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

JndiPropertyInjector

public class JndiPropertyInjector extends AbstractPropertyInjector implements PojoInjector
Injects a jndi dependency into a bean property.
author
Bill Burke
author
Carlo de Wolf
version
$Revision: $

Fields Summary
private static final Logger
log
private String
jndiName
private Context
ctx
Constructors Summary
public JndiPropertyInjector(org.jboss.injection.lang.reflect.BeanProperty property, String jndiName, Context ctx)


         
   
      super(property);
      this.jndiName = jndiName;
      this.ctx = ctx;
   
Methods Summary
public java.lang.ClassgetInjectionClass()

      return property.getType();
   
public voidinject(org.jboss.ejb3.BeanContext bctx)

      inject(bctx, bctx.getInstance());
   
public voidinject(org.jboss.ejb3.BeanContext bctx, java.lang.Object instance)

      inject(instance);
   
public voidinject(java.lang.Object instance)

      Object value = lookup(jndiName);
      property.set(instance, value);
   
protected java.lang.Objectlookup(java.lang.String jndiName)

      Object dependency = null;
      
      try
      {
         dependency = ctx.lookup(jndiName);
      }
      catch (NamingException e)
      {
         Throwable cause = e;
         while(cause.getCause() != null)
            cause = cause.getCause();
         throw new RuntimeException("Unable to inject jndi dependency: " + jndiName + " into property " + property + ": " + cause.getMessage(), e);
      }
      return dependency;