org.jboss.mx.interceptor
Class AbstractInterceptor

java.lang.Object
  extended byorg.jboss.mx.interceptor.AbstractInterceptor
All Implemented Interfaces:
Interceptor (src)
Direct Known Subclasses:
AbstractSharedInterceptor (src) , AuthenticationInterceptor (src) , AuthorizationInterceptor (src) , JNDIPersistence (src) , JNDISecurity (src) , LogInterceptor (src) , ModelMBeanAttributeInterceptor (src) , ModelMBeanInfoInterceptor (src) , ModelMBeanOperationInterceptor (src) , NullInterceptor (src) , ObjectReferenceInterceptor (src) , PersistenceInterceptor (src) , PrincipalInterceptor (src) , ProxyFactoryInterceptor (src) , ProxyFactoryInterceptor (src) , ReflectedDispatcher (src) , SecurityInterceptor (src) , SecurityInterceptor (src) , SRPCacheInterceptor (src) , StandardMBeanInfoInterceptor (src)

public abstract class AbstractInterceptor
extends java.lang.Object
implements Interceptor (src)

Base class for all interceptors. This class provides some default method implementations for interceptors.

See Also:
Interceptor (src) , MBeanInvoker (src)

Field Summary
protected  boolean isShared
          Indicates whether this interceptor instance is shared or not.
protected  Logger (src) log
          Logger reference for interceptor implementations.
protected  java.lang.String name
          Name for this interceptor.
 
Constructor Summary
AbstractInterceptor()
          Constructs a new intereceptor instance.
AbstractInterceptor(java.lang.String name)
          Constructs a new interceptor instance with a given name.
 
Method Summary
 void destroy()
          This method is part of the interceptor lifecycle.
 java.lang.String getName()
          Returns the name of this interceptor.
 void init()
          This method is part of the interceptor's lifecycle.
 java.lang.Object invoke(Invocation (src)  invocation)
          The default invoke implementation queries the invocation object for the next interceptor in the chain.
 boolean isShared()
          Returns true if this interceptor is shared by multiple invokers; false otherwise.
 void setLogger(Logger (src)  log)
          Called by the MBeanInvoker (src) on a non-shared interceptors to set a logger reference for this interceptor.
 void setName(java.lang.String name)
          Sets a name for this interceptor.
 void start()
          This method is part of the interceptor's lifecycle.
 void stop()
          This method is part of the interceptor lifecycle.
 java.lang.String toString()
          Returns a string representation of this interceptor instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

name

protected java.lang.String name
Name for this interceptor.


isShared

protected boolean isShared
Indicates whether this interceptor instance is shared or not.


log

protected Logger (src)  log
Logger reference for interceptor implementations. This reference is set by the invoker for non-shared interceptors after construction. Shared interceptors will should create their own logger instance.

Constructor Detail

AbstractInterceptor

public AbstractInterceptor()
Constructs a new intereceptor instance. This interceptor is not shared in the MBean server.


AbstractInterceptor

public AbstractInterceptor(java.lang.String name)
Constructs a new interceptor instance with a given name. This interceptor is not shared in the MBean server.

Parameters:
name - name of this interceptor
Throws:
java.lang.IllegalArgumentException - if name contains null reference
Method Detail

setName

public void setName(java.lang.String name)
Sets a name for this interceptor.

Parameters:
name -

invoke

public java.lang.Object invoke(Invocation (src)  invocation)
                        throws java.lang.Throwable
The default invoke implementation queries the invocation object for the next interceptor in the chain. If one exists, it is invoked. Otherwise the invocation is dispatched to the target object.

Concrete implementations should override this method to implement their specific application logic.

Specified by:
invoke in interface Interceptor (src)
Parameters:
invocation - the invocation object send towards the target resource by the invoker
Returns:
return value from the target resource
Throws:
InvocationException - This exception wraps any exceptions thrown by either the target method of the resource object, or invocation interceptors in this interceptor chain. The target exception is unwrapped at the MBeanInvoker (src) instance.
java.lang.Throwable
See Also:
Invocation (src) , MBeanInvoker (src)

getName

public java.lang.String getName()
Description copied from interface: Interceptor (src)
Returns the name of this interceptor. Notice that for shared interceptors this name must be unique among the shared interceptors in the MBean server.

Specified by:
getName in interface Interceptor (src)

isShared

public boolean isShared()
Description copied from interface: Interceptor (src)
Returns true if this interceptor is shared by multiple invokers; false otherwise. Non-shared interceptors should always return false. Shared interceptors return false if they have not been registered to the MBean server yet. Shared interceptors must always return true after they have been registered to the server.

Specified by:
isShared in interface Interceptor (src)
Returns:
true if shared;false otherwise

setLogger

public void setLogger(Logger (src)  log)
Description copied from interface: Interceptor (src)
Called by the MBeanInvoker (src) on a non-shared interceptors to set a logger reference for this interceptor. The interceptor implementation may use the invoker's logger for recording log information.

Shared interceptors should set up their log facility through other means as they are invoked by several different MBean invokers. To access the log implementation of the originating invoker for a particular invocation, an interceptor may query they invocation context for invoker reference.

Specified by:
setLogger in interface Interceptor (src)

init

public void init()
          throws java.lang.Exception
Description copied from interface: Interceptor (src)
This method is part of the interceptor's lifecycle. It is called by the invoker during the initialization of the interceptor instance.

For shared interceptors the lifecycle is driven by the MBean registration. This method is called before the MBean is registered to the server.

Concrete interceptor implementations can override this method to provide initialization code that should be executed before the interceptor is registered.

Any exception that is propagated from this method to its caller will cancel the interceptor registration.

Specified by:
init in interface Interceptor (src)
Throws:
java.lang.Exception - if you want to cancel the interceptor registration

start

public void start()
Description copied from interface: Interceptor (src)
This method is part of the interceptor's lifecycle. It is called by the invoker during the interceptor initialization process.

For shared interceptors the lifecycle is driven by the MBean registration. This method is called after the MBean is registered to the server as part of the MBeanRegistration.postRegister(java.lang.Boolean) execution.

Concrete interceptor implementations can override this method to provide initialization code that should be executed once the MBean server and object name references for this interceptor have been resolved.

Specified by:
start in interface Interceptor (src)

stop

public void stop()
          throws java.lang.Exception
Description copied from interface: Interceptor (src)
This method is part of the interceptor lifecycle. It is called by the invoker during the interceptor removal.

For shared interceptors the lifecycle is driven by the MBean unregistration. This method is called after the MBean is registered to the server as part of the MBeanRegistration.preDeregister() execution.

Concrete interceptor implementations can override this method to provide cleanup code that should be executed before the interceptor is unregistered.

Any exception that is propagated from this method to its caller will cancel the interceptor unregistration.

Specified by:
stop in interface Interceptor (src)
Throws:
java.lang.Exception - if you want to cancel the interceptor unregistration

destroy

public void destroy()
Description copied from interface: Interceptor (src)
This method is part of the interceptor lifecycle. It is called by the invoker durin the interceptor removal.

For shared interceptors the lifecycle is driven by the MBean unregistration. This method is called after the MBean is registered to the server as part of the MBeanRegistration.postDeregister() execution.

Concrete interceptor implementations can override this method to provide cleanup code that should be executed once the interceptor is no longer registered to the MBean server.

Specified by:
destroy in interface Interceptor (src)

toString

public java.lang.String toString()
Returns a string representation of this interceptor instance.

Returns:
string representation