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

JndiInjectHandler

public class JndiInjectHandler extends Object implements InjectionHandler
Searches bean class for all @Inject and create Injectors
author
Bill Burke
version
$Revision: 60233 $

Fields Summary
private static final Logger
log
Constructors Summary
Methods Summary
public voidhandleClassAnnotations(java.lang.Class clazz, InjectionContainer container)

      // complete
   
public voidhandleFieldAnnotations(java.lang.reflect.Field field, InjectionContainer container, java.util.Map injectors)

      JndiInject ref = field.getAnnotation(JndiInject.class);
      if (ref != null)
      {
         String encName = InjectionUtil.getEncName(field);
         if (!container.getEncInjectors().containsKey(encName))
         {
            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.jndiName(), "@JndiInject"));
         }
         injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
      }
   
public voidhandleMethodAnnotations(java.lang.reflect.Method method, InjectionContainer container, java.util.Map injectors)

      JndiInject ref = method.getAnnotation(JndiInject.class);
      if (ref != null)
      {
         if (!method.getName().startsWith("set"))
            throw new RuntimeException("@EJB can only be used with a set method: " + method);
         String encName = InjectionUtil.getEncName(method);
         if (!container.getEncInjectors().containsKey(encName))
         {
            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.jndiName(), "@JndiInject"));
         }
         injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
      }
   
public voidloadXml(org.jboss.metamodel.descriptor.EnvironmentRefGroup xml, InjectionContainer container)

   
        
   
      if (xml == null) return;
      if (xml.getJndiRefs() == null) return;
      for (JndiRef ref : xml.getJndiRefs())
      {
         if (ref.getMappedName() == null || ref.getMappedName().equals(""))
            throw new RuntimeException("mapped-name is required for " + ref.getJndiRefName() + " of container " + container.getIdentifier());

         String encName = "env/" + ref.getJndiRefName();
         if (!container.getEncInjectors().containsKey(encName))
         {
            container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.getMappedName(), "jndi ref"));
         }
         InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
      }