public class FileIdGenerator extends PersistentIdGenerator
IdSpaces
in a flat
file as a serialized Map
. This implementation is
not suitable for distributed systems.This implementation is intended for use in applications that desire simple persistent ids but do not need the transactional features of a database. For example, a file logger may associate ids with log entries. The file logger needs the ids to be unique across JVM restarts, however it does not need to share these ids with loggers in other JVMs.
Different applications can use a single instance of the file id generator. Different file id generators must not use the same data file.
No file locking is attempted. The flat file should not be modified by any other facility, nor should it be read while it is in use.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
ERR_ADD_BAD_STATE, ERR_ADD_NULL_SPACE, ERR_READING_BOOTSTRAP_SPACES, STATE_ERROR, STATE_INITIALIZING, STATE_NEW, STATE_RUNNING, WARN_PICKING_DEFAULT
ERR_BAD_SPACE, ERR_ROLLBACK, ERR_UNSUPPORTED, mSpaces, RESOURCE_BUNDLE_NAME, sResourceBundle
SERVICE_INFO_KEY
DEFAULT_LOG_TRACE_STATUS
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
Constructor and Description |
---|
FileIdGenerator() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
addPersistentIdSpace(IdSpace pSpace)
Add an id space to the data store.
|
java.io.File |
getDataFile()
Get property
dataFile . |
void |
initialize()
Initialize the id generator
mgkmgk: need to override this as we do not want a transaction manager
may need to factor the initialize in our parent...bleh
|
protected void |
initializeIdSpaces()
Initialize the id spaces from the data store.
|
boolean |
isMakeDirs()
Returns whether or not the parent directories of the data file should be
created if they don't exist.
|
protected void |
reserveSeeds(IdSpace pSpace)
Reserve a batch of seeds for the specified id space from the
persistent store.
|
void |
setDataFile(java.io.File pDataFile)
Set property
dataFile . |
void |
setMakeDirs(boolean pMakeDirs)
Sets whether or not the parent directories of the data file should be
created if they don't exist.
|
addIdSpace, getInitialIdSpaces, getLoadInitialIdSpacesAtStartup, getState, getTransactionManager, getXMLToolsFactory, removeAllIdSpaces, removeIdSpace, setInitialIdSpaces, setLoadInitialIdSpacesAtStartup, setState, setTransactionManager, setXMLToolsFactory
doStartService, format, format, format, format, generateLongId, generateLongId, generateStringId, generateStringId, getAutoCreate, getBundle, getDefaultIdSpace, getDefaultIdSpaceName, getIdSpace, getIdSpaces, getResourceBundleName, isAutoCreate, postGenerateLongId, postGenerateStringId, setAutoCreate, setDefaultIdSpace, setDefaultIdSpaceName, setHighWaterMark, toString
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getAdminServletOutputStreamEncoding, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isAdminServletUseServletOutputStream, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, reResolveThis, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setAdminServletOutputStreamEncoding, setAdminServletUseServletOutputStream, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
generateLongId, generateLongId, generateStringId, generateStringId, getAutoCreate, getDefaultIdSpace, getIdSpace, getIdSpaces, isAutoCreate, setAutoCreate
public void setDataFile(java.io.File pDataFile)
dataFile
. This is
the file to hold the persistent state of this id generator.pDataFile
- new value to setpublic java.io.File getDataFile()
dataFile
. This is
the file to hold the persistent state of this id generator.dataFile
public boolean isMakeDirs()
public void setMakeDirs(boolean pMakeDirs)
pMakeDirs
- the makeDirs to setpublic void initialize() throws IdGeneratorException
initialize
in interface IdGenerator
initialize
in class PersistentIdGenerator
IdGeneratorException
- if there is an error
initializing. If initialization was unsuccessful the
IdGeneratorException may have a source exception which is a chain
of all of the exceptions encountered during the attempt to initializeprotected void initializeIdSpaces() throws IdGeneratorException
initializeIdSpaces
in class PersistentIdGenerator
IdGeneratorException
- if there is a problemprotected boolean addPersistentIdSpace(IdSpace pSpace) throws IdGeneratorException
addPersistentIdSpace
in class PersistentIdGenerator
pSpace
- space to add, cannot be null. Nota Bene: this may be
modified by this method.IdGeneratorException
- if there is trouble adding id spaceprotected void reserveSeeds(IdSpace pSpace) throws IdGeneratorException
reserveSeeds
in class PersistentIdGenerator
pSpace
- space in which to reserve seeds, must not be nullIdGeneratorException
- if there is a problem with the
persistent store