de.novanic.eventservice.service
Class EventServiceImpl

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
              extended by com.google.gwt.user.server.rpc.RemoteServiceServlet
                  extended by de.novanic.eventservice.service.EventServiceImpl
All Implemented Interfaces:
com.google.gwt.user.client.rpc.RemoteService, com.google.gwt.user.server.rpc.SerializationPolicyProvider, EventService, java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class EventServiceImpl
extends com.google.gwt.user.server.rpc.RemoteServiceServlet
implements EventService

EventService is the server side interface to register listen requests for domains and to add events.

Author:
sstrohschein
Date: 05.06.2008
Time: 19:12:17
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
perThreadRequest, perThreadResponse
 
Constructor Summary
EventServiceImpl()
           
 
Method Summary
 void addEvent(Domain aDomain, Event anEvent)
          Adds an event for all users in the domain.
 void addEventUserSpecific(Event anEvent)
          Adds an event only for the current user.
 void deregisterEventFilter(Domain aDomain)
          Deregisters the EventFilter of the domain.
 java.util.Set<Domain> getActiveListenDomains()
          Returns the domain names, where the user is listening to
protected  java.lang.String getClientId(boolean isInitSession)
          Returns the client id.
 EventFilter getEventFilter(Domain aDomain)
          Returns the EventFilter for the user domain combination.
 void init(javax.servlet.ServletConfig aConfig)
          The init method should be called automatically before the servlet can be used and should called only one time.
 void initEventService()
          Initializes the EventService.
 boolean isUserRegistered(Domain aDomain)
          Checks if the user is registered for event listening.
 java.util.List<DomainEvent> listen()
          The listen method returns all events for the user (events for all domains where the user is registered and user specific events).
 void register(Domain aDomain)
          Register listen for a domain.
 void register(Domain aDomain, EventFilter anEventFilter)
          Register listen for a domain.
 void register(java.util.Set<Domain> aDomains)
          Register listen for a domain.
 void register(java.util.Set<Domain> aDomains, EventFilter anEventFilter)
          Register listen for domains.
 void registerEventFilter(Domain aDomain, EventFilter anEventFilter)
          Registers an EventFilter for the domain.
 void registerUnlistenEvent(UnlistenEventListener.Scope anUnlistenScope, UnlistenEvent anUnlistenEvent)
          Registers an UnlistenEvent which is triggered on a timeout or when a user/client leaves a Domain.
 void unlisten()
          Unlisten for events (for the current user) in all domains (deregisters the user from all domains).
 void unlisten(Domain aDomain)
          Unlisten for events (for the current user) in the domain and deregisters the user from the domain.
 void unlisten(java.util.Set<Domain> aDomains)
          Unlisten for events (for the current user) in the domains and deregisters the user from the domains.
 
Methods inherited from class com.google.gwt.user.server.rpc.RemoteServiceServlet
doGetSerializationPolicy, getSerializationPolicy, onAfterResponseSerialized, onBeforeRequestDeserialized, processCall, processPost, shouldCompressResponse
 
Methods inherited from class com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
doPost, doUnexpectedFailure, getPermutationStrongName, getThreadLocalRequest, getThreadLocalResponse, onAfterRequestDeserialized, readContent
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventServiceImpl

public EventServiceImpl()
Method Detail

init

public void init(javax.servlet.ServletConfig aConfig)
          throws javax.servlet.ServletException
The init method should be called automatically before the servlet can be used and should called only one time. That method initialized the EventRegistry.

Specified by:
init in interface javax.servlet.Servlet
Overrides:
init in class javax.servlet.GenericServlet
Parameters:
aConfig - servlet configuration
Throws:
javax.servlet.ServletException

initEventService

public void initEventService()
Initializes the EventService.

Specified by:
initEventService in interface EventService

register

public void register(Domain aDomain)
Register listen for a domain.

Specified by:
register in interface EventService
Parameters:
aDomain - domain to listen to

register

public void register(Domain aDomain,
                     EventFilter anEventFilter)
Register listen for a domain.

Specified by:
register in interface EventService
Parameters:
aDomain - domain to listen to
anEventFilter - EventFilter to filter events

register

public void register(java.util.Set<Domain> aDomains)
Register listen for a domain.

Specified by:
register in interface EventService
Parameters:
aDomains - domains to listen to

register

public void register(java.util.Set<Domain> aDomains,
                     EventFilter anEventFilter)
Register listen for domains.

Specified by:
register in interface EventService
Parameters:
aDomains - domains to listen to
anEventFilter - EventFilter to filter events (applied to all domains)

registerUnlistenEvent

public void registerUnlistenEvent(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.

Specified by:
registerUnlistenEvent in interface EventService
Parameters:
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.

registerEventFilter

public void registerEventFilter(Domain aDomain,
                                EventFilter anEventFilter)
Registers an EventFilter for the domain.

Specified by:
registerEventFilter in interface EventService
Parameters:
aDomain - domain to register the EventFilter to
anEventFilter - EventFilter to filter events for the domain

deregisterEventFilter

public void deregisterEventFilter(Domain aDomain)
Deregisters the EventFilter of the domain.

Specified by:
deregisterEventFilter in interface EventService
Parameters:
aDomain - domain to drop the EventFilters from

getEventFilter

public EventFilter getEventFilter(Domain aDomain)
Returns the EventFilter for the user domain combination.

Specified by:
getEventFilter in interface EventService
Parameters:
aDomain - domain
Returns:
EventFilter for the domain

listen

public java.util.List<DomainEvent> listen()
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 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 waiting time can be configured with EventServiceConfiguration.

Specified by:
listen in interface EventService
Returns:
list of events

unlisten

public void unlisten()
Unlisten for events (for the current user) in all domains (deregisters the user from all domains).

Specified by:
unlisten in interface EventService

unlisten

public void unlisten(Domain aDomain)
Unlisten for events (for the current user) in the domain and deregisters the user from the domain.

Specified by:
unlisten in interface EventService
Parameters:
aDomain - domain to unlisten

unlisten

public void unlisten(java.util.Set<Domain> aDomains)
Unlisten for events (for the current user) in the domains and deregisters the user from the domains.

Specified by:
unlisten in interface EventService
Parameters:
aDomains - set of domains to unlisten

isUserRegistered

public boolean isUserRegistered(Domain aDomain)
Checks if the user is registered for event listening.

Specified by:
isUserRegistered in interface EventService
Parameters:
aDomain - domain to check
Returns:
true when the user is registered for listening, otherwise false

addEvent

public void addEvent(Domain aDomain,
                     Event anEvent)
Adds an event for all users in the domain.

Specified by:
addEvent in interface EventService
Parameters:
aDomain - domain to add the event
anEvent - event to add

addEventUserSpecific

public void addEventUserSpecific(Event anEvent)
Adds an event only for the current user.

Specified by:
addEventUserSpecific in interface EventService
Parameters:
anEvent - event to add to the user

getActiveListenDomains

public java.util.Set<Domain> getActiveListenDomains()
Returns the domain names, where the user is listening to

Specified by:
getActiveListenDomains in interface EventService
Returns:
collection of domain names

getClientId

protected java.lang.String getClientId(boolean isInitSession)
Returns the client id.

Parameters:
isInitSession - initializes the session (if not already initialized).
Returns:
client id