|
GigaSpaces - Open Spaces | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openspaces.events.AbstractSpaceListeningContainer
org.openspaces.events.AbstractEventListenerContainer
org.openspaces.events.AbstractTemplateEventListenerContainer
org.openspaces.events.notify.AbstractNotifyEventListenerContainer
public abstract class AbstractNotifyEventListenerContainer
Base class for notifications based containers allowing to register listener that will be
triggered by the space if notifications occur. Provides all the necessary parameters that are
used by EventSessionConfig
and support methods for creating
EventSessionFactory
and
DataEventSession
objects.
The container allows to set the template object used for the notify registration. Note, this can
be a Pojo based template, or one of GigaSpace's query classes such as
SQLQuery
.
Masking of which operations will cause notifications can be set using
setNotifyWrite(Boolean)
, setNotifyUpdate(Boolean)
,
setNotifyTake(Boolean)
and setNotifyLeaseExpire(Boolean)
. Note, if no flag is
set, notifications will be send for write operations.
Batching of notifications can be turned on by setting both setBatchSize(Integer)
and
setBatchTime(Integer)
.
Fifo ordering of raised notification can be controlled by setting setFifo(boolean)
flag
to true
. Note, for a full fifo based ordering the relevant entries in the space
should be configured to be fifo as well.
Listener registration across replicated spaces can be set using
setReplicateNotifyTemplate(boolean)
and setTriggerNotifyTemplate(boolean)
.
The communication protocol between the space "server" and the even listener client can be
configured using either setComType(int)
or setComTypeName(String)
. The
available options are COM_TYPE_UNICAST
, COM_TYPE_MULTIPLEX
and
COM_TYPE_MULTICAST
. If using setComType(int)
the integer constant value should
be used. If using setComTypeName(String)
the actual name of the com type can be used (unicast
,
multiplex
or multicast
). The default communication type is
COM_TYPE_UNICAST
.
The AbstractTemplateEventListenerContainer.setTemplate(Object)
parameter is required in order to perform matching on which
events to receive. If the AbstractEventListenerContainer.setEventListener(org.openspaces.events.SpaceDataEventListener)
implements EventTemplateProvider
and the template is directly set,
the event listener will be used to get the template. This feature helps when event listeners
directly can only work with a certain template and removes the requirement of configuring the
template as well.
Provides invokeListenerWithTransaction(Object,Object,boolean,boolean)
allowing to execute the
listener within a transactional context. Also allows for the performTakeOnNotify to control if a
take operation will be performed against the space with the given event data in order to remove it
from the space.
EventSessionConfig
,
EventSessionFactory
,
DataEventSession
Field Summary | |
---|---|
static int |
COM_TYPE_MULTICAST
Controls how notification are propagated from the space to the listener. |
static int |
COM_TYPE_MULTIPLEX
Controls how notification are propagated from the space to the listener. |
static String |
COM_TYPE_PREFIX
|
static int |
COM_TYPE_UNICAST
Controls how notification are propagated from the space to the listener. |
Fields inherited from class org.openspaces.events.AbstractSpaceListeningContainer |
---|
logger |
Constructor Summary | |
---|---|
AbstractNotifyEventListenerContainer()
|
Method Summary | |
---|---|
protected com.gigaspaces.events.DataEventSession |
createDataEventSession(com.gigaspaces.events.EventSessionFactory factory)
Creates a new DataEventSession based on the provided factory. |
protected com.gigaspaces.events.EventSessionConfig |
createEventSessionConfig()
Creates a new EventSessionConfig based on the different
parameters this container accepts. |
protected com.gigaspaces.events.EventSessionFactory |
createEventSessionFactory()
Creates a new event session factory based on the space provided. |
protected Boolean |
getNotifyLeaseExpire()
|
protected Boolean |
getNotifyTake()
|
protected Boolean |
getNotifyUpdate()
|
protected Boolean |
getNotifyWrite()
|
protected PlatformTransactionManager |
getTransactionManager()
Return the Spring PlatformTransactionManager to use for transactional wrapping of message reception plus listener execution. |
void |
initialize()
Initialize this container. |
protected void |
invokeListenerWithTransaction(Object eventData,
Object source,
boolean performTakeOnNotify,
boolean ignoreEventOnNullTake)
Executes the given listener. |
protected void |
registerListener(com.gigaspaces.events.DataEventSession dataEventSession,
net.jini.core.event.RemoteEventListener listener)
Registers a listener using the provided DataEventSession and
based on different parameters set on this container. |
void |
setAutoRenew(boolean autoRenew)
If setListenerLease(long) is set, automatically performs lease renewal. |
void |
setBatchSize(Integer batchSize)
If set, turns batching event notifications where the server space accumalates notifications to be sent and then send them in batch. |
void |
setBatchTime(Integer batchTime)
If set, turns batching event notifications where the server space accumalates notifications to be sent and then send them in batch. |
void |
setComType(int comType)
See setComTypeName(String) . |
void |
setComTypeName(String comTypeName)
Sets the communication protocol for the notification registration. |
void |
setDisableTransactionValidation(boolean disableTransactionValidation)
Should transaction validation be enabled or not (verify and fail if transaction manager is provided and the GigaSpace is not transactional). |
void |
setFifo(boolean fifo)
Determines if events arrives in the same order they were triggered by the space "server". |
void |
setLeaseListener(net.jini.lease.LeaseListener leaseListener)
If setAutoRenew(boolean) is set to true sets the lease listener for
it. |
void |
setListenerLease(long listenerLease)
Controls the lease associated with the registered listener. |
void |
setNotifyAll(Boolean notifyAll)
Turns on notifications for all operations. |
void |
setNotifyFilter(com.j_spaces.core.client.INotifyDelegatorFilter notifyFilter)
Allows to register a filter on the server side that can filter out or modify notifications that will be sent by the space "server". |
void |
setNotifyLeaseExpire(Boolean notifyLeaseExpire)
Turns on notification for least expiration. |
void |
setNotifyTake(Boolean notifyTake)
Turns on notifications for take operations. |
void |
setNotifyUpdate(Boolean notifyUpdate)
Turns on notifications for update operations. |
void |
setNotifyWrite(Boolean notifyWrite)
Turns on notifications for write operations. |
void |
setReplicateNotifyTemplate(boolean replicateNotifyTemplate)
If using a replicated space controls if the listener will be replicated between all the replicated cluster members. |
void |
setTransactionIsolationLevel(int transactionIsolationLevel)
Specify the transaction isolation to use for transactional wrapping. |
void |
setTransactionIsolationLevelName(String transactionIsolationLevelName)
Specify the transaction isolation to use for transactional wrapping. |
void |
setTransactionManager(PlatformTransactionManager transactionManager)
Specify the Spring PlatformTransactionManager to use
for transactional wrapping of listener execution. |
void |
setTransactionName(String transactionName)
Specify the transaction name to use for transactional wrapping. |
void |
setTransactionTimeout(int transactionTimeout)
Specify the transaction timeout to use for transactional wrapping, in seconds. |
void |
setTriggerNotifyTemplate(boolean triggerNotifyTemplate)
If using a replicated space controls if the listener that are replicated to cluster members will raise notifications. |
protected void |
validateConfiguration()
Validate the configuration of this container. |
Methods inherited from class org.openspaces.events.AbstractTemplateEventListenerContainer |
---|
afterPropertiesSet, getReceiveTemplate, getTemplate, setPerformSnapshot, setTemplate |
Methods inherited from class org.openspaces.events.AbstractEventListenerContainer |
---|
doStart, executeListener, getActualEventListener, getApplicationContext, getEventListener, getEventListenerClass, handleListenerException, invokeExceptionListener, invokeListener, setApplicationContext, setEventListener, setEventListenerRef |
Methods inherited from class org.openspaces.events.AbstractSpaceListeningContainer |
---|
destroy, doAfterStart, doBeforeStop, doInitialize, doRescheduleTask, doShutdown, doStop, getBeanName, getGigaSpace, isActive, isRunning, message, onApplicationEvent, rescheduleTaskIfNecessary, setActiveWhenPrimary, setAutoStart, setBeanName, setGigaSpace, setRegisterSpaceModeListener, shutdown, start, stop, waitWhileNotRunning |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String COM_TYPE_PREFIX
public static final int COM_TYPE_UNICAST
public static final int COM_TYPE_MULTIPLEX
COM_TYPE_UNICAST
)
in terms of communication protocol but uses a single client side multiplexer which handles
all the dispatching to the different notification listeners.
public static final int COM_TYPE_MULTICAST
Constructor Detail |
---|
public AbstractNotifyEventListenerContainer()
Method Detail |
---|
public void setComType(int comType)
setComTypeName(String)
.
COM_TYPE_MULTICAST
,
COM_TYPE_MULTIPLEX
,
COM_TYPE_UNICAST
public void setComTypeName(String comTypeName)
COM_TYPE_MULTICAST
,
COM_TYPE_MULTIPLEX
,
COM_TYPE_UNICAST
public void setFifo(boolean fifo)
public void setBatchSize(Integer batchSize)
setBatchTime(Integer)
must be set as well.
public void setBatchTime(Integer batchTime)
setBatchSize(Integer)
must be set as well.
public void setAutoRenew(boolean autoRenew)
setListenerLease(long)
is set, automatically performs lease renewal. Defaults to
false
.
setListenerLease(long)
public void setLeaseListener(net.jini.lease.LeaseListener leaseListener)
setAutoRenew(boolean)
is set to true
sets the lease listener for
it.
public void setListenerLease(long listenerLease)
Lease.FOREVER
.
setAutoRenew(boolean)
public void setNotifyFilter(com.j_spaces.core.client.INotifyDelegatorFilter notifyFilter)
public void setNotifyWrite(Boolean notifyWrite)
false
.
public void setNotifyUpdate(Boolean notifyUpdate)
false
.
public void setNotifyTake(Boolean notifyTake)
false
.
public void setNotifyAll(Boolean notifyAll)
false
.
public void setNotifyLeaseExpire(Boolean notifyLeaseExpire)
false
.
public void setTriggerNotifyTemplate(boolean triggerNotifyTemplate)
setReplicateNotifyTemplate(boolean)
public void setReplicateNotifyTemplate(boolean replicateNotifyTemplate)
If working directly with a cluster memeber, the default value will be false
.
Otherwise, the default value will be based on the cluster schema (which is true for clusters
with backups).
setTriggerNotifyTemplate(boolean)
public void setTransactionManager(PlatformTransactionManager transactionManager)
PlatformTransactionManager
to use
for transactional wrapping of listener execution.
Default is none, not performing any transactional wrapping.
protected final PlatformTransactionManager getTransactionManager()
public void setTransactionName(String transactionName)
TransactionDefinition.getName()
public void setTransactionTimeout(int transactionTimeout)
TransactionDefinition.getTimeout()
public void setTransactionIsolationLevel(int transactionIsolationLevel)
DefaultTransactionDefinition.setIsolationLevel(int)
public void setTransactionIsolationLevelName(String transactionIsolationLevelName)
DefaultTransactionDefinition.setIsolationLevelName(String)
public void setDisableTransactionValidation(boolean disableTransactionValidation)
false
.
protected Boolean getNotifyWrite()
protected Boolean getNotifyUpdate()
protected Boolean getNotifyTake()
protected Boolean getNotifyLeaseExpire()
public void initialize() throws DataAccessException
AbstractSpaceListeningContainer
true
will call AbstractSpaceListeningContainer.doStart()
(if it is set to true
,
lifecycle of the container will be controlled by the current space mode).
AbstractSpaceListeningContainer.doInitialize()
will be called for additional initialization after the possible
AbstractSpaceListeningContainer.doStart()
call.
initialize
in class AbstractTemplateEventListenerContainer
DataAccessException
AbstractSpaceListeningContainer.onApplicationEvent(org.springframework.context.ApplicationEvent)
protected void validateConfiguration()
AbstractSpaceListeningContainer
validateConfiguration
in class AbstractSpaceListeningContainer
protected com.gigaspaces.events.EventSessionFactory createEventSessionFactory()
protected com.gigaspaces.events.EventSessionConfig createEventSessionConfig() throws IllegalArgumentException
EventSessionConfig
based on the different
parameters this container accepts.
IllegalArgumentException
protected com.gigaspaces.events.DataEventSession createDataEventSession(com.gigaspaces.events.EventSessionFactory factory) throws DataAccessException
DataEventSession
based on the provided factory.
Uses createEventSessionConfig()
in order to create the session configuration.
DataAccessException
protected void registerListener(com.gigaspaces.events.DataEventSession dataEventSession, net.jini.core.event.RemoteEventListener listener) throws NotifyListenerRegistrationException
DataEventSession
and
based on different parameters set on this container.
NotifyListenerRegistrationException
protected void invokeListenerWithTransaction(Object eventData, Object source, boolean performTakeOnNotify, boolean ignoreEventOnNullTake) throws DataAccessException
setTransactionManager(PlatformTransactionManager)
is provided will perform the listener execution within a transaction, if not, the listener
execution is performed without a transaction.
If the performTakeOnNotify flag is set to true
will also perform take
operation with the given event data (i.e. remove it from the space).
eventData
- The event data objectsource
- The remote notify eventperformTakeOnNotify
- A flag indicating whether to perform take operation with the given event data
DataAccessException
|
GigaSpaces - Open Spaces | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |