org.jboss.system.microcontainer
Class ServiceProxy

java.lang.Object
  extended by org.jboss.system.microcontainer.ServiceProxy
All Implemented Interfaces:
InvocationHandler

public class ServiceProxy
extends Object
implements InvocationHandler

An implementation of InvocationHandler used to proxy of the Service interface for mbeans. It determines which of the start/stop methods of the Service interface an mbean implements by inspecting its MBeanOperationInfo values. Each Service interface method that has a matching operation is forwarded to the mbean by invoking the method through the MBeanServer object.

This class is based on the old ServiceConfigurator

Version:
$Revision: 85945 $
Author:
Marc Fleury, Hiram Chirino, David Jencks, Jason Dillon, Dimitris Andreadis, Adrian Brock

Constructor Summary
ServiceProxy(ObjectName objectName, MBeanServer server, MBeanOperationInfo[] opInfo)
          Go through the opInfo array and for each operation that matches on of the Service interface methods set the corresponding hasOp array value to true.
 
Method Summary
static Service getServiceProxy(ObjectName objectName, MBeanServer server)
          Get the Service interface through which the mbean given by objectName will be managed.
static Service getServiceProxy(ObjectName objectName, MBeanServer server, boolean includeLifecycle)
          Get the Service interface through which the mbean given by objectName will be managed.
 Object invoke(Object proxy, Method method, Object[] args)
          Map the method name to a Service interface method index and if the corresponding hasOp array element is true, dispatch the method to the mbean we are proxying.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServiceProxy

public ServiceProxy(ObjectName objectName,
                    MBeanServer server,
                    MBeanOperationInfo[] opInfo)
Go through the opInfo array and for each operation that matches on of the Service interface methods set the corresponding hasOp array value to true.

Parameters:
objectName - the object name
server - the mbean server
opInfo - the MBean operation info
Method Detail

getServiceProxy

public static Service getServiceProxy(ObjectName objectName,
                                      MBeanServer server)
                               throws Exception
Get the Service interface through which the mbean given by objectName will be managed.

Parameters:
objectName - the object name
server - the mbean server
Returns:
The Service value
Throws:
Exception - for any error

getServiceProxy

public static Service getServiceProxy(ObjectName objectName,
                                      MBeanServer server,
                                      boolean includeLifecycle)
                               throws Exception
Get the Service interface through which the mbean given by objectName will be managed.

Parameters:
objectName - the object name
server - the mbean server
includeLifecycle - include lifecycle
Returns:
The Service value
Throws:
Exception - for any error

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Map the method name to a Service interface method index and if the corresponding hasOp array element is true, dispatch the method to the mbean we are proxying.

Specified by:
invoke in interface InvocationHandler
Parameters:
proxy -
method -
args -
Returns:
Always null.
Throws:
Throwable


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.