Package adams.flow.rest.dex.backend
Class InMemory
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.flow.rest.dex.backend.AbstractBackend
-
- adams.flow.rest.dex.backend.InMemory
-
- All Implemented Interfaces:
adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.SizeOfHandler
,Serializable
public class InMemory extends AbstractBackend
Simply stores the uploaded data in memory, with no persistence.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
InMemory.DataContainer
Wraps the actual data item with the expiry timestamp.
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,InMemory.DataContainer>
m_Storage
the in-memory storage.-
Fields inherited from class adams.flow.rest.dex.backend.AbstractBackend
m_Initialized, m_SequentialTokens, m_TimeToLive
-
-
Constructor Summary
Constructors Constructor Description InMemory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
addItem(byte[] data)
Adds the item, returns the generated token.protected void
doClear()
Removes all items.protected String
doInitBackend()
Initializes the backend.protected void
doPurge()
Purges any expired items.protected byte[]
getItem(String token)
Gets the item, if present.String
globalInfo()
Returns a string describing the object.protected boolean
hasItem(String token)
Checks whether the item is present.protected boolean
removeItem(String token)
Removes the data associated with the token.-
Methods inherited from class adams.flow.rest.dex.backend.AbstractBackend
add, clear, defineOptions, get, getSequentialTokens, getTimeToLive, has, initBackend, nextToken, purge, remove, reset, sequentialTokensTipText, setSequentialTokens, setTimeToLive, timeToLiveTipText
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
Field Detail
-
m_Storage
protected Map<String,InMemory.DataContainer> m_Storage
the in-memory storage.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
doInitBackend
protected String doInitBackend()
Initializes the backend.- Specified by:
doInitBackend
in classAbstractBackend
- Returns:
- null if sucessfully initialized, otherwise error message
-
doClear
protected void doClear()
Removes all items.- Specified by:
doClear
in classAbstractBackend
-
doPurge
protected void doPurge()
Purges any expired items.- Specified by:
doPurge
in classAbstractBackend
-
hasItem
protected boolean hasItem(String token)
Checks whether the item is present.- Specified by:
hasItem
in classAbstractBackend
- Parameters:
token
- the token to check- Returns:
- true if available
-
getItem
protected byte[] getItem(String token)
Gets the item, if present.- Specified by:
getItem
in classAbstractBackend
- Parameters:
token
- the token to get- Returns:
- the item, null if not available
-
addItem
protected String addItem(byte[] data)
Adds the item, returns the generated token.- Specified by:
addItem
in classAbstractBackend
- Parameters:
data
- the data to add- Returns:
- the token, null if failed to add
-
removeItem
protected boolean removeItem(String token)
Removes the data associated with the token.- Specified by:
removeItem
in classAbstractBackend
- Parameters:
token
- the token to remove the data for- Returns:
- true if removed
-
-