Package groovy.jmx

# Class GroovyMBean

java.lang.Object
groovy.lang.GroovyObjectSupport
groovy.jmx.GroovyMBean

All Implemented Interfaces:
  `GroovyObject`

public class GroovyMBean extends GroovyObjectSupport
A GroovyObject facade for an underlying MBean which acts like a normal groovy object but which is actually implemented via an underlying JMX MBean. Properties and normal method invocations delegate to the MBeanServer to the actual MBean.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GroovyMBean(MBeanServerConnection server, String objectName)`
  Creates a facade for the named MBean.
  `GroovyMBean(MBeanServerConnection server, String objectName, boolean ignoreErrors)`
  Creates a facade for the named MBean.
  `GroovyMBean(MBeanServerConnection server, ObjectName name)`
  Creates a facade for the named MBean.
  `GroovyMBean(MBeanServerConnection server, ObjectName name, boolean ignoreErrors)`
  Creates a facade for the named MBean.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected String`
  `createOperationKey(String operation, int params)`
  Construct a simple key based on the method name and the number of parameters
  `protected String[]`
  `createSignature(MBeanOperationInfo info)`
  Builds the signature array for an operation.
  `String`
  `describeAttribute(String attributeName)`
  Description of the specified attribute name.
  `protected String`
  `describeAttribute(MBeanAttributeInfo attr)`
  Description of the specified attribute name.
  `List<String>`
  `describeOperation(String operationName)`
  Get the description of the specified operation.
  `protected String`
  `describeOperation(MBeanOperationInfo operation)`
  Description of the operation.
  `Object`
  `getProperty(String property)`
  Reads an attribute from the wrapped MBean.
  `MBeanInfo`
  `info()`
  Returns cached metadata for the wrapped MBean.
  `Object`
  `invokeMethod(String method, Object arguments)`
  Invokes an operation on the wrapped MBean.
  `Collection<String>`
  `listAttributeDescriptions()`
  List of string representations of all the attributes on the MBean.
  `Collection<String>`
  `listAttributeNames()`
  List of the names of each of the attributes on the MBean
  `List<String>`
  `listAttributeValues()`
  The values of each of the attributes on the MBean
  `Collection<String>`
  `listOperationDescriptions()`
  Description of all the operations available on the MBean.
  `Collection<String>`
  `listOperationNames()`
  Names of all the operations available on the MBean.
  `ObjectName`
  `name()`
  Returns the object name of the wrapped MBean.
  `MBeanServerConnection`
  `server()`
  Returns the backing server connection.
  `void`
  `setProperty(String property, Object value)`
  Writes an attribute on the wrapped MBean.
  `String`
  `toString()`
  Return an end user readable representation of the underlying MBean

  ### Methods inherited from class groovy.lang.GroovyObjectSupport

  `getMetaClass, setMetaClass`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### GroovyMBean

    public GroovyMBean(MBeanServerConnection server, String objectName) throws JMException, IOException
    Creates a facade for the named MBean.
    Parameters:
      `server` - the server connection to use
      `objectName` - the name of the target MBean
    Throws:
      `JMException` - if the MBean name is invalid or metadata cannot be read
      `IOException` - if the server connection fails

  - ### GroovyMBean

    public GroovyMBean(MBeanServerConnection server, String objectName, boolean ignoreErrors) throws JMException, IOException
    Creates a facade for the named MBean.
    Parameters:
      `server` - the server connection to use
      `objectName` - the name of the target MBean
      `ignoreErrors` - whether access errors should be ignored
    Throws:
      `JMException` - if the MBean name is invalid or metadata cannot be read
      `IOException` - if the server connection fails

  - ### GroovyMBean

    public GroovyMBean(MBeanServerConnection server, ObjectName name) throws JMException, IOException
    Creates a facade for the named MBean.
    Parameters:
      `server` - the server connection to use
      `name` - the object name of the target MBean
    Throws:
      `JMException` - if metadata cannot be read
      `IOException` - if the server connection fails

  - ### GroovyMBean

    public GroovyMBean(MBeanServerConnection server, ObjectName name, boolean ignoreErrors) throws JMException, IOException
    Creates a facade for the named MBean.
    Parameters:
      `server` - the server connection to use
      `name` - the object name of the target MBean
      `ignoreErrors` - whether access errors should be ignored
    Throws:
      `JMException` - if metadata cannot be read
      `IOException` - if the server connection fails

- ## Method Details

  - ### server

    public MBeanServerConnection server()
    Returns the backing server connection.
    Returns:
      the server connection

  - ### name

    public ObjectName name()
    Returns the object name of the wrapped MBean.
    Returns:
      the MBean name

  - ### info

    public MBeanInfo info()
    Returns cached metadata for the wrapped MBean.
    Returns:
      the MBean metadata

  - ### getProperty

    public Object getProperty(String property)
    Reads an attribute from the wrapped MBean.
    Parameters:
      `property` - the attribute name
    Returns:
      the attribute value

  - ### setProperty

    public void setProperty(String property, Object value)
    Writes an attribute on the wrapped MBean.
    Parameters:
      `property` - the attribute name
      `value` - the new attribute value

  - ### invokeMethod

    public Object invokeMethod(String method, Object arguments)
    Invokes an operation on the wrapped MBean.
    Parameters:
      `method` - the operation name
      `arguments` - the operation arguments
    Returns:
      the invocation result

  - ### createSignature

    protected String[] createSignature(MBeanOperationInfo info)
    Builds the signature array for an operation.
    Parameters:
      `info` - the operation metadata
    Returns:
      the operation signature

  - ### createOperationKey

    protected String createOperationKey(String operation, int params)
    Construct a simple key based on the method name and the number of parameters
    Parameters:
      `operation` - - the mbean operation name
      `params` - - the number of parameters the operation supports
    Returns:
      simple unique identifier for a method

  - ### listAttributeNames

    public Collection<String> listAttributeNames()
    List of the names of each of the attributes on the MBean
    Returns:
      list of attribute names

  - ### listAttributeValues

    public List<String> listAttributeValues()
    The values of each of the attributes on the MBean
    Returns:
      list of values of each attribute

  - ### listAttributeDescriptions

    public Collection<String> listAttributeDescriptions()
    List of string representations of all the attributes on the MBean.
    Returns:
      list of descriptions of each attribute on the mbean

  - ### describeAttribute

    protected String describeAttribute(MBeanAttributeInfo attr)
    Description of the specified attribute name.
    Parameters:
      `attr` - - the attribute
    Returns:
      String the description

  - ### describeAttribute

    public String describeAttribute(String attributeName)
    Description of the specified attribute name.
    Parameters:
      `attributeName` - - stringified name of the attribute
    Returns:
      the description

  - ### listOperationNames

    public Collection<String> listOperationNames()
    Names of all the operations available on the MBean.
    Returns:
      all the operations on the MBean

  - ### listOperationDescriptions

    public Collection<String> listOperationDescriptions()
    Description of all the operations available on the MBean.
    Returns:
      full description of each operation on the MBean

  - ### describeOperation

    public List<String> describeOperation(String operationName)
    Get the description of the specified operation. This returns a Collection since operations can be overloaded and one operationName can have multiple forms.
    Parameters:
      `operationName` - the name of the operation to describe
    Returns:
      Collection of operation description

  - ### describeOperation

    protected String describeOperation(MBeanOperationInfo operation)
    Description of the operation.
    Parameters:
      `operation` - the operation to describe
    Returns:
      pretty-printed description

  - ### toString

    public String toString()
    Return an end user readable representation of the underlying MBean
    Overrides:
      `toString` in class `Object`
    Returns:
      the user readable description