org.picocontainer.gems.jmx
Class JMXExposed<T>

java.lang.Object
  extended by org.picocontainer.behaviors.AbstractBehavior<T>
      extended by org.picocontainer.gems.jmx.JMXExposed<T>
All Implemented Interfaces:
Serializable, Behavior<T>, ComponentAdapter<T>, ComponentLifecycle<T>, ComponentMonitorStrategy, LifecycleStrategy

public class JMXExposed<T>
extends AbstractBehavior<T>

ComponentAdapter that is exposing a component as MBean in a MBeanServer.

Author:
Jörg Schaible
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter
ComponentAdapter.NOTHING
 
Field Summary
 
Fields inherited from class org.picocontainer.behaviors.AbstractBehavior
delegate
 
Constructor Summary
JMXExposed(ComponentAdapter<T> delegate, MBeanServer mBeanServer)
          Construct a JMXExposed behaviour.
JMXExposed(ComponentAdapter<T> delegate, MBeanServer mBeanServer, DynamicMBeanProvider[] providers)
          Construct a JMXExposed behaviour
 
Method Summary
 void dispose(Object component)
           
 T getComponentInstance(PicoContainer container, Type into)
          Retrieve the component instance.
 String getDescriptor()
           
 boolean hasLifecycle(Class<?> type)
           
 
Methods inherited from class org.picocontainer.behaviors.AbstractBehavior
accept, changeMonitor, componentHasLifecycle, currentMonitor, dispose, findAdapterOfType, getComponentImplementation, getComponentInstance, getComponentKey, getDelegate, isLazy, isStarted, start, start, stop, stop, toString, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JMXExposed

public JMXExposed(ComponentAdapter<T> delegate,
                  MBeanServer mBeanServer,
                  DynamicMBeanProvider[] providers)
           throws NullPointerException
Construct a JMXExposed behaviour

Parameters:
delegate - The delegated ComponentAdapter.
mBeanServer - The MBeanServer used for registering the MBean.
providers - An array with providers for converting the component instance into a DynamicMBean.
Throws:
NullPointerException - Thrown if the MBeanServer or the array with the DynamicMBeanProvider instances is null.

JMXExposed

public JMXExposed(ComponentAdapter<T> delegate,
                  MBeanServer mBeanServer)
           throws NullPointerException
Construct a JMXExposed behaviour. This instance uses a DynamicMBeanComponentProvider as default to register any component instance in the MBeanServer, that is already a DynamicMBean.

Parameters:
delegate - The delegated ComponentAdapter.
mBeanServer - The MBeanServer used for registering the MBean.
Throws:
NullPointerException - Thrown if the MBeanServer or the array with the DynamicMBeanProvider instances is null.
Method Detail

getComponentInstance

public T getComponentInstance(PicoContainer container,
                              Type into)
                       throws PicoCompositionException
Retrieve the component instance. The implementation will automatically register it in the MBeanServer, if a provider can return a DynamicMBean for it.

Note, that you will have to wrap this ComponentAdapter with a Cached to avoid the registration of the same component again.

Specified by:
getComponentInstance in interface ComponentAdapter<T>
Overrides:
getComponentInstance in class AbstractBehavior<T>
Throws:
PicoCompositionException - Thrown by the delegate or if the registering of the DynamicMBean in the MBeanServer fails.
See Also:
AbstractBehavior#getComponentInstance(org.picocontainer.PicoContainer, java.lang.Class)

getDescriptor

public String getDescriptor()

dispose

public void dispose(Object component)
Specified by:
dispose in interface LifecycleStrategy
Overrides:
dispose in class AbstractBehavior<T>

hasLifecycle

public boolean hasLifecycle(Class<?> type)
Specified by:
hasLifecycle in interface LifecycleStrategy
Overrides:
hasLifecycle in class AbstractBehavior<T>


Copyright © 2003-2010 Codehaus. All Rights Reserved.