|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openspaces.events.AbstractSpaceListeningContainer
public abstract class AbstractSpaceListeningContainer
Common base class for all containers which need to implement listening based on Space events.
Provide lifecycle support for containers using doStart()
and doStop()
. By
default, the container lifecycle will be bound to the space mode, starting when the space mode is
PRIMARY
and stopping otherwise. This behavior is controlled by
setActiveWhenPrimary(boolean)
. Note that most operations can not be performed directly
against a backup space cluster member (when working with the
GigaSpaceFactoryBean.setClustered(boolean)
flag set to
false
) so setting this flag to false
(which means this container
will operate when the space is in BACKUP
mode as well) needs to be done with care.
This base class does not assume any specific listener programming model or listener invoker mechanism. It just provides the general runtime lifecycle management needed for any kind of Space event listening mechanism.
For a concrete listener programming model, check out the
AbstractEventListenerContainer
subclass. For a concrete listener
invoker mechanism, check out the
SimplePollingEventListenerContainer
class.
Field Summary | |
---|---|
protected String |
beanName
|
protected Log |
logger
|
Constructor Summary | |
---|---|
AbstractSpaceListeningContainer()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Delegates to validateConfiguration() and initialize() . |
void |
destroy()
Calls shutdown() when the BeanFactory destroys the container instance. |
protected void |
doAfterStart()
|
protected void |
doBeforeStop()
|
protected abstract void |
doInitialize()
A callback to perform custom initialization steps. |
protected void |
doRescheduleTask(Object task)
Reschedule the given task object immediately. |
protected abstract void |
doShutdown()
Perform any custom shutdown operations. |
protected void |
doStart()
Notify all invoker tasks. |
protected void |
doStop()
Notify all invoker tasks to stop |
protected String |
getBeanName()
Return the bean name that this listener container has been assigned in its containing bean factory, if any. |
protected GigaSpace |
getGigaSpace()
Returns the GigaSpace instance to be used for Space operations. |
protected String |
getStatus()
|
void |
initialize()
Initialize this container. |
boolean |
isActive()
Return whether this container is currently active, that is, whether it has been set up but not shut down yet. |
boolean |
isRunning()
Return whether this container is currently running, that is, whether it has been started and not stopped yet. |
protected String |
message(String message)
|
void |
onApplicationEvent(ApplicationEvent applicationEvent)
If the setActiveWhenPrimary(boolean) is set to true (the default),
the container lifecycle will be controlled by the space mode. |
protected boolean |
rescheduleTaskIfNecessary(Object task)
Take the given task object and reschedule it, either immediately if this container is currently running, or later once this container has been restarted. |
void |
setActiveWhenPrimary(boolean activeWhenPrimary)
Set whether this container will start only when it is primary (space mode). |
void |
setAutoStart(boolean initOnStartup)
Set whether this container will start once instantiated. |
void |
setBeanName(String beanName)
|
void |
setGigaSpace(GigaSpace gigaSpace)
Sets the GigaSpace instance to be used for space event listening operations. |
void |
setRegisterSpaceModeListener(boolean registerSpaceModeListener)
|
void |
shutdown()
Stop container, call doShutdown() , and close this container. |
void |
start()
Start this container. |
void |
stop()
Stop this container. |
protected void |
validateConfiguration()
Validate the configuration of this container. |
protected void |
waitWhileNotRunning()
Wait while this container is not running. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.openspaces.pu.service.ServiceDetailsProvider |
---|
getServicesDetails |
Methods inherited from interface org.openspaces.pu.service.ServiceMonitorsProvider |
---|
getServicesMonitors |
Field Detail |
---|
protected final Log logger
protected String beanName
Constructor Detail |
---|
public AbstractSpaceListeningContainer()
Method Detail |
---|
public void setGigaSpace(GigaSpace gigaSpace)
public void setAutoStart(boolean initOnStartup)
Default is true
. Set to false
in order for this container to
be started using start()
.
protected final GigaSpace getGigaSpace()
public void setActiveWhenPrimary(boolean activeWhenPrimary)
Default is true
. Set to false
in order for this container to
always start regardless of the space mode.
public void setBeanName(String beanName)
setBeanName
in interface BeanNameAware
protected final String getBeanName()
public void setRegisterSpaceModeListener(boolean registerSpaceModeListener)
public void afterPropertiesSet()
validateConfiguration()
and initialize()
.
afterPropertiesSet
in interface InitializingBean
protected void validateConfiguration()
public void initialize() throws DataAccessException
true
will call doStart()
(if it is set to true
,
lifecycle of the container will be controlled by the current space mode).
doInitialize()
will be called for additional initialization after the possible
doStart()
call.
DataAccessException
onApplicationEvent(org.springframework.context.ApplicationEvent)
public void destroy()
shutdown()
when the BeanFactory destroys the container instance.
destroy
in interface DisposableBean
shutdown()
public void shutdown() throws DataAccessException
doShutdown()
, and close this container.
DataAccessException
public final boolean isActive()
public void onApplicationEvent(ApplicationEvent applicationEvent)
setActiveWhenPrimary(boolean)
is set to true
(the default),
the container lifecycle will be controlled by the space mode. The container will start when
the space is in PRIMARY
mode, and will stop when the space is in
BACKUP
mode.
Note, this might cause doStart()
or doStop()
to be called several times in
a row, and sub classes should take this into account.
onApplicationEvent
in interface ApplicationListener<ApplicationEvent>
public void start() throws DataAccessException
start
in interface Lifecycle
DataAccessException
doStart()
protected void doStart() throws DataAccessException
DataAccessException
protected void doAfterStart() throws DataAccessException
DataAccessException
public void stop() throws DataAccessException
stop
in interface Lifecycle
DataAccessException
doStop()
protected void doStop() throws DataAccessException
DataAccessException
protected void doBeforeStop() throws DataAccessException
DataAccessException
public final boolean isRunning()
isRunning
in interface Lifecycle
protected String getStatus()
protected final void waitWhileNotRunning()
To be called by asynchronous tasks that want to block while the container is in stopped state.
protected final boolean rescheduleTaskIfNecessary(Object task)
If this container has already been shut down, the task will not get rescheduled at all.
task
- the task object to reschedule
doRescheduleTask(java.lang.Object)
protected void doRescheduleTask(Object task)
To be implemented by subclasses if they ever call rescheduleTaskIfNecessary
.
This implementation throws an UnsupportedOperationException.
task
- the task object to reschedulerescheduleTaskIfNecessary(java.lang.Object)
protected String message(String message)
protected abstract void doInitialize() throws DataAccessException
DataAccessException
protected abstract void doShutdown() throws DataAccessException
DataAccessException
shutdown()
|
GigaSpaces XAP 9.7.2 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |