org.rhq.plugins.jmx
Class MBeanResourceComponent<T extends JMXComponent>

java.lang.Object
  extended by org.rhq.plugins.jmx.MBeanResourceComponent<T>
All Implemented Interfaces:
AvailabilityFacet, ConfigurationFacet, ConfigurationFacetSupport, ResourceComponent<T>, MeasurementFacet, OperationFacet, JMXComponent<T>
Direct Known Subclasses:
JavaUtilLoggingResourceComponent, ThreadDataMeasurementComponent

public class MBeanResourceComponent<T extends JMXComponent>
extends Object
implements MeasurementFacet, OperationFacet, ConfigurationFacet, JMXComponent<T>

A generic JMX MBean resource component that can be used to manage a JMX MBean. The resource's plugin configuration will determine what MBean is to be managed by this component.

Author:
Greg Hinkle, John Mazzitelli

Field Summary
protected  org.mc4j.ems.connection.bean.EmsBean bean
          Deprecated. do not use this - use getEmsBean() instead
protected static org.apache.commons.logging.Log log
          Subclasses are free to use this directly as a way to log messages.
static String OBJECT_NAME_PROP
           
static String PROPERTY_TRANSFORM
           
protected  ResourceContext<T> resourceContext
          Deprecated. do not use this - use getResourceContext() instead
 
Fields inherited from interface org.rhq.plugins.jmx.JMXComponent
CREDENTIALS_CONFIG_PROP, PRINCIPAL_CONFIG_PROP
 
Constructor Summary
MBeanResourceComponent()
           
 
Method Summary
protected  String getAttributeName(String property)
           
protected  String getAttributeProperty(String property)
           
 AvailabilityType getAvailability()
          Is this service alive?
protected  void getBeanProperties(MeasurementReport report, org.mc4j.ems.connection.bean.EmsBean thisBean, Set<MeasurementScheduleRequest> requests)
           
 org.mc4j.ems.connection.bean.EmsBean getEmsBean()
          Gets the loaded MBean.
 org.mc4j.ems.connection.EmsConnection getEmsConnection()
           
 ResourceContext<T> getResourceContext()
           
 void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests)
           
protected  void getValues(MeasurementReport report, Set<MeasurementScheduleRequest> requests, org.mc4j.ems.connection.bean.EmsBean bean)
          Can be called from sub-classes to collect metrics on a bean other than the default bean for this resource Supports {a.b} syntax for reading the b Java Bean property from the object value returned from the a jmx property.
 OperationResult invokeOperation(String name, Configuration parameters)
           
 OperationResult invokeOperation(String name, Configuration parameters, org.mc4j.ems.connection.bean.EmsBean emsBean)
           
protected  org.mc4j.ems.connection.bean.EmsBean loadBean()
          Loads the MBean in a default way.
protected  org.mc4j.ems.connection.bean.EmsBean loadBean(String objectName)
          Loads the bean with the given object name.
 Configuration loadResourceConfiguration()
          This default setup of configuration properties can map to mbean attributes
protected  Object lookupAttributeProperty(Object value, String property)
           
protected  void setEmsBean(org.mc4j.ems.connection.bean.EmsBean bean)
          Sets the MBean that this component considers loaded.
protected  void setResourceContext(ResourceContext<T> resourceContext)
           
 void start(ResourceContext<T> context)
          Stores the context and loads the MBean.
 void stop()
          Cleans the old resource context and the old MBean.
protected  String transformBeanName(String beanTemplate)
           
 void updateResourceConfiguration(ConfigurationUpdateReport report)
          Equivalent to updateResourceConfiguration(report, false);
 void updateResourceConfiguration(ConfigurationUpdateReport report, boolean ignoreReadOnly)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static org.apache.commons.logging.Log log
Subclasses are free to use this directly as a way to log messages.


OBJECT_NAME_PROP

public static final String OBJECT_NAME_PROP
See Also:
Constant Field Values

PROPERTY_TRANSFORM

public static final String PROPERTY_TRANSFORM
See Also:
Constant Field Values

bean

protected org.mc4j.ems.connection.bean.EmsBean bean
Deprecated. do not use this - use getEmsBean() instead

resourceContext

protected ResourceContext<T extends JMXComponent> resourceContext
Deprecated. do not use this - use getResourceContext() instead
Constructor Detail

MBeanResourceComponent

public MBeanResourceComponent()
Method Detail

start

public void start(ResourceContext<T> context)
Stores the context and loads the MBean.

Specified by:
start in interface ResourceComponent<T extends JMXComponent>
See Also:
ResourceComponent.start(ResourceContext)

stop

public void stop()
Cleans the old resource context and the old MBean.

Specified by:
stop in interface ResourceComponent<T extends JMXComponent>
See Also:
ResourceComponent.stop()

getEmsBean

public org.mc4j.ems.connection.bean.EmsBean getEmsBean()
Gets the loaded MBean. This will attempt to load the bean if it is not yet loaded. This might still return null if the MBean could not be loaded.

Returns:
the loaded MBean
Throws:
IllegalStateException - if it could not be loaded
See Also:
loadBean()

setEmsBean

protected void setEmsBean(org.mc4j.ems.connection.bean.EmsBean bean)
Sets the MBean that this component considers loaded.

Parameters:
bean - the new MBean representing the component resource

getResourceContext

public ResourceContext<T> getResourceContext()

setResourceContext

protected void setResourceContext(ResourceContext<T> resourceContext)

loadBean

protected org.mc4j.ems.connection.bean.EmsBean loadBean()
Loads the MBean in a default way. This default mechanism is to look in the plugin configuration for a key of OBJECT_NAME_PROP and uses that as the object name to load via loadBean(String). Subclasses are free to override this method in order to provide its own default loading mechanism.

Returns:
the bean that is loaded

loadBean

protected org.mc4j.ems.connection.bean.EmsBean loadBean(String objectName)
Loads the bean with the given object name. Subclasses are free to override this method in order to load the bean.

Parameters:
objectName - the name of the bean to load
Returns:
the bean that is loaded

getAvailability

public AvailabilityType getAvailability()
Is this service alive?

Specified by:
getAvailability in interface AvailabilityFacet
Returns:
true if the service is running

getValues

public void getValues(MeasurementReport report,
                      Set<MeasurementScheduleRequest> requests)
Specified by:
getValues in interface MeasurementFacet

getValues

protected void getValues(MeasurementReport report,
                         Set<MeasurementScheduleRequest> requests,
                         org.mc4j.ems.connection.bean.EmsBean bean)
Can be called from sub-classes to collect metrics on a bean other than the default bean for this resource Supports {a.b} syntax for reading the b Java Bean property from the object value returned from the a jmx property. For example,

Parameters:
report -
requests -
bean - the EmsBean on which to collect the metrics

transformBeanName

protected String transformBeanName(String beanTemplate)

getBeanProperties

protected void getBeanProperties(MeasurementReport report,
                                 org.mc4j.ems.connection.bean.EmsBean thisBean,
                                 Set<MeasurementScheduleRequest> requests)

lookupAttributeProperty

protected Object lookupAttributeProperty(Object value,
                                         String property)

getAttributeName

protected String getAttributeName(String property)

getAttributeProperty

protected String getAttributeProperty(String property)

loadResourceConfiguration

public Configuration loadResourceConfiguration()
This default setup of configuration properties can map to mbean attributes

Specified by:
loadResourceConfiguration in interface ConfigurationFacet
Returns:
the configuration of the component

updateResourceConfiguration

public void updateResourceConfiguration(ConfigurationUpdateReport report)
Equivalent to updateResourceConfiguration(report, false);

Specified by:
updateResourceConfiguration in interface ConfigurationFacet

updateResourceConfiguration

public void updateResourceConfiguration(ConfigurationUpdateReport report,
                                        boolean ignoreReadOnly)

getEmsConnection

public org.mc4j.ems.connection.EmsConnection getEmsConnection()
Specified by:
getEmsConnection in interface JMXComponent<T extends JMXComponent>

invokeOperation

public OperationResult invokeOperation(String name,
                                       Configuration parameters)
                                throws Exception
Specified by:
invokeOperation in interface OperationFacet
Throws:
Exception

invokeOperation

public OperationResult invokeOperation(String name,
                                       Configuration parameters,
                                       org.mc4j.ems.connection.bean.EmsBean emsBean)
                                throws Exception
Throws:
Exception


Copyright © 2008-2011 Red Hat, Inc.. All Rights Reserved.