|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IContextStore
The ContextStore manages a persistent store for context events and manages context providers and consumers through a uniform interface. Context events are dispatched to registered handlers according to the registered types of the handlers. Handlers can change the registration for context types during their lifetime.
Since version 1.1.0, the semantics of the newContextEvent
methods changed substantially: the events created this way are no longer processed
synchronously. Handlers execute their handling code in own threads.
Also since version 1.1.0, ContextStores now feature a (ideally unique) ID. This ID might be used in future releases, where communication between ContextStores (e.g. on different hosts) might be possible.
OSGi notice: In OSGi environments, the ContextStore is registered as a service providing this interface.
IContextHandler
Field Summary | |
---|---|
static java.lang.String |
CONTEXT_STORE_ID
|
static java.lang.String |
TYPE_ALL
This constant is used as a context type when a handler should receive all context events |
static java.lang.String |
TYPE_DEREGISTERED
|
static java.lang.String |
TYPE_REGISTERED
|
Method Summary | |
---|---|
void |
activateEventsForHandler(IContextHandler ctxHandler)
Activate notification. |
void |
deactivateEventsForHandler(IContextHandler ctxHandler)
Deactivate notification. |
void |
deregisterContextType(java.lang.String ctxType)
Deregister context type in the ContextStore. |
void |
deregisterHandler(IContextHandler ctxHandler)
Deregister context handler. |
void |
deregisterHandlerForContextType(IContextHandler ctxHandler,
java.lang.String ctxType)
Deregister the context handler for the given context type. |
java.lang.String[] |
getHandlersRegisteredContextTypes(IContextHandler handler)
Returns all registered context types for committed handler. |
java.lang.String[] |
getRegisteredContextTypes()
Returns all registered context types. |
IContextStorage |
getStorage()
Returns the storage handler of the context store, which handles storing, loading, querying and deleting context events |
java.lang.String |
getStoreID()
Returns the ID of the ContextStore. |
boolean |
isRegisteredContextType(java.lang.String myType)
Checks if given context type is registered in the ContextStore. |
void |
newContextEvent(ContextEvent ctxEvent)
Insert a new context in the ContextStore. |
void |
newContextEvent(ContextEvent ctxEvent,
boolean persist)
Insert a new context in the ContextStore. |
void |
newContextEvent(java.lang.String originID,
java.lang.String type,
java.lang.Object data,
java.util.Date date)
Insert a new context with the given parameters in the ContextStore. |
void |
newContextEvent(java.lang.String originID,
java.lang.String type,
java.lang.Object data,
java.util.Date date,
boolean persist)
Insert a new context with the given parameters in the ContextStore. |
void |
registerContextType(java.lang.String ctxType)
Register context type in the ContextStore. |
void |
registerHandler(IContextHandler ctxHandler)
Register a context handler for notification of new contexts (all types). |
void |
registerHandler(IContextHandler ctxHandler,
java.lang.String[] ctxTypes)
Register a context handler for notification of new contexts with any type in the given list. |
void |
registerHandlerForContextType(IContextHandler ctxHandler,
java.lang.String ctxType)
Register the context handler for the given context type. |
Methods inherited from interface com.sag.osami.api.context.IContextQuery |
---|
query, queryLazy |
Field Detail |
---|
static final java.lang.String CONTEXT_STORE_ID
static final java.lang.String TYPE_REGISTERED
static final java.lang.String TYPE_DEREGISTERED
static final java.lang.String TYPE_ALL
Method Detail |
---|
void newContextEvent(java.lang.String originID, java.lang.String type, java.lang.Object data, java.util.Date date)
originID
- the origin id of the new context eventtype
- the type of the new context eventdata
- the data of the new context eventdate
- the date of the new context eventvoid newContextEvent(java.lang.String originID, java.lang.String type, java.lang.Object data, java.util.Date date, boolean persist)
originID
- the origin id of the new context eventtype
- the type of the new context eventdata
- the data of the new context eventdate
- the date of the new context eventpersist
- indicates whether context event should be persisted or notvoid newContextEvent(ContextEvent ctxEvent)
Note that the actual context event object won't be stored as-is in the ContextStore but instead is re-packaged in a new ContextEvent data object. Also, the properties ID and contextStoreOriginID stored in the given object will be ignored and determined internally. This method exists for convenience only.
ctxEvent
- the context event to be insertedvoid newContextEvent(ContextEvent ctxEvent, boolean persist)
Note that the actual context event object won't be stored as-is in the ContextStore but instead is re-packaged in a new ContextEvent data object. Also, the properties ID and contextStoreOriginID stored in the given object will be ignored and determined internally. This method exists for convenience only.
ctxEvent
- the context event to be insertedpersist
- indicates whether context event should be persisted or notvoid registerHandler(IContextHandler ctxHandler)
ctxHandler
- the context handlervoid registerHandler(IContextHandler ctxHandler, java.lang.String[] ctxTypes)
ctxHandler
- the context handlerctxTypes
- the context type listvoid deregisterHandler(IContextHandler ctxHandler)
ctxHandler
- the context handlervoid activateEventsForHandler(IContextHandler ctxHandler)
Has no effect when notification was already active.
ctxHandler
- the context handlervoid deactivateEventsForHandler(IContextHandler ctxHandler)
This is useful if the handler does some time-consuming operations while processing, or needs to be temporarily disabled. Despite the deactivation, the normal operation can be resumed without having to register again.
Has no effect when notification was already inactive.
ctxHandler
- the context handlervoid registerContextType(java.lang.String ctxType)
This routine is useful, if a context source is not available in the beginning, but there are already handlers registering for future context events of the given type.
ctxType
- the context typevoid deregisterContextType(java.lang.String ctxType)
ctxType
- the context typeboolean isRegisteredContextType(java.lang.String myType)
ctxType
- the context type to be checked
java.lang.String[] getRegisteredContextTypes()
java.lang.String[] getHandlersRegisteredContextTypes(IContextHandler handler)
void registerHandlerForContextType(IContextHandler ctxHandler, java.lang.String ctxType)
ctxHandler
- the context handlerctxType
- the context typevoid deregisterHandlerForContextType(IContextHandler ctxHandler, java.lang.String ctxType)
ctxHandler
- the context handlerctxType
- the context typejava.lang.String getStoreID()
IContextStorage getStorage()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |