org.fusesource.commons.management.basic
Class AbstractManagementStrategy

java.lang.Object
  extended by org.fusesource.commons.management.basic.AbstractManagementStrategy
All Implemented Interfaces:
ManagementStrategy

public abstract class AbstractManagementStrategy
extends java.lang.Object
implements ManagementStrategy

A base class from which JMX based ManagementStrategy implementations may use as a starting point.

This base class implements the following:


Field Summary
static java.lang.String DEFAULT_DOMAIN
          The default domain name to be used when creating a MBeanServer
 
Constructor Summary
AbstractManagementStrategy()
           
 
Method Summary
 Statistic createStatistic(java.lang.String name, java.lang.Object owner, Statistic.UpdateMode updateMode)
          Creates a statistic; a representation of raw statistical data.
 javax.management.MBeanServer getMbeanServer()
          Gets the JMX MBeanServer.
 java.lang.String getMbeanServerDefaultDomain()
          Gets the mbeanServerDefaultDomain property.
 boolean getUsePlatformMBeanServer()
          Gets the value of the usePlatformMBeanServer property.
 void manageObject(java.lang.Object managedObject)
          Adds a managed object allowing the ManagementStrategy implementation to record or expose the object as it sees fit.
 void notify(java.util.EventObject event)
          A default implementation of notify that logs events to java.util.logging using the event class name for the logger, a Level.FINE as the log level and the event source and event toString() to create a loggable message.
 void setMbeanServer(javax.management.MBeanServer mbeanServer)
          Sets the JMX MBeanServer.
 void setMbeanServerDefaultDomain(java.lang.String mbeanServerDefaultDomain)
          Sets the mbeanServerDefaultDomain property.
 void setUsePlatformMBeanServer(boolean usePlatformMBeanServer)
          Sets the value of the usePlatformMBeanServer property.
 void unmanageObject(java.lang.Object managedObject)
          Removes the managed object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.fusesource.commons.management.ManagementStrategy
getManagedObjectName, isManaged, manageNamedObject, unmanageNamedObject
 

Field Detail

DEFAULT_DOMAIN

public static final java.lang.String DEFAULT_DOMAIN
The default domain name to be used when creating a MBeanServer

See Also:
Constant Field Values
Constructor Detail

AbstractManagementStrategy

public AbstractManagementStrategy()
Method Detail

manageObject

public void manageObject(java.lang.Object managedObject)
                  throws java.lang.Exception
Description copied from interface: ManagementStrategy
Adds a managed object allowing the ManagementStrategy implementation to record or expose the object as it sees fit.

Specified by:
manageObject in interface ManagementStrategy
Parameters:
managedObject - the managed object
Throws:
java.lang.Exception - can be thrown if the object could not be added

unmanageObject

public void unmanageObject(java.lang.Object managedObject)
                    throws java.lang.Exception
Description copied from interface: ManagementStrategy
Removes the managed object.

Specified by:
unmanageObject in interface ManagementStrategy
Parameters:
managedObject - the managed object
Throws:
java.lang.Exception - can be thrown if the object could not be removed

notify

public void notify(java.util.EventObject event)
            throws java.lang.Exception
A default implementation of notify that logs events to java.util.logging using the event class name for the logger, a Level.FINE as the log level and the event source and event toString() to create a loggable message.

Applications that use other logging systems (such as commons logging or log4j will typically override this implementation of notify(EventObject).

Specified by:
notify in interface ManagementStrategy
Parameters:
event - the event
Throws:
java.lang.Exception - can be thrown if the notification failed

createStatistic

public Statistic createStatistic(java.lang.String name,
                                 java.lang.Object owner,
                                 Statistic.UpdateMode updateMode)
Description copied from interface: ManagementStrategy
Creates a statistic; a representation of raw statistical data.

Specified by:
createStatistic in interface ManagementStrategy
Parameters:
name - The unique name assigned to the statistic usage.
owner - The object whose identity is to be associated with the metric.
updateMode - The update mode to be assigned to the returned statistic.
Returns:
the statistic
See Also:
Statistic.UpdateMode

getMbeanServer

public javax.management.MBeanServer getMbeanServer()
Gets the JMX MBeanServer.

Returns:
the mbean server

setMbeanServer

public void setMbeanServer(javax.management.MBeanServer mbeanServer)
Sets the JMX MBeanServer.

Parameters:
mbeanServer - the new mbean server

getUsePlatformMBeanServer

public boolean getUsePlatformMBeanServer()
Gets the value of the usePlatformMBeanServer property.

Returns:
whether to use platform mbean server or not

setUsePlatformMBeanServer

public void setUsePlatformMBeanServer(boolean usePlatformMBeanServer)
Sets the value of the usePlatformMBeanServer property.

Parameters:
usePlatformMBeanServer - If true, then use the JVM's platform MBeanServer. If false, find or create an MBeanServer using the mbeanServerDefaultDomain property.

getMbeanServerDefaultDomain

public java.lang.String getMbeanServerDefaultDomain()
Gets the mbeanServerDefaultDomain property.

Returns:
The MBeanServerDefaultDomainName.

setMbeanServerDefaultDomain

public void setMbeanServerDefaultDomain(java.lang.String mbeanServerDefaultDomain)
Sets the mbeanServerDefaultDomain property.

If the MBeanServer is not explicitly set and using the default platform MBeanServer has been disabled, then an MBeanServer with the given default domain name will be discovered or created.

Parameters:
mbeanServerDefaultDomain - The MBeanServerDefaultDomainName.


Copyright © 2009 FuseSource. All Rights Reserved.