Package groovy.jmx.builder

# Class JmxBuilderModelMBean

java.lang.Object
javax.management.modelmbean.RequiredModelMBean
groovy.jmx.builder.JmxBuilderModelMBean

All Implemented Interfaces:
  `EventListener`, `DynamicMBean`, `MBeanRegistration`, `ModelMBean`, `ModelMBeanNotificationBroadcaster`, `NotificationBroadcaster`, `NotificationEmitter`, `NotificationListener`, `PersistentMBean`

public class JmxBuilderModelMBean extends RequiredModelMBean implements NotificationListener
The JmxBuilderModelMBean is the MBean class that proxies exported POGO/POJO inside the MBeanServer. When JmxBuilder exports an object instance, an instance of this class is created and exported inside the MBeanServer.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JmxBuilderModelMBean()`
  Creates an empty model MBean.
  `JmxBuilderModelMBean(Object objectRef)`
  Creates a model MBean for the supplied managed resource.
  `JmxBuilderModelMBean(ModelMBeanInfo mbi)`
  Creates a model MBean backed by the supplied metadata.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addEventListeners(MBeanServer server, Map<String,Map<String,Object>> descriptor)`
  Sets up event listeners for this MBean as described in the descriptor.
  `void`
  `addOperationCallListeners(Map<String,Map<String,Map<String,Object>>> descriptor)`
  Registers listeners for operation calls (i.e.
  `void`
  `handleNotification(Notification note, Object handback)`
  Handles notifications received by this model MBean.
  `Object`
  `invoke(String opName, Object[] opArgs, String[] signature)`
  Invokes the named operation and emits any configured call notifications.
  `void`
  `setManagedResource(Object obj)`
  Updates the managed resource exposed by this model MBean.

  ### Methods inherited from class javax.management.modelmbean.RequiredModelMBean

  `addAttributeChangeNotificationListener, addNotificationListener, getAttribute, getAttributes, getClassLoaderRepository, getMBeanInfo, getNotificationInfo, load, postDeregister, postRegister, preDeregister, preRegister, removeAttributeChangeNotificationListener, removeNotificationListener, removeNotificationListener, sendAttributeChangeNotification, sendAttributeChangeNotification, sendNotification, sendNotification, setAttribute, setAttributes, setManagedResource, setModelMBeanInfo, store`

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

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

- ## Constructor Details

  - ### JmxBuilderModelMBean

    public JmxBuilderModelMBean(Object objectRef) throws MBeanException, RuntimeOperationsException, InstanceNotFoundException, InvalidTargetObjectTypeException
    Creates a model MBean for the supplied managed resource.
    Parameters:
      `objectRef` - the resource to expose
    Throws:
      `MBeanException` - if the resource cannot be registered
      `RuntimeOperationsException` - if the supplied resource is invalid
      `InstanceNotFoundException` - if the resource cannot be found
      `InvalidTargetObjectTypeException` - if the resource type is unsupported

  - ### JmxBuilderModelMBean

    public JmxBuilderModelMBean() throws MBeanException, RuntimeOperationsException
    Creates an empty model MBean.
    Throws:
      `MBeanException` - if initialization fails
      `RuntimeOperationsException` - if the MBean cannot be initialized

  - ### JmxBuilderModelMBean

    public JmxBuilderModelMBean(ModelMBeanInfo mbi) throws MBeanException, RuntimeOperationsException
    Creates a model MBean backed by the supplied metadata.
    Parameters:
      `mbi` - the model MBean metadata
    Throws:
      `MBeanException` - if initialization fails
      `RuntimeOperationsException` - if the MBean cannot be initialized

- ## Method Details

  - ### setManagedResource

    public void setManagedResource(Object obj)
    Updates the managed resource exposed by this model MBean.
    Parameters:
      `obj` - the resource to expose

  - ### addOperationCallListeners

    public void addOperationCallListeners(Map<String,Map<String,Map<String,Object>>> descriptor)
    Registers listeners for operation calls (i.e. method, getter, and setter calls) when invoked on this bean from the MBeanServer. Descriptor should contain a map with layout `item -> [Map[methodListener:[target:"", tpe:"", callback:&Closure], ... ,]]`
    Parameters:
      `descriptor` - MetaMap descriptor containing description of operation call listeners

  - ### addEventListeners

    public void addEventListeners(MBeanServer server, Map<String,Map<String,Object>> descriptor)
    Sets up event listeners for this MBean as described in the descriptor. The descriptor contains a map with layout {item -> Map[event:"...", from:ObjectName, callback:&Closure],...,}
    Parameters:
      `server` - the MBeanServer is to be registered.
      `descriptor` - a map containing info about the event

  - ### invoke

    public Object invoke(String opName, Object[] opArgs, String[] signature) throws MBeanException, ReflectionException
    Invokes the named operation and emits any configured call notifications.
    Specified by:
      `invoke` in interface `DynamicMBean`
    Overrides:
      `invoke` in class `RequiredModelMBean`
    Parameters:
      `opName` - the operation name
      `opArgs` - the invocation arguments
      `signature` - the argument signature
    Returns:
      the invocation result
    Throws:
      `MBeanException` - if the invocation fails
      `ReflectionException` - if the method cannot be resolved

  - ### handleNotification

    public void handleNotification(Notification note, Object handback)
    Handles notifications received by this model MBean.
    Specified by:
      `handleNotification` in interface `NotificationListener`
    Parameters:
      `note` - the received notification
      `handback` - the handback object supplied at registration time