public class EventServiceImpl extends RemoteServiceServlet implements EventService
EventService
is the server side interface to register listen
requests for domains and to add events.perThreadRequest, perThreadResponse
Constructor and Description |
---|
EventServiceImpl() |
Modifier and Type | Method and Description |
---|---|
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.
|
protected void |
checkPermutationStrongName()
This method is overridden because applications with various GWT versions got a
SecurityException |
void |
deregisterEventFilter(Domain aDomain)
Deregisters the
EventFilter of the domain. |
void |
destroy() |
protected void |
doGet(javax.servlet.http.HttpServletRequest aRequest,
javax.servlet.http.HttpServletResponse aResponse)
The GET method is used to stream data to the clients.
|
protected String |
generateClientId()
Generates and returns a new client id.
|
Set<Domain> |
getActiveListenDomains()
Returns the domain names, where the user is listening to
|
protected String |
getClientId()
Returns the client id.
|
protected String |
getClientId(javax.servlet.http.HttpServletRequest aRequest)
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.
|
EventServiceConfigurationTransferable |
initEventService()
Initializes the
EventService . |
boolean |
isUserRegistered(Domain aDomain)
Checks if the user is registered for event listening.
|
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(Set<Domain> aDomains)
Register listen for a domain.
|
void |
register(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(Set<Domain> aDomains)
Unlisten for events (for the current user) in the domains and deregisters the user from the domains.
|
doGetSerializationPolicy, getSerializationPolicy, onAfterResponseSerialized, onBeforeRequestDeserialized, processCall, processPost, shouldCompressResponse
doPost, doUnexpectedFailure, getPermutationStrongName, getThreadLocalRequest, getThreadLocalResponse, onAfterRequestDeserialized, readContent
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
public EventServiceImpl()
public void init(javax.servlet.ServletConfig aConfig) throws javax.servlet.ServletException
EventRegistry
.init
in interface javax.servlet.Servlet
init
in class javax.servlet.GenericServlet
aConfig
- servlet configurationjavax.servlet.ServletException
public void destroy()
destroy
in interface javax.servlet.Servlet
destroy
in class javax.servlet.GenericServlet
protected void doGet(javax.servlet.http.HttpServletRequest aRequest, javax.servlet.http.HttpServletResponse aResponse) throws javax.servlet.ServletException, IOException
doGet
in class javax.servlet.http.HttpServlet
aRequest
- requestaResponse
- response (with the stream)javax.servlet.ServletException
IOException
public EventServiceConfigurationTransferable initEventService()
EventService
.initEventService
in interface EventService
public void register(Domain aDomain)
register
in interface EventService
aDomain
- domain to listen topublic void register(Domain aDomain, EventFilter anEventFilter)
register
in interface EventService
aDomain
- domain to listen toanEventFilter
- EventFilter to filter eventspublic void register(Set<Domain> aDomains)
register
in interface EventService
aDomains
- domains to listen topublic void register(Set<Domain> aDomains, EventFilter anEventFilter)
register
in interface EventService
aDomains
- domains to listen toanEventFilter
- EventFilter to filter events (applied to all domains)public void registerUnlistenEvent(UnlistenEventListener.Scope anUnlistenScope, UnlistenEvent anUnlistenEvent)
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.registerUnlistenEvent
in interface EventService
anUnlistenScope
- scope of the unlisten events to receiveanUnlistenEvent
- UnlistenEvent
which should
be transferred to other users/clients when a timeout occurs or a domain is leaved.public void registerEventFilter(Domain aDomain, EventFilter anEventFilter)
EventFilter
for the domain.registerEventFilter
in interface EventService
aDomain
- domain to register the EventFilter toanEventFilter
- EventFilter to filter events for the domainpublic void deregisterEventFilter(Domain aDomain)
EventFilter
of the domain.deregisterEventFilter
in interface EventService
aDomain
- domain to drop the EventFilters frompublic EventFilter getEventFilter(Domain aDomain)
getEventFilter
in interface EventService
aDomain
- domainpublic List<DomainEvent> listen()
EventServiceConfiguration
.
The default listening method is long-polling, but that can be changed with changing the connection strategy.
The connection strategy can be configured with ConfigParameter.CONNECTION_STRATEGY_CLIENT_CONNECTOR
for the client side part / connector and ConfigParameter.CONNECTION_STRATEGY_SERVER_CONNECTOR
.listen
in interface EventService
public void unlisten()
unlisten
in interface EventService
public void unlisten(Domain aDomain)
unlisten
in interface EventService
aDomain
- domain to unlistenpublic void unlisten(Set<Domain> aDomains)
unlisten
in interface EventService
aDomains
- set of domains to unlistenpublic boolean isUserRegistered(Domain aDomain)
isUserRegistered
in interface EventService
aDomain
- domain to checkpublic void addEvent(Domain aDomain, Event anEvent)
addEvent
in interface EventService
aDomain
- domain to add the eventanEvent
- event to addpublic void addEventUserSpecific(Event anEvent)
addEventUserSpecific
in interface EventService
anEvent
- event to add to the userpublic Set<Domain> getActiveListenDomains()
getActiveListenDomains
in interface EventService
protected String getClientId()
protected String getClientId(javax.servlet.http.HttpServletRequest aRequest)
aRequest
- requestprotected String generateClientId()
protected void checkPermutationStrongName() throws SecurityException
SecurityException
checkPermutationStrongName
in class RemoteServiceServlet
SecurityException
Copyright © 2012. All Rights Reserved.