com.hazelcast.jmx
Class AbstractMBean<E>

java.lang.Object
  extended by com.hazelcast.jmx.AbstractMBean<E>
All Implemented Interfaces:
DynamicMBean, MBeanRegistration
Direct Known Subclasses:
AtomicNumberMBean, ClusterMBean, CountDownLatchMBean, DataMBean, ListMBean, LockMBean, MapEntryMBean, MapMBean, MemberMBean, MultiMapMBean, QueueMBean, SemaphoreMBean, SetMBean, TopicMBean

public abstract class AbstractMBean<E>
extends Object
implements DynamicMBean, MBeanRegistration

A generic class to instrument object with dynamic MBeans.

Implements the method instrument(), in which add attributes and operation exposed to JMX.

If the managed object is an immutable state of some other object that requires a special refresh strategy, override method refresh()

http://docs.sun.com/app/docs/doc/816-4178/6madjde4n?a=view

Author:
Marco Ferrante, DISI - University of Genoa

Field Summary
protected static Logger logger
           
protected  ManagementService managementService
           
protected  MBeanServer mbeanServer
           
 
Constructor Summary
AbstractMBean(E managedObject, ManagementService service)
           
 
Method Summary
 Object getAttribute(String attribute)
          Local attribute override managed object attribute
 AttributeList getAttributes(String[] attributes)
          getAttributes() in interface DynamicMBean
 E getManagedObject()
           
 MBeanInfo getMBeanInfo()
          From DynamicMBean interface
protected  ObjectNameSpec getNameSpec()
          Override to provide a JMX name
 ObjectName getObjectName()
          The current objectName.
 ObjectNameSpec getParentName()
           
 Object invoke(String actionName, Object[] params, String[] signature)
          invoke() in interface DynamicMBean
 void postDeregister()
          From interface MBeanRegistration
 void postRegister(Boolean registrationDone)
          From interface MBeanRegistration
 void preDeregister()
          From interface MBeanRegistration
 ObjectName preRegister(MBeanServer server, ObjectName name)
          From interface MBeanRegistration
protected  E refresh()
          Override this method if the managed object requires some refresh before reading.
 void setAttribute(Attribute attribute)
           
 AttributeList setAttributes(AttributeList attributes)
           
 void setParentName(ObjectNameSpec spec)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final Logger logger

mbeanServer

protected transient MBeanServer mbeanServer

managementService

protected final ManagementService managementService
Constructor Detail

AbstractMBean

public AbstractMBean(E managedObject,
                     ManagementService service)
Method Detail

getManagedObject

public final E getManagedObject()

refresh

protected E refresh()
Override this method if the managed object requires some refresh before reading. Return the new state/object.


getMBeanInfo

public MBeanInfo getMBeanInfo()
From DynamicMBean interface

Specified by:
getMBeanInfo in interface DynamicMBean

getAttribute

public final Object getAttribute(String attribute)
                          throws AttributeNotFoundException,
                                 MBeanException,
                                 ReflectionException
Local attribute override managed object attribute

Specified by:
getAttribute in interface DynamicMBean
Throws:
AttributeNotFoundException
MBeanException
ReflectionException

getAttributes

public final AttributeList getAttributes(String[] attributes)
getAttributes() in interface DynamicMBean

Specified by:
getAttributes in interface DynamicMBean
Parameters:
attributes - A String array of names of the attributes to be retrieved.
Returns:
The array of the retrieved attributes.
Throws:
RuntimeOperationsException - Wraps an IllegalArgumentException: The object name in parameter is null or attributes in parameter is null.

invoke

public final Object invoke(String actionName,
                           Object[] params,
                           String[] signature)
                    throws MBeanException,
                           ReflectionException
invoke() in interface DynamicMBean

Specified by:
invoke in interface DynamicMBean
Throws:
MBeanException
ReflectionException

setAttribute

public final void setAttribute(Attribute attribute)
                        throws AttributeNotFoundException,
                               InvalidAttributeValueException,
                               MBeanException,
                               ReflectionException
Specified by:
setAttribute in interface DynamicMBean
Throws:
AttributeNotFoundException
InvalidAttributeValueException
MBeanException
ReflectionException

setAttributes

public final AttributeList setAttributes(AttributeList attributes)
Specified by:
setAttributes in interface DynamicMBean

setParentName

public void setParentName(ObjectNameSpec spec)

getParentName

public ObjectNameSpec getParentName()

getNameSpec

protected ObjectNameSpec getNameSpec()
Override to provide a JMX name


getObjectName

public final ObjectName getObjectName()
                               throws Exception
The current objectName. To provide a default, override this method and pass null as name to the method MBeanServer.registerMBean()

Returns:
The current objectName
Throws:
Exception

preRegister

public ObjectName preRegister(MBeanServer server,
                              ObjectName name)
                       throws Exception
From interface MBeanRegistration

Specified by:
preRegister in interface MBeanRegistration
Throws:
Exception

postRegister

public void postRegister(Boolean registrationDone)
From interface MBeanRegistration

Specified by:
postRegister in interface MBeanRegistration

preDeregister

public void preDeregister()
                   throws Exception
From interface MBeanRegistration

Specified by:
preDeregister in interface MBeanRegistration
Throws:
Exception

postDeregister

public void postDeregister()
From interface MBeanRegistration

Specified by:
postDeregister in interface MBeanRegistration


Copyright 2008-2012 Hazel Ltd. All Rights Reserved.