public class SimpleContextManager extends java.lang.Object implements ContextManager
| Modifier and Type | Class and Description |
|---|---|
static class |
SimpleContextManager.DefaultInstanceStoreFactory |
| Modifier and Type | Field and Description |
|---|---|
protected Application |
application |
static java.lang.String |
CONTEXT_CREATE |
static java.lang.String |
CONTEXT_DESTROY |
protected EventBus |
eventBus |
| Constructor and Description |
|---|
SimpleContextManager() |
SimpleContextManager(Application application)
Create a simple context manager using the specified application
|
SimpleContextManager(Application application,
EventBus eventBus)
Create a simple context manager using the specified application and event bus
|
| Modifier and Type | Method and Description |
|---|---|
void |
addToContextsToDestroy(java.lang.String contextId)
Add context to the list of contexts to destroy
|
protected Context |
createContext(Context parentCtx,
java.lang.String contextId) |
void |
destroyContext(java.lang.String contextId)
Destroy a context
|
void |
destroyContexts()
Destroy all contexts
|
void |
destroyFinishedContexts()
Destroy finished contexts and reset current pending contexts
|
java.util.List<Context> |
getAllContexts()
Get a list of all conversation contexts
|
Context |
getContext()
Get the global context
|
Context |
getContext(java.lang.String contextId)
Get the context from its id
|
Context |
getContext(java.lang.String contextId,
java.lang.String parentContextId,
boolean create)
Get a context from its id with the specified parent id, and create it if it does not exist
|
void |
initModules(java.lang.Class<?>... moduleClasses)
Configure modules for specified class names
|
void |
initModules(java.lang.String... moduleClassNames)
Configure modules for specified class names
|
boolean |
isGlobal(Context context)
Determine if the specified context is the global one
|
Context |
newContext(java.lang.String contextId,
java.lang.String parentContextId)
Create a context with the specified id and parent id if it does not exist
|
void |
registerFactory(java.lang.Class<?> type,
Factory<?> factory) |
void |
registerFactory(java.lang.String name,
Factory<?> factory) |
void |
removeFromContextsToDestroy(java.lang.String contextId)
Remove context from the list of contexts to destroy
|
Context |
retrieveContext(Context sourceContext,
java.lang.String contextId,
boolean wasConversationCreated,
boolean wasConversationEnded)
Get or create the context for the specified context id and server conversation flags
|
void |
scanModules(java.lang.String... packageNames)
Scan specific packages and configure found modules
|
void |
setInstanceStoreFactory(InstanceStoreFactory instanceStoreFactory)
Set the instance store factory for this context manager
|
void |
updateContextId(java.lang.String previousContextId,
Context context)
Defines new context for existing id
|
public static final java.lang.String CONTEXT_CREATE
public static final java.lang.String CONTEXT_DESTROY
protected final Application application
protected final EventBus eventBus
public SimpleContextManager()
public SimpleContextManager(Application application)
application - applicationpublic SimpleContextManager(Application application, EventBus eventBus)
application - applicationeventBus - event buspublic void setInstanceStoreFactory(InstanceStoreFactory instanceStoreFactory)
instanceStoreFactory - instance store factorypublic boolean isGlobal(Context context)
isGlobal in interface ContextManagercontext - public Context getContext()
ContextManagergetContext in interface ContextManagerpublic Context getContext(java.lang.String contextId)
ContextManagergetContext in interface ContextManagercontextId - context idpublic Context getContext(java.lang.String contextId, java.lang.String parentContextId, boolean create)
ContextManagergetContext in interface ContextManagercontextId - context idparentContextId - parent context idcreate - if true, create a context if not existpublic Context newContext(java.lang.String contextId, java.lang.String parentContextId)
ContextManagernewContext in interface ContextManagercontextId - context idparentContextId - parent context idpublic void destroyContext(java.lang.String contextId)
ContextManagerdestroyContext in interface ContextManagercontextId - context idpublic java.util.List<Context> getAllContexts()
ContextManagergetAllContexts in interface ContextManagerpublic void destroyContexts()
ContextManagerdestroyContexts in interface ContextManagerpublic void destroyFinishedContexts()
ContextManagerdestroyFinishedContexts in interface ContextManagerpublic void removeFromContextsToDestroy(java.lang.String contextId)
removeFromContextsToDestroy in interface ContextManagercontextId - context idpublic void addToContextsToDestroy(java.lang.String contextId)
addToContextsToDestroy in interface ContextManagercontextId - context idpublic Context retrieveContext(Context sourceContext, java.lang.String contextId, boolean wasConversationCreated, boolean wasConversationEnded)
ContextManagerretrieveContext in interface ContextManagersourceContext - source contextcontextId - conversation context idwasConversationCreated - true if the conversation was just created by the last request on the serverwasConversationEnded - true if the conversation was just ended by the last request on the serverpublic void updateContextId(java.lang.String previousContextId,
Context context)
updateContextId in interface ContextManagerpreviousContextId - existing idcontext - new contextpublic void scanModules(java.lang.String... packageNames)
packageNames - module package namespublic void initModules(java.lang.String... moduleClassNames)
moduleClassNames - module classespublic void initModules(java.lang.Class<?>... moduleClasses)
moduleClasses - module classespublic void registerFactory(java.lang.String name,
Factory<?> factory)
public void registerFactory(java.lang.Class<?> type,
Factory<?> factory)