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

DependsFieldInjector

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

Fields Summary
Field
field
ObjectName
on
Constructors Summary
public DependsFieldInjector(Field field, ObjectName on)

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

      return field.getType();
   
public voidinject(org.jboss.ejb3.BeanContext ctx)

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

      Class clazz = field.getType();
      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
      {
         field.set(instance, value);
      }
      catch (IllegalAccessException e)
      {
         throw new RuntimeException(e);
      }