Class AbstractStateContextLookup
- java.lang.Object
-
- org.apache.mina.statemachine.context.AbstractStateContextLookup
-
- All Implemented Interfaces:
StateContextLookup
- Direct Known Subclasses:
IoSessionStateContextLookup
public abstract class AbstractStateContextLookup extends java.lang.Object implements StateContextLookup
AbstractStateContextLookupimplementation. Thelookup(Object[])method will loop through the event arguments and call the supports(Class) method for each of them. The first argument that this method returnstruefor will be passed to the abstract lookup(Object) method which should try to extract aStateContextfrom the argument. If none is found a newStateContextwill be created and stored in the event argument using the store(Object, StateContext) method.
-
-
Field Summary
Fields Modifier and Type Field Description private StateContextFactorycontextFactory
-
Constructor Summary
Constructors Constructor Description AbstractStateContextLookup(StateContextFactory contextFactory)Creates a new instance which uses the specifiedStateContextFactoryto createStateContextobjects.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract StateContextlookup(java.lang.Object eventArg)Extracts aStateContextfrom the specified event argument which is an instance of a classsupports(Class)returnstruefor.StateContextlookup(java.lang.Object[] eventArgs)Searches the arguments from anEventand returns aStateContextif any of the arguments holds one.protected abstract voidstore(java.lang.Object eventArg, StateContext context)Stores a newStateContextin the specified event argument which is an instance of a classsupports(Class)returnstruefor.protected abstract booleansupports(java.lang.Class<?> c)Must returntruefor anyClassthat thisStateContextLookupcan use to store and lookupStateContextobjects.
-
-
-
Field Detail
-
contextFactory
private final StateContextFactory contextFactory
-
-
Constructor Detail
-
AbstractStateContextLookup
public AbstractStateContextLookup(StateContextFactory contextFactory)
Creates a new instance which uses the specifiedStateContextFactoryto createStateContextobjects.- Parameters:
contextFactory- the factory.
-
-
Method Detail
-
lookup
public StateContext lookup(java.lang.Object[] eventArgs)
Description copied from interface:StateContextLookupSearches the arguments from anEventand returns aStateContextif any of the arguments holds one. NOTE! This method must create a newStateContextif a compatible object is in the arguments and the next time that same object is passed to this method the sameStateContextshould be returned.- Specified by:
lookupin interfaceStateContextLookup- Parameters:
eventArgs- The arguments we are looking for- Returns:
- The StateContext we are looking for
-
lookup
protected abstract StateContext lookup(java.lang.Object eventArg)
Extracts aStateContextfrom the specified event argument which is an instance of a classsupports(Class)returnstruefor.- Parameters:
eventArg- the event argument.- Returns:
- the
StateContext.
-
store
protected abstract void store(java.lang.Object eventArg, StateContext context)Stores a newStateContextin the specified event argument which is an instance of a classsupports(Class)returnstruefor.- Parameters:
eventArg- the event argument.context- theStateContextto be stored.
-
supports
protected abstract boolean supports(java.lang.Class<?> c)
Must returntruefor anyClassthat thisStateContextLookupcan use to store and lookupStateContextobjects.- Parameters:
c- the class.- Returns:
trueorfalse.
-
-