public class SimpleDataStore extends DataStore
A simple concrete implementation of the datastore class.
The Datastore, takes a number of properties which determines its behaviour, these are:-
#The Fully qualified filename where data will be stored.
simpledatastore.fileName
#The Fully qualified filename where a semaphore lock file will be stored.
simpledatastore.lockFile
#The number of attempts made to get a lock before an error is thrown
simpledatastore.maxLockAttempts
DataStore
In the adapter configuration file this class is aliased as simple-data-store which is the preferred alternative to the fully qualified classname when building your configuration.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_FILENAME
The default data filename.
|
static java.lang.String |
DEFAULT_LOCK
The default lock file.
|
static java.lang.String |
FILE_PROPERTY
The filename property
|
static java.lang.String |
LOCK_PROPERTY
The locfile property
|
static java.lang.String |
MAXLOCK_PROPERTY
the max lock attempts property
|
Constructor and Description |
---|
SimpleDataStore() |
SimpleDataStore(java.util.Properties p)
Constructor using a set of properties.
|
Modifier and Type | Method and Description |
---|---|
boolean |
exists(java.lang.String id,
java.lang.String type)
Check if the data exists in the store.
|
java.lang.String |
getDataFile()
Get the data filename.
|
void |
getLock()
Get a lock on the file
|
java.lang.String |
getLockFile()
Get the lock file name.
|
int |
getMaxAttempts()
Return the number of attempts to gain a lock
|
void |
persist(java.lang.String id,
java.lang.String type,
java.lang.Object obj)
Persist the data to the store.
|
void |
remove(java.lang.String id,
java.lang.String type)
Remove the data from the datastore.
|
void |
removeLock()
Remove the lock.
|
java.lang.Object |
retrieve(java.lang.String id,
java.lang.String type)
Retrieve the data from the datastore.
|
void |
setConfiguration(java.util.Properties p)
Set the configuration for this datastore.
|
void |
setDataFile(java.lang.String string)
The Data file stored url format.
|
void |
setLockFile(java.lang.String string)
The lock file in url format.
|
void |
setMaxAttempts(int i)
Set the number of attempts to gain a lock.
|
getConfiguration
public static final java.lang.String FILE_PROPERTY
public static final java.lang.String LOCK_PROPERTY
public static final java.lang.String MAXLOCK_PROPERTY
public static final java.lang.String DEFAULT_FILENAME
public static final java.lang.String DEFAULT_LOCK
public SimpleDataStore()
DataStore.DataStore()
public SimpleDataStore(java.util.Properties p) throws DataStoreException
p
- the properties.DataStoreException
- if there is an error.FILE_PROPERTY
,
LOCK_PROPERTY
,
MAXLOCK_PROPERTY
public void persist(java.lang.String id, java.lang.String type, java.lang.Object obj) throws DataStoreException
DataStore
persist
in class DataStore
id
- the idtype
- the typeobj
- object stored in the datastoreDataStoreException
- if an error is encounteredDataStore.persist(String, String, Object)
public java.lang.Object retrieve(java.lang.String id, java.lang.String type) throws DataStoreException
DataStore
retrieve
in class DataStore
id
- the idtype
- the typeDataStoreException
- if an error is encounteredDataStore.retrieve(String, String)
public void remove(java.lang.String id, java.lang.String type) throws DataStoreException
DataStore
remove
in class DataStore
id
- the idtype
- the typeDataStoreException
- if an error is encounteredDataStore.remove(String, String)
public boolean exists(java.lang.String id, java.lang.String type) throws DataStoreException
DataStore
exists
in class DataStore
id
- the idtype
- the typeDataStoreException
- if an error is encounteredDataStore.exists(String, String)
public void getLock() throws java.lang.Exception
java.lang.Exception
- if we could not get the lock.public void removeLock()
public void setDataFile(java.lang.String string)
string
- the data file.public java.lang.String getDataFile()
public void setLockFile(java.lang.String string)
string
- the lock filepublic java.lang.String getLockFile()
public void setMaxAttempts(int i)
i
- the number of attempts, default is 15.public int getMaxAttempts()
public void setConfiguration(java.util.Properties p) throws DataStoreException
DataStore
setConfiguration
in class DataStore
p
- the configurationDataStoreException
- if there was an error.DataStore.setConfiguration(java.util.Properties)