Class DefaultCachingSerialNumberGenerator
- java.lang.Object
-
- de.hybris.platform.persistence.numberseries.DefaultCachingSerialNumberGenerator
-
- All Implemented Interfaces:
SerialNumberGenerator
public class DefaultCachingSerialNumberGenerator extends java.lang.Object implements SerialNumberGenerator
Default implementation ofSerialNumberGeneratorwhich caches number ranges for each key.Cache size may be specified in project.properties like this:
# set cache size for single series 'myseries' to 50 numberseries.cache.size.myseries=50 # set default cache size to 999 numberseries.cache.size=999
-
-
Constructor Summary
Constructors Constructor Description DefaultCachingSerialNumberGenerator(Tenant t, SerialNumberDAO dao)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidclearAll()Completely clear all (cached) ranges.voidcreateSeries(java.lang.String key, int type, long startValue)Deprecated.since agesvoidcreateSeries(java.lang.String key, int type, long startValue, java.lang.String template)Creates a new number series with the specified key, type and start value.java.util.Collection<NumberSeries>getAllInfo()Returns snapshot of all number series of this tenant.protected intgetCacheSize(java.lang.String key)SerialNumberDAOgetDao()NumberSeriesgetInfo(java.lang.String key)Returns a snapshot of a specified number series.protected TenantgetTenant()NumberSeriesgetUniqueNumber(java.lang.String key)Generates a new unique number for the given series.voidremoveSeries(java.lang.String key)Removes a existing number series.voidresetSeries(java.lang.String key, int type, long startValue)Resets type and start value of a existing series.
-
-
-
Constructor Detail
-
DefaultCachingSerialNumberGenerator
public DefaultCachingSerialNumberGenerator(Tenant t, SerialNumberDAO dao)
-
-
Method Detail
-
createSeries
public void createSeries(java.lang.String key, int type, long startValue, java.lang.String template)Description copied from interface:SerialNumberGeneratorCreates a new number series with the specified key, type and start value.- Specified by:
createSeriesin interfaceSerialNumberGenerator- Parameters:
key- the series keytype- the type; use one ofNumberSeries.TYPE_ALPHANUMERICandNumberSeries.TYPE_NUMERICstartValue- the start value - must be positive longtemplate- the template to be applied on generated value
-
createSeries
@Deprecated public void createSeries(java.lang.String key, int type, long startValue)Deprecated.since agesDescription copied from interface:SerialNumberGeneratorCreates a new number series with the specified key, type and start value.- Specified by:
createSeriesin interfaceSerialNumberGenerator- Parameters:
key- the series keytype- the type; use one ofNumberSeries.TYPE_ALPHANUMERICandNumberSeries.TYPE_NUMERICstartValue- the start value - must be positive long
-
getUniqueNumber
public NumberSeries getUniqueNumber(java.lang.String key)
Description copied from interface:SerialNumberGeneratorGenerates a new unique number for the given series. The returned number is consumed and will never be returned again. Please note that transactions have no effect upon number generation!- Specified by:
getUniqueNumberin interfaceSerialNumberGenerator- Parameters:
key- the series key
-
getInfo
public NumberSeries getInfo(java.lang.String key)
Description copied from interface:SerialNumberGeneratorReturns a snapshot of a specified number series.- Specified by:
getInfoin interfaceSerialNumberGenerator- Parameters:
key- the series key.
-
getAllInfo
public java.util.Collection<NumberSeries> getAllInfo()
Description copied from interface:SerialNumberGeneratorReturns snapshot of all number series of this tenant.- Specified by:
getAllInfoin interfaceSerialNumberGenerator
-
removeSeries
public void removeSeries(java.lang.String key)
Description copied from interface:SerialNumberGeneratorRemoves a existing number series.- Specified by:
removeSeriesin interfaceSerialNumberGenerator- Parameters:
key- the series key
-
resetSeries
public void resetSeries(java.lang.String key, int type, long startValue)Description copied from interface:SerialNumberGeneratorResets type and start value of a existing series. Please use with care since duplicate numbers are likely to be generated if start value is moved 'back'!- Specified by:
resetSeriesin interfaceSerialNumberGenerator- Parameters:
key- the series keytype- the series typestartValue- the start value
-
clearAll
public void clearAll()
Description copied from interface:SerialNumberGeneratorCompletely clear all (cached) ranges. This is only called after the 'numberseries' table has been dropped.- Specified by:
clearAllin interfaceSerialNumberGenerator
-
getTenant
protected Tenant getTenant()
-
getDao
public SerialNumberDAO getDao()
-
getCacheSize
protected int getCacheSize(java.lang.String key)
-
-