FileDocCategorySizeDatePackage
DependsMethodInjector.javaAPI DocJBoss 4.2.12543Fri Jul 13 20:53:46 BST 2007org.jboss.injection

DependsMethodInjector

public class DependsMethodInjector extends Object implements Injector
author
Kabir Khan
version
$Revision: 60233 $

Fields Summary
Method
method
ObjectName
on
Constructors Summary
public DependsMethodInjector(Method method, ObjectName on)

      this.method = method;
      this.on = on;
      method.setAccessible(true);
   
Methods Summary
public java.lang.ClassgetInjectionClass()

      return method.getParameterTypes()[0];
   
public voidinject(org.jboss.ejb3.BeanContext ctx)

      Object instance = ctx.getInstance();
      inject(instance);
   
public voidinject(java.lang.Object instance)

      Class clazz = method.getParameterTypes()[0];
      Object value = null;

      if (clazz == ObjectName.class)
      {
         value = on;
      }
      else
      {
         MBeanServer server = (MBeanServer) MBeanServerFactory.findMBeanServer(null).get(0);
         value = MBeanProxyExt.create(clazz, on, server);
      }

      try
      {
         method.invoke(instance, value);
      }
      catch (InvocationTargetException e)
      {
         throw new RuntimeException(e);
      }
      catch (IllegalAccessException e)
      {
         throw new RuntimeException(e);
      }