de.novanic.eventservice.service.registry
Interface EventRegistry

All Known Implementing Classes:
DefaultEventRegistry

public interface EventRegistry

The EventRegistry handles the users/clients and the events per domain. Users can be registered for a domain/context to receive events for the corresponding domain. User specific events can be handled domain-less, when the user is registered. The EventRegistry is used by EventServiceImpl.
The client id is required, because the connection to every client must be kept open.

Author:
sstrohschein
Date: 09.08.2008
Time: 22:28:24
See Also:
EventServiceImpl

Method Summary
 void addEvent(Domain aDomain, Event anEvent)
          Adds an event to a domain.
 void addEventUserSpecific(java.lang.String aUserId, Event anEvent)
          Adds an event directly to a user.
 EventServiceConfiguration getConfiguration()
          Returns the initialized EventServiceConfiguration
 EventFilter getEventFilter(Domain aDomain, java.lang.String aUserId)
          Returns the EventFilter for the user domain combination.
 java.util.Set<Domain> getListenDomains()
          Returns all registered/activated domains.
 java.util.Set<Domain> getListenDomains(java.lang.String aUserId)
          Returns all domains where the user is registered to.
 java.util.Set<java.lang.String> getRegisteredUserIds()
          Returns all registered users/clients.
 java.util.Set<java.lang.String> getRegisteredUserIds(Domain aDomain)
          Returns all registered users/client of a specific Domain.
 boolean isUserRegistered(Domain aDomain, java.lang.String aUserId)
          Checks if the user is registered for the corresponding domain.
 boolean isUserRegistered(java.lang.String aUserId)
          Checks if the user is registered for any domain.
 java.util.List<DomainEvent> listen(java.lang.String aUserId)
          The listen method returns all events for the user (events for all domains where the user is registered and user specific events).
 void registerUnlistenEvent(java.lang.String aUserId, UnlistenEventListener.Scope anUnlistenScope, UnlistenEvent anUnlistenEvent)
          Registers an UnlistenEvent which is triggered on a timeout or when a user/client leaves a Domain.
 void registerUser(Domain aDomain, java.lang.String aUserId, EventFilter anEventFilter)
          Registers a user for listening for the corresponding domain.
 void removeEventFilter(Domain aDomain, java.lang.String aUserId)
          EventFilters can be removed for a user domain combination with that method.
 void setEventFilter(Domain aDomain, java.lang.String aUserId, EventFilter anEventFilter)
          The EventFilter for a user domain combination can be set or changed with that method.
 void unlisten(Domain aDomain, java.lang.String aUserId)
          This method causes a stop of listening for a domain (listen(String)).
 void unlisten(java.lang.String aUserId)
          This method causes a stop of listening for all domains (listen(String)).
 

Method Detail

isUserRegistered

boolean isUserRegistered(java.lang.String aUserId)
Checks if the user is registered for any domain.

Parameters:
aUserId - the user to check
Returns:
true if registered, false if not registered

isUserRegistered

boolean isUserRegistered(Domain aDomain,
                         java.lang.String aUserId)
Checks if the user is registered for the corresponding domain.

Parameters:
aDomain - the domain to check
aUserId - the user to check
Returns:
true if registered, false if not registered

registerUser

void registerUser(Domain aDomain,
                  java.lang.String aUserId,
                  EventFilter anEventFilter)
Registers a user for listening for the corresponding domain. From now all events for the domain are recognized and will be returned when listen (listen(String)) is called. The EventFilter is optional and can be NULL.

Parameters:
aDomain - the domain to listen
aUserId - the user to register
anEventFilter - EventFilter to filter the domain events (optional, can be NULL)

setEventFilter

void setEventFilter(Domain aDomain,
                    java.lang.String aUserId,
                    EventFilter anEventFilter)
The EventFilter for a user domain combination can be set or changed with that method.

Parameters:
aDomain - domain
aUserId - user
anEventFilter - new EventFilter

getEventFilter

EventFilter getEventFilter(Domain aDomain,
                           java.lang.String aUserId)
Returns the EventFilter for the user domain combination.

Parameters:
aDomain - domain
aUserId - user
Returns:
EventFilter for the user domain combination

removeEventFilter

void removeEventFilter(Domain aDomain,
                       java.lang.String aUserId)
EventFilters can be removed for a user domain combination with that method.

Parameters:
aUserId - user
aDomain - domain

listen

java.util.List<DomainEvent> listen(java.lang.String aUserId)
The listen method returns all events for the user (events for all domains where the user is registered and user specific events). If no events are available, the method waits a defined time before the events are returned. The listen method is designed for the EventService functionality. The client side calls the method with a defined interval to receive all events. If the client don't call the method in the interval, the user will be removed from the EventRegistry. The timeout time and the min and max waiting time can be configured by EventServiceConfiguration.

Parameters:
aUserId - user
Returns:
list of events

unlisten

void unlisten(Domain aDomain,
              java.lang.String aUserId)
This method causes a stop of listening for a domain (listen(String)).

Parameters:
aDomain - domain to stop listening
aUserId - user

unlisten

void unlisten(java.lang.String aUserId)
This method causes a stop of listening for all domains (listen(String)).

Parameters:
aUserId - user

getListenDomains

java.util.Set<Domain> getListenDomains(java.lang.String aUserId)
Returns all domains where the user is registered to.

Parameters:
aUserId - user
Returns:
domains where the user is registered to

getListenDomains

java.util.Set<Domain> getListenDomains()
Returns all registered/activated domains.

Returns:
all registered/activated domains

getRegisteredUserIds

java.util.Set<java.lang.String> getRegisteredUserIds()
Returns all registered users/clients. To get only the registered users/client of a specific Domain, the method getRegisteredUserIds(de.novanic.eventservice.client.event.domain.Domain) can be used instead.

Returns:
registered users/clients

getRegisteredUserIds

java.util.Set<java.lang.String> getRegisteredUserIds(Domain aDomain)
Returns all registered users/client of a specific Domain. To get all the registered users/client (of all domains), the method getRegisteredUserIds() can be used instead.

Parameters:
aDomain - domain
Returns:
registered users/client of the specific domain

addEvent

void addEvent(Domain aDomain,
              Event anEvent)
Adds an event to a domain.

Parameters:
aDomain - domain for the event
anEvent - event to add

addEventUserSpecific

void addEventUserSpecific(java.lang.String aUserId,
                          Event anEvent)
Adds an event directly to a user. The user must be registered to any domain.

Parameters:
aUserId - user
anEvent - event

registerUnlistenEvent

void registerUnlistenEvent(java.lang.String aUserId,
                           UnlistenEventListener.Scope anUnlistenScope,
                           UnlistenEvent anUnlistenEvent)
Registers an UnlistenEvent which is triggered on a timeout or when a user/client leaves a Domain. An UnlistenEvent is hold at the server side and can contain custom data. Other users/clients can use the custom data when the event is for example triggered by a timeout.

Parameters:
aUserId - user to register the UnlistenEvent to
anUnlistenScope - scope of the unlisten events to receive
anUnlistenEvent - UnlistenEvent which should be transferred to other users/clients when a timeout occurs or a domain is leaved.

getConfiguration

EventServiceConfiguration getConfiguration()
Returns the initialized EventServiceConfiguration

Returns:
configuration EventServiceConfiguration