org.jboss.ejb.plugins
Class CleanShutdownInterceptor

java.lang.Object
  extended byorg.jboss.ejb.plugins.AbstractInterceptor (src) 
      extended byorg.jboss.ejb.plugins.CleanShutdownInterceptor
All Implemented Interfaces:
AllowedOperationsFlags (src) , ContainerPlugin (src) , Interceptor (src) , Service (src)

public class CleanShutdownInterceptor
extends AbstractInterceptor (src)

Track the incoming invocations and when shuting down a container (stop or destroy), waits for current invocations to finish before returning the stop or destroy call. This interceptor can be important in clustered environment where shuting down a node doesn't necessarly mean that an application cannot be reached: other nodes may still be servicing. Consequently, it is important to have a clean shutdown to keep a coherent behaviour cluster-wide. To avoid strange or inefficient behaviour, the facade session bean (if any) should be stopped first thus not blocking invocations in a middle-step (i.e. facade making multiple invocations to "sub-beans": if a "sub-bean" is shut down, the facade will get an exception in the middle of its activity)

See Also:

Field Summary
protected  boolean allowInvocations
           
protected  boolean allowRemoteInvocations
           
protected  Container (src) container
           
protected  EjbModule (src) ejbModule
           
protected  java.lang.String ejbModuleName
           
protected  boolean isDebugEnabled
           
 long readAcquireTimeMs
           
 long runningHomeInvocations
           
 long runningInvocations
           
protected  ReentrantWriterPreferenceReadWriteLock rwLock
           
 long shutdownTimeout
           
 
Fields inherited from class org.jboss.ejb.plugins.AbstractInterceptor (src)
log, nextInterceptor
 
Fields inherited from interface org.jboss.ejb.AllowedOperationsFlags (src)
IN_AFTER_BEGIN, IN_AFTER_COMPLETION, IN_BEFORE_COMPLETION, IN_BUSINESS_METHOD, IN_EJB_ACTIVATE, IN_EJB_CREATE, IN_EJB_FIND, IN_EJB_HOME, IN_EJB_LOAD, IN_EJB_PASSIVATE, IN_EJB_POST_CREATE, IN_EJB_REMOVE, IN_EJB_STORE, IN_EJB_TIMEOUT, IN_INTERCEPTOR_METHOD, IN_SERVICE_ENDPOINT_METHOD, IN_SET_ENTITY_CONTEXT, IN_SET_MESSAGE_DRIVEN_CONTEXT, IN_SET_SESSION_CONTEXT, IN_UNSET_ENTITY_CONTEXT, NOT_ALLOWED
 
Constructor Summary
CleanShutdownInterceptor()
           
 
Method Summary
protected  void containerIsAboutToStop()
           
 void create()
          create the service, do expensive operations etc
 void destroy()
          destroy the service, tear down
protected  void forbidInvocations()
           
 Container (src) getContainer()
           
protected  java.lang.String getOrigin(Invocation (src)  mi)
           
 java.lang.Object invoke(Invocation (src)  mi)
          ???
 java.lang.Object invokeHome(Invocation (src)  mi)
          ???
 void onlyAllowLocalInvocations()
           
protected  void purgeRunningInvocations()
           
protected  void revertOrigin(Invocation (src)  mi, java.lang.String origin)
           
 void setContainer(Container (src)  con)
          This callback is set by the container so that the plugin may access it
protected  void setOrigin(Invocation (src)  mi)
           
 void start()
          start the service, create is already called
 void stop()
          stop the service
 void waitForNoMoreInvocations()
           
 
Methods inherited from class org.jboss.ejb.plugins.AbstractInterceptor (src)
getNext, setNext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

container

protected Container (src)  container

ejbModule

protected EjbModule (src)  ejbModule

ejbModuleName

protected java.lang.String ejbModuleName

allowInvocations

protected boolean allowInvocations

allowRemoteInvocations

protected boolean allowRemoteInvocations

isDebugEnabled

protected boolean isDebugEnabled

runningInvocations

public long runningInvocations

runningHomeInvocations

public long runningHomeInvocations

shutdownTimeout

public long shutdownTimeout

readAcquireTimeMs

public long readAcquireTimeMs

rwLock

protected ReentrantWriterPreferenceReadWriteLock rwLock
Constructor Detail

CleanShutdownInterceptor

public CleanShutdownInterceptor()
Method Detail

onlyAllowLocalInvocations

public void onlyAllowLocalInvocations()

waitForNoMoreInvocations

public void waitForNoMoreInvocations()

create

public void create()
            throws java.lang.Exception
Description copied from interface: Service (src)
create the service, do expensive operations etc

Specified by:
create in interface Service (src)
Overrides:
create in class AbstractInterceptor (src)
Throws:
java.lang.Exception

start

public void start()
           throws java.lang.Exception
Description copied from interface: Service (src)
start the service, create is already called

Specified by:
start in interface Service (src)
Overrides:
start in class AbstractInterceptor (src)
Throws:
java.lang.Exception

stop

public void stop()
Description copied from interface: Service (src)
stop the service

Specified by:
stop in interface Service (src)
Overrides:
stop in class AbstractInterceptor (src)

destroy

public void destroy()
Description copied from interface: Service (src)
destroy the service, tear down

Specified by:
destroy in interface Service (src)
Overrides:
destroy in class AbstractInterceptor (src)

invokeHome

public java.lang.Object invokeHome(Invocation (src)  mi)
                            throws java.lang.Exception
Description copied from interface: Interceptor (src)
???

Specified by:
invokeHome in interface Interceptor (src)
Overrides:
invokeHome in class AbstractInterceptor (src)
Throws:
java.lang.Exception

invoke

public java.lang.Object invoke(Invocation (src)  mi)
                        throws java.lang.Exception
Description copied from interface: Interceptor (src)
???

Specified by:
invoke in interface Interceptor (src)
Overrides:
invoke in class AbstractInterceptor (src)
Throws:
java.lang.Exception

getContainer

public Container (src)  getContainer()
Overrides:
getContainer in class AbstractInterceptor (src)

setContainer

public void setContainer(Container (src)  con)
This callback is set by the container so that the plugin may access it

Specified by:
setContainer in interface ContainerPlugin (src)
Overrides:
setContainer in class AbstractInterceptor (src)
Parameters:
con - The container using this plugin.

forbidInvocations

protected void forbidInvocations()

purgeRunningInvocations

protected void purgeRunningInvocations()

getOrigin

protected java.lang.String getOrigin(Invocation (src)  mi)

setOrigin

protected void setOrigin(Invocation (src)  mi)

revertOrigin

protected void revertOrigin(Invocation (src)  mi,
                            java.lang.String origin)

containerIsAboutToStop

protected void containerIsAboutToStop()