JBossMX Parent POM 6.0.0.GA

org.jboss.mx.interceptor
Class AbstractSharedInterceptor

java.lang.Object
  extended by org.jboss.mx.interceptor.AbstractInterceptor
      extended by org.jboss.mx.interceptor.AbstractSharedInterceptor
All Implemented Interfaces:
MBeanRegistration, Interceptor, SharedInterceptor

public abstract class AbstractSharedInterceptor
extends AbstractInterceptor
implements SharedInterceptor

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

Version:
$Revision: 86129 $
Author:
Juha Lindfors.
See Also:
SharedInterceptor, MBeanInvoker

Field Summary
protected  ObjectName objectName
          Object name of this interceptor.
protected  MBeanServer server
          MBean server reference for shared interceptors.
 
Fields inherited from class org.jboss.mx.interceptor.AbstractInterceptor
isShared, log, name
 
Constructor Summary
AbstractSharedInterceptor()
          Constructs a new shared interceptor instance.
AbstractSharedInterceptor(String name)
          Constructs a new shared interceptor instance with a given name.
 
Method Summary
protected  ObjectName createObjectName()
          Creates an object name for this interceptor.
 void destroy()
          This method is part of the interceptor MBean's registration lifecycle.
 MBeanServer getMBeanServer()
          Returns the interceptor's view to the MBean server it has been registered to.
 ObjectName getObjectName()
          Returns the object name of this shared interceptor.
 void init()
          This method is part of the interceptor MBean's registration lifecycle.
 void postDeregister()
           
 void postRegister(Boolean registrationSuccesful)
           
 void preDeregister()
           
 ObjectName preRegister(MBeanServer server, ObjectName oname)
           
 ObjectName register(MBeanServer server)
          Registers the interceptor to the MBean server.
 void setName(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.
 String toString()
          Returns a string representation of this interceptor instance.
 
Methods inherited from class org.jboss.mx.interceptor.AbstractInterceptor
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
getName, invoke, isShared, setLogger
 

Field Detail

server

protected MBeanServer server
MBean server reference for shared interceptors.


objectName

protected ObjectName 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(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:
IllegalArgumentException - if name contains null reference
Method Detail

getObjectName

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

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

getMBeanServer

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

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

register

public ObjectName register(MBeanServer server)
                    throws InterceptorNameConflictException
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,*

 

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

init

public void init()
          throws 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
Overrides:
init in class AbstractInterceptor
Throws:
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
Overrides:
start in class AbstractInterceptor

stop

public void stop()
          throws 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
Overrides:
stop in class AbstractInterceptor
Throws:
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
Overrides:
destroy in class AbstractInterceptor

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName oname)
                       throws Exception
Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception

postRegister

public void postRegister(Boolean registrationSuccesful)
Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws Exception
Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception

postDeregister

public void postDeregister()
Specified by:
postDeregister in interface MBeanRegistration

setName

public void setName(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
Parameters:
name - name of this shared interceptor
Throws:
IllegalArgumentException - if there was an attempt to change the name after the interceptor had been registered to the server

toString

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

Overrides:
toString in class AbstractInterceptor
Returns:
string representation

createObjectName

protected ObjectName createObjectName()
                               throws MalformedObjectNameException
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 - if the object name could not be created

JBossMX Parent POM 6.0.0.GA

Copyright © 2012 JBoss, a division of Red Hat, Inc.. All Rights Reserved.