dk.netarkivet.common.management
Class SingleMBeanObject<I>

java.lang.Object
  extended by dk.netarkivet.common.management.SingleMBeanObject<I>

public class SingleMBeanObject<I>
extends java.lang.Object

Wrapper class for registering objects of type I as MBeans. The register method will register a given obejct under an object name, generated with the domain given in constructor, and fields from the Hashtable nameProperties. It is prefilled with values common for all MBeans, but it is expected to be extended after the object is created with additional info.


Constructor Summary
SingleMBeanObject(javax.management.ObjectName name, I o, java.lang.Class<I> asInterface, javax.management.MBeanServer mBeanServer)
          Create a single mbean object.
SingleMBeanObject(java.lang.String domain, I object, java.lang.Class<I> asInterface, javax.management.MBeanServer mBeanServer)
          Create a single mbean object.
 
Method Summary
 javax.management.ObjectName getName()
           
 java.util.Hashtable<java.lang.String,java.lang.String> getNameProperties()
          Properties for the ObjectName name.
 void register()
          Registers this object as a standard MBean, with a name generated from domain given in constructor and the nameProperties hashTable.
 void unregister()
          Unregister the object from the MBeanServer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SingleMBeanObject

public SingleMBeanObject(java.lang.String domain,
                         I object,
                         java.lang.Class<I> asInterface,
                         javax.management.MBeanServer mBeanServer)
Create a single mbean object. This will fill out nameProperties with default values, and remember the domain and interface given. It will not, however, register the MBean.

Parameters:
domain - The domain of the MBean.
object - The object to expose as an MBean.
asInterface - The interface this MBean is exposed as.
mBeanServer - The server to register the mbean in.
Throws:
ArgumentNotValid - If domain is null or empty, or any other argument is null.

SingleMBeanObject

public SingleMBeanObject(javax.management.ObjectName name,
                         I o,
                         java.lang.Class<I> asInterface,
                         javax.management.MBeanServer mBeanServer)
Create a single mbean object. This is a helper method for the constructor taking a domain, which take the domain from a preconstructed ObjectName and replaces the nameProperties with the properties from the given object name. Use this if you have an object name created already, which you wish to use.

Parameters:
name - The object name to register under.
o - The object to register.
asInterface - The interface o should implement.
mBeanServer - The mbean server to register o in.
Throws:
ArgumentNotValid - on any null parameter.
Method Detail

getNameProperties

public java.util.Hashtable<java.lang.String,java.lang.String> getNameProperties()
Properties for the ObjectName name. Update these before registering. On construction, initialised with location, hostname, httpport, priority, replica, applicationname, applicationinstid.

Returns:
Hashtable of the object name properties.

register

public void register()
Registers this object as a standard MBean, with a name generated from domain given in constructor and the nameProperties hashTable.

Throws:
IllegalState - if bean is already registered.
IOFailure - on trouble registering.

unregister

public void unregister()
Unregister the object from the MBeanServer. Note: It is not checked that it is actually this mbean that is registered under the name, this method simply unregisters any object with this object name.

Throws:
IOFailure - on trouble unregistering.

getName

public javax.management.ObjectName getName()
Returns:
the name