org.jboss.mx.interceptor
Class AbstractSharedInterceptor

java.lang.Object
  extended byorg.jboss.mx.interceptor.AbstractInterceptor (src) 
      extended byorg.jboss.mx.interceptor.AbstractSharedInterceptor
All Implemented Interfaces:
Interceptor (src) , MBeanRegistration (src) , SharedInterceptor (src)
Direct Known Subclasses:
MySharedInterceptor (src)

public abstract class AbstractSharedInterceptor
extends AbstractInterceptor (src)
implements SharedInterceptor (src)

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

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

Field Summary
protected  ObjectName (src) objectName
          Object name of this interceptor.
protected  MBeanServer (src) server
          MBean server reference for shared interceptors.
 
Fields inherited from class org.jboss.mx.interceptor.AbstractInterceptor (src)
isShared, log, name
 
Constructor Summary
AbstractSharedInterceptor()
          Constructs a new shared interceptor instance.
AbstractSharedInterceptor(java.lang.String name)
          Constructs a new shared interceptor instance with a given name.
 
Method Summary
protected  ObjectName (src) createObjectName()
          Creates an object name for this interceptor.
 void destroy()
          This method is part of the interceptor MBean's registration lifecycle.
 MBeanServer (src) getMBeanServer()
          Returns the interceptor's view to the MBean server it has been registered to.
 ObjectName (src) getObjectName()
          Returns the object name of this shared interceptor.
 void init()
          This method is part of the interceptor MBean's registration lifecycle.
 void postDeregister()
          This method is called by the MBeanServer after deregistration takes place.
 void postRegister(java.lang.Boolean registrationSuccesful)
          This method is called by the MBeanServer after registration takes place or when registration fails.
 void preDeregister()
          This method is called by the MBeanServer before deregistration takes place.
 ObjectName (src) preRegister(MBeanServer (src)  server, ObjectName (src)  oname)
          This method is called by the MBeanServer before registration takes place.
 ObjectName (src) register(MBeanServer (src)  server)
          Registers the interceptor to the MBean server.
 void setName(java.lang.String name)
          Shared interceptors allows their name to be set only before they have been registered to the MBean server.
 void start()
          This method is part of the interceptor MBean's registration lifecycle.
 void stop()
          This method is part of the interceptor MBean's registration lifecycle.
 java.lang.String toString()
          Returns a string representation of this interceptor instance.
 
Methods inherited from class org.jboss.mx.interceptor.AbstractInterceptor (src)
getName, invoke, isShared, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.mx.interceptor.Interceptor (src)
getName, invoke, isShared, setLogger
 

Field Detail

server

protected MBeanServer (src)  server
MBean server reference for shared interceptors.


objectName

protected ObjectName (src)  objectName
Object name of this interceptor. Shared interceptors must always contain a valid object name.

Constructor Detail

AbstractSharedInterceptor

public AbstractSharedInterceptor()
Constructs a new shared interceptor instance. The interceptor is not automatically registered to the MBean server. Notice that the interceptor name must be set before the call to register(javax.management.MBeanServer) method. Shared interceptor names must be unique within the MBean server.


AbstractSharedInterceptor

public AbstractSharedInterceptor(java.lang.String name)
Constructs a new shared interceptor instance with a given name. The interceptor is not automatically registered to the MBean server. Notice that the shared interceptor name must be unique name among all shared interceptors within the MBean server.

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

getObjectName

public ObjectName (src)  getObjectName()
Description copied from interface: SharedInterceptor (src)
Returns the object name of this shared interceptor.

Specified by:
getObjectName in interface SharedInterceptor (src)
Returns:
interceptor's object name

getMBeanServer

public MBeanServer (src)  getMBeanServer()
Description copied from interface: SharedInterceptor (src)
Returns the interceptor's view to the MBean server it has been registered to.

Specified by:
getMBeanServer in interface SharedInterceptor (src)
Returns:
interceptor's view to its MBean server

register

public ObjectName (src)  register(MBeanServer (src)  server)
                    throws InterceptorNameConflictException (src) 
Registers the interceptor to the MBean server.

The interceptor is registered under the JBOSSMX_DOMAIN name. An interceptor's object name contains a type property and a name property. Property type always contains string 'Interceptor' as its value. Interceptor's name is used as a value for the name property. Therefore, an interceptor created with name 'Bart' can be found from the MBean server under object name:


    JBOSSMX_DOMAIN:type=Interceptor,name=Bart,*

 
If the log reference has not been set for this interceptor when it is registered, this implementation will register a log MBean via the system log manager under JBOSSMX domain (see SystemLogManager for details). The log instance's name will match the pattern:

    "JBossMX.Interceptor.<interceptor name>"

 

Specified by:
register in interface SharedInterceptor (src)
Parameters:
server - MBean server where this shared interceptor is registered
Returns:
the object name of the registered interceptor
Throws:
InterceptorNameConflictException (src) - if an interceptor was already registered to the given server

init

public void init()
          throws java.lang.Exception
This method is part of the interceptor MBean's registration lifecycle. It 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)
Overrides:
init in class AbstractInterceptor (src)
Throws:
java.lang.Exception - if you want to cancel the interceptor registration

start

public void start()
This method is part of the interceptor MBean's registration lifecycle. It is called after the MBean is registered to the server. 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)
Overrides:
start in class AbstractInterceptor (src)

stop

public void stop()
          throws java.lang.Exception
This method is part of the interceptor MBean's registration lifecycle. It is called before the MBean is unregistered from the server. 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)
Overrides:
stop in class AbstractInterceptor (src)
Throws:
java.lang.Exception - if you want to cancel the interceptor unregistration

destroy

public void destroy()
This method is part of the interceptor MBean's registration lifecycle. It is called after the MBean has been unregistered from the server. 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)
Overrides:
destroy in class AbstractInterceptor (src)

preRegister

public ObjectName (src)  preRegister(MBeanServer (src)  server,
                              ObjectName (src)  oname)
                       throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before registration takes place. The MBean is passed a reference of the MBeanServer it is about to be registered with. The MBean must return the ObjectName it will be registered with. The MBeanServer can pass a suggested object depending upon how the MBean is registered.

The MBean can stop the registration by throwing an exception.The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preRegister in interface MBeanRegistration (src)
Returns:
the actual ObjectName to register this MBean with.
Throws:
java.lang.Exception - for any error, the MBean is not registered.

postRegister

public void postRegister(java.lang.Boolean registrationSuccesful)
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after registration takes place or when registration fails.

Specified by:
postRegister in interface MBeanRegistration (src)
Parameters:
registrationSuccesful - the MBeanServer passes true when the MBean was registered, false otherwise.

preDeregister

public void preDeregister()
                   throws java.lang.Exception
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer before deregistration takes place.

The MBean can throw an exception, this will stop the deregistration. The exception is forwarded to the invoker wrapped in an MBeanRegistrationException.

Specified by:
preDeregister in interface MBeanRegistration (src)
Throws:
java.lang.Exception

postDeregister

public void postDeregister()
Description copied from interface: MBeanRegistration (src)
This method is called by the MBeanServer after deregistration takes place.

Specified by:
postDeregister in interface MBeanRegistration (src)

setName

public void setName(java.lang.String name)
Shared interceptors allows their name to be set only before they have been registered to the MBean server. After that the name is fixed and any attempt to invoke this method to change the name will yield a IllegalArgumentException.

Overrides:
setName in class AbstractInterceptor (src)
Parameters:
name - name of this shared interceptor
Throws:
java.lang.IllegalArgumentException - if there was an attempt to change the name after the interceptor had been registered to the server

toString

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

Overrides:
toString in class AbstractInterceptor (src)
Returns:
string representation

createObjectName

protected ObjectName (src)  createObjectName()
                               throws MalformedObjectNameException (src) 
Creates an object name for this interceptor. The object name contains a type property and a name property. Property type always contains string 'Interceptor' as its value. Interceptor's name is used as a value for the name property. Therefore, an interceptor created with name 'Bart' will generate an object name matching to pattern:

    JBOSSMX_DOMAIN:type=Interceptor,name=Bart,*

 

Returns:
generated object name for this interceptor
Throws:
MalformedObjectNameException (src) - if the object name could not be created