public class ObfuscatedSQLIdGenerator extends SQLIdGenerator
This implementation obfuscates the generated ids in two ways. First, for a given batch of reservered ids this implementation only gives out a few ids. Second, ids can be optionally hex encoded when being used as String ids. Both the String and long ids generated use a pseudorandom number generator to get a long id from the current batch of ids. In addition to not giving out the same id twice, this implementation will not given out adjacent long ids (or String ids that come from adjacent long ids).
This implementation is suitable for use in a distributed system. Transactionality integrity is provided by the underlying data store, which is an SQL database.
 The IdSpace properties batchSize and idsPerBatch
 are used in conjunction. batchSize works as in the
 SQLIdGenerator. idsPerBatch is the maximum never of ids that
 will be given out in any given batch.
 It is strongly recommended that idsPerBatch be less than 1%
 of the batchSize. This is both for security and
 performance. For security a sparse (i.e., less dense) id space makes it
 harder to guess ids. Since this implementation does not give out adjacent
 ids, it could be forced to do more work to find suitable ids if the id
 space is too dense. This implementation will not allow an id space to be
 added that is denser than 10%. That is, idsPerBatch /
 batchSize must be less than .1. Always set these
 two properties together to maintain the 1% density goal.
 The recommended values for batchSize and
 idsPerBatch are 100,000 and 997, respectively. These numbers
 are not magic. 100,000 is the default batch size. 997 is a prime number
 that is slightly less than 1% of the batch size.
PersistentIdGenerator, 
SQLIdGenerator| Modifier and Type | Field and Description | 
|---|---|
static java.lang.String | 
CLASS_VERSION
Class version string 
 | 
protected static java.lang.String | 
ERR_TOO_DENSE  | 
static float | 
MAX_DENSITY
maximum density for obfuscated id generators 
 | 
ERR_HWM_BAD_STATE, ERR_HWM_FAIL, ERR_NULL_DS, ERR_QUERY_TABLE, ERR_RESERVE_BAD_STATEERR_ADD_BAD_STATE, ERR_ADD_NULL_SPACE, ERR_READING_BOOTSTRAP_SPACES, STATE_ERROR, STATE_INITIALIZING, STATE_NEW, STATE_RUNNING, WARN_PICKING_DEFAULTERR_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 | 
|---|
ObfuscatedSQLIdGenerator()
Construct a generator 
 | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
addIdSpace(IdSpace pSpace)
Add an id space to the id generator. 
 | 
protected boolean | 
addPersistentIdSpace(IdSpace pSpace)
Add an id space to the data store. 
 | 
protected void | 
createNewDefaultIdSpace()
Make sure the default id space exists, creating it if necessary. 
 | 
boolean | 
getHexEncode()
Get property  
hexEncode | 
java.lang.String | 
getIdsPerBatchColumn()
Get property  
idsPerBatchColumn | 
java.lang.String | 
getInsertSQL()
Get property  
InsertSQL. | 
java.lang.String | 
getSelectSQL()
Get property  
SelectSQL. | 
java.lang.String | 
getUpdateSQL()
Get property  
UpdateSQL. | 
boolean | 
isHexEncode()
Test property  
hexEncode | 
protected void | 
reserveSeeds(IdSpace pSpace)
Reserve a batch of seeds for the specified id space. 
 | 
void | 
setHexEncode(boolean pHexEncode)
Set property  
hexEncode | 
void | 
setIdsPerBatchColumn(java.lang.String pIdsPerBatchColumn)
Set property  
idsPerBatchColumn | 
getBatchSizeColumn, getDataSource, getNameColumn, getPrefixColumn, getSeedColumn, getSuffixColumn, getTableName, getUseRequiredTransactionMode, initializeIdSpaces, removePersistentIdSpaces, setBatchSizeColumn, setDataSource, setHighWaterMark, setNameColumn, setPrefixColumn, setSeedColumn, setSuffixColumn, setTableName, setUseRequiredTransactionModegetInitialIdSpaces, getLoadInitialIdSpacesAtStartup, getState, getTransactionManager, getXMLToolsFactory, initialize, removeAllIdSpaces, removeIdSpace, setInitialIdSpaces, setLoadInitialIdSpacesAtStartup, setState, setTransactionManager, setXMLToolsFactorydoStartService, format, format, format, format, generateLongId, generateLongId, generateStringId, generateStringId, getAutoCreate, getBundle, getDefaultIdSpace, getDefaultIdSpaceName, getIdSpace, getIdSpaces, getResourceBundleName, isAutoCreate, postGenerateLongId, postGenerateStringId, setAutoCreate, setDefaultIdSpace, setDefaultIdSpaceName, 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
public static float MAX_DENSITY
protected static java.lang.String ERR_TOO_DENSE
public void setIdsPerBatchColumn(java.lang.String pIdsPerBatchColumn)
idsPerBatchColumnpIdsPerBatchColumn - new value to setpublic java.lang.String getIdsPerBatchColumn()
idsPerBatchColumnidsPerBatchColumnpublic void setHexEncode(boolean pHexEncode)
hexEncodepHexEncode - new value to setpublic boolean getHexEncode()
hexEncodehexEncodepublic boolean isHexEncode()
hexEncodehexEncodepublic java.lang.String getSelectSQL()
SelectSQL. The SQL is lazily generated.getSelectSQL in class SQLIdGeneratorpublic java.lang.String getInsertSQL()
InsertSQL. The SQL is lazily generated.getInsertSQL in class SQLIdGeneratorpublic java.lang.String getUpdateSQL()
UpdateSQL. The SQL is lazily generated.getUpdateSQL in class SQLIdGeneratorpublic boolean addIdSpace(IdSpace pSpace) throws IdGeneratorException
idsPerBatch property of
 the id space. Somewhat reasonable means a prime number not large than
 roughly 1% of the batch size:
 batchSize | 
   idsPerBatch | 
  
| >=100,000 | 997 | 
| >=10,000 | 89 | 
| >=else | 7 | 
addIdSpace in interface IdGeneratoraddIdSpace in class PersistentIdGeneratorpSpace - space to add, cannot be nullIdGeneratorException - if there is trouble adding the spaceprotected boolean addPersistentIdSpace(IdSpace pSpace) throws IdGeneratorException
addPersistentIdSpace in class SQLIdGeneratorpSpace - space to add, cannot be nullIdGeneratorException - if there is trouble adding id spaceprotected void createNewDefaultIdSpace()
protected void reserveSeeds(IdSpace pSpace) throws IdGeneratorException
DataSource for use and closes that
 connection when done. This method also runs in its own new transaction.reserveSeeds in class SQLIdGeneratorpSpace - id space to reserve seeds in, cannot be nullIdGeneratorException - if there is DB trouble