public abstract class PersistentIdGenerator extends AbstractSequentialIdGenerator implements IdGenerator
IdGenerator that gives out ids suitable for use
with persistent objects. The ids are reserved in batches from some
a persistent data store. The ids generated generally sequential and
strictly increasing. A PersistentIdGenerator will not avoid ever
giving out the same id twice for a given IdSpace, even
across restarts of the JVM.
This class reserves batches of ids from the data store and doles
them out one at a time. Thus the ids given out are generally
sequential and strictly increasing. Subclasses should indicate
whether or not they are safe to use in a distributed system.IdGenerator| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
CLASS_VERSION
Class version string
|
protected static java.lang.String |
ERR_ADD_BAD_STATE |
protected static java.lang.String |
ERR_ADD_NULL_SPACE |
protected static java.lang.String |
ERR_READING_BOOTSTRAP_SPACES |
protected static int |
STATE_ERROR |
protected static int |
STATE_INITIALIZING |
protected static int |
STATE_NEW |
protected static int |
STATE_RUNNING |
protected static java.lang.String |
WARN_PICKING_DEFAULT |
ERR_BAD_SPACE, ERR_ROLLBACK, ERR_UNSUPPORTED, mSpaces, RESOURCE_BUNDLE_NAME, sResourceBundleSERVICE_INFO_KEYDEFAULT_LOG_TRACE_STATUSDEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS| Constructor and Description |
|---|
PersistentIdGenerator() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
addIdSpace(IdSpace pSpace)
Add an id space to the id generator.
|
protected abstract boolean |
addPersistentIdSpace(IdSpace pSpace)
Add id space to the data store.
|
atg.xml.XMLFile |
getInitialIdSpaces()
Get property
initialIdSpaces |
boolean |
getLoadInitialIdSpacesAtStartup()
Get property
loadInitialIdSpacesAtStartup. |
protected int |
getState()
Get the current state
|
javax.transaction.TransactionManager |
getTransactionManager()
Get property
TransactionManager |
atg.xml.tools.XMLToolsFactory |
getXMLToolsFactory()
Get property
XMLToolsFactory |
void |
initialize()
Initialize the generator.
|
protected abstract void |
initializeIdSpaces()
Initialize the id spaces from the data store.
|
void |
removeAllIdSpaces()
Remove all id spaces from the id generator.
|
boolean |
removeIdSpace(IdSpace pSpace)
Remove an id space from the id generator.
|
protected abstract void |
reserveSeeds(IdSpace pSpace)
Reserve a batch of seeds for the specified id space and update
the id space itself with the new seed information.
|
void |
setInitialIdSpaces(atg.xml.XMLFile pInitialIdSpaces)
Set property
initialIdSpaces |
void |
setLoadInitialIdSpacesAtStartup(boolean pLoadInitialIdSpacesAtStartup)
Set property
loadInitialIdSpacesAtStartup. |
protected void |
setState(int pState)
Set the current state
|
void |
setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Set property
TransactionManager |
void |
setXMLToolsFactory(atg.xml.tools.XMLToolsFactory pXMLToolsFactory)
Set property
XMLToolsFactory |
doStartService, format, format, format, format, generateLongId, generateLongId, generateStringId, generateStringId, getAutoCreate, getBundle, getDefaultIdSpace, getDefaultIdSpaceName, getIdSpace, getIdSpaces, getResourceBundleName, isAutoCreate, postGenerateLongId, postGenerateStringId, setAutoCreate, setDefaultIdSpace, setDefaultIdSpaceName, setHighWaterMark, toStringaddLogListener, 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, stopServicevlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogDebugTrace, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarningclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgenerateLongId, generateLongId, generateStringId, generateStringId, getAutoCreate, getDefaultIdSpace, getIdSpace, getIdSpaces, isAutoCreate, setAutoCreatepublic static java.lang.String CLASS_VERSION
protected static int STATE_NEW
protected static int STATE_INITIALIZING
protected static int STATE_RUNNING
protected static int STATE_ERROR
protected static java.lang.String WARN_PICKING_DEFAULT
protected static java.lang.String ERR_READING_BOOTSTRAP_SPACES
protected static java.lang.String ERR_ADD_NULL_SPACE
protected static java.lang.String ERR_ADD_BAD_STATE
protected final void setState(int pState)
pState - new value to setprotected final int getState()
public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
TransactionManagerpTransactionManager - new value to setpublic javax.transaction.TransactionManager getTransactionManager()
TransactionManagerTransactionManagerpublic void setXMLToolsFactory(atg.xml.tools.XMLToolsFactory pXMLToolsFactory)
XMLToolsFactorypXMLToolsFactory - new value to setpublic atg.xml.tools.XMLToolsFactory getXMLToolsFactory()
XMLToolsFactoryXMLToolsFactorypublic void setInitialIdSpaces(atg.xml.XMLFile pInitialIdSpaces)
initialIdSpacespInitialIdSpaces - new value to setpublic atg.xml.XMLFile getInitialIdSpaces()
initialIdSpacesinitialIdSpacespublic void setLoadInitialIdSpacesAtStartup(boolean pLoadInitialIdSpacesAtStartup)
loadInitialIdSpacesAtStartup. This is if true
the XML file specified by the initialIdSpaces property is loaded at
startup. If false the XML file is only loaded when no persistent ids are
found in the DB. The default is true.pLoadInitialIdSpacesAtStartup - new value to setpublic boolean getLoadInitialIdSpacesAtStartup()
loadInitialIdSpacesAtStartup. If this is true
the XML file specified by the initialIdSpaces property is loaded at
startup. If false the XML file is only loaded when no persistent ids are
found in the DB. The default is true.loadInitialIdSpacesAtStartuppublic void initialize()
throws IdGeneratorException
initialize in interface IdGeneratorinitialize in class AbstractSequentialIdGeneratorIdGeneratorException - 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 abstract void reserveSeeds(IdSpace pSpace) throws IdGeneratorException
pSpace - id space to reserve seeds in, cannot be nullIdGeneratorException - if there is a problem reserving
the seedsprotected abstract void initializeIdSpaces()
throws IdGeneratorException
IdGeneratorExceptionpublic boolean addIdSpace(IdSpace pSpace) throws IdGeneratorException
addIdSpace in interface IdGeneratoraddIdSpace in class AbstractSequentialIdGeneratorpSpace - space to add, cannot be nullIdGeneratorException - if there is trouble adding the spaceprotected abstract boolean addPersistentIdSpace(IdSpace pSpace) throws IdGeneratorException
pSpace - space to add, will not be nullIdGeneratorExceptionpublic boolean removeIdSpace(IdSpace pSpace) throws IdGeneratorException
removeIdSpace in interface IdGeneratorremoveIdSpace in class AbstractSequentialIdGeneratorpSpace - space to remove, cannot be nullIdGeneratorException - not yet supportedpublic void removeAllIdSpaces()
throws IdGeneratorException
removeAllIdSpaces in interface IdGeneratorremoveAllIdSpaces in class AbstractSequentialIdGeneratorIdGeneratorException - not yet supported