[Jboss-cvs] JBossAS SVN: r55144 - in trunk/ejb3/src/main/org/jboss: ejb3 ejb3/injection ejb3/interceptor ejb3/service ejb3/stateful ejb3/stateless injection

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Aug 3 19:13:10 EDT 2006


Author: bill.burke at jboss.com
Date: 2006-08-03 19:12:56 -0400 (Thu, 03 Aug 2006)
New Revision: 55144

Removed:
   trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsFieldInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsMethodInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBContextFieldInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBContextMethodInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/EntityManagerFactoryFieldInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/EntityManagerFactoryMethodInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/ExtendedPersistenceContextInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionUtil.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/Injector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiFieldInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiInjectHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiMethodInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/PersistenceContextHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/PersistenceUnitHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/PojoInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/ResourceHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/TimerServiceFieldInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/TimerServiceMethodInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/UserTransactionFieldInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/UserTransactionMethodInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/injection/WebServiceHandler.java
Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java
   trunk/ejb3/src/main/org/jboss/ejb3/BaseContext.java
   trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/Pool.java
   trunk/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsInterceptor.java
   trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInjector.java
   trunk/ejb3/src/main/org/jboss/ejb3/interceptor/LifecycleInterceptorHandler.java
   trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoveInterceptor.java
   trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
   trunk/ejb3/src/main/org/jboss/injection/DependsHandler.java
   trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java
   trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java
   trunk/ejb3/src/main/org/jboss/injection/InjectionUtil.java
   trunk/ejb3/src/main/org/jboss/injection/JndiInjectHandler.java
   trunk/ejb3/src/main/org/jboss/injection/PcEncInjector.java
   trunk/ejb3/src/main/org/jboss/injection/PersistenceContextHandler.java
   trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java
   trunk/ejb3/src/main/org/jboss/injection/PuEncInjector.java
   trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
   trunk/ejb3/src/main/org/jboss/injection/WebServiceHandler.java
Log:
full refactoring of annotation, injection, and XML ENC population so that the code can be reused within the web tier.

Modified: trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/AbstractPool.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -21,7 +21,7 @@
 */
 package org.jboss.ejb3;
 
-import org.jboss.ejb3.injection.Injector;
+import org.jboss.injection.Injector;
 import org.jboss.ejb3.stateful.StatefulBeanContext;
 import org.jboss.logging.Logger;
 import org.jboss.util.id.GUID;
@@ -52,7 +52,7 @@
       this.contextClass = contextClass;
       this.container = container;
    }
-   
+
    public void setMaxSize(int maxSize)
    {
    }
@@ -170,7 +170,6 @@
 
    public void remove(BeanContext ctx)
    {
-      Object bean = ctx.getInstance();
       container.invokePreDestroy(ctx);
       ctx.remove();
    }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/BaseContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/BaseContext.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/BaseContext.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -102,7 +102,6 @@
       {
          HashMap<Class,InterceptorInjector> interceptorInjectors = ((EJBContainer)container).getInterceptorInjectors();
          interceptorInstances = new HashMap<Class, Object>();
-
          for (InterceptorInfo info : interceptors)
          {
             try

Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -27,26 +27,29 @@
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.annotation.AnnotationElement;
 import org.jboss.aop.joinpoint.ConstructorInvocation;
-import org.jboss.ejb3.injection.DependsHandler;
-import org.jboss.ejb3.injection.EJBHandler;
-import org.jboss.ejb3.injection.InjectionContainer;
-import org.jboss.ejb3.injection.Injector;
-import org.jboss.ejb3.injection.JndiInjectHandler;
-import org.jboss.ejb3.injection.PersistenceContextHandler;
-import org.jboss.ejb3.injection.PersistenceUnitHandler;
-import org.jboss.ejb3.injection.ResourceHandler;
-import org.jboss.ejb3.injection.WebServiceHandler;
+import org.jboss.ejb3.entity.PersistenceUnitDeployment;
 import org.jboss.ejb3.interceptor.InterceptorInfo;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
 import org.jboss.ejb3.interceptor.InterceptorInjector;
 import org.jboss.ejb3.interceptor.LifecycleInterceptorHandler;
 import org.jboss.ejb3.metamodel.AssemblyDescriptor;
 import org.jboss.ejb3.metamodel.EnterpriseBean;
-import org.jboss.metamodel.descriptor.PersistenceContextRef;
 import org.jboss.ejb3.security.JaccHelper;
 import org.jboss.ejb3.tx.UserTransactionImpl;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
+import org.jboss.injection.DependsHandler;
+import org.jboss.injection.EJBHandler;
+import org.jboss.injection.EncInjector;
+import org.jboss.injection.InjectionContainer;
+import org.jboss.injection.InjectionHandler;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.injection.Injector;
+import org.jboss.injection.JndiInjectHandler;
+import org.jboss.injection.PersistenceContextHandler;
+import org.jboss.injection.PersistenceUnitHandler;
+import org.jboss.injection.ResourceHandler;
+import org.jboss.injection.WebServiceHandler;
 import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.PersistenceContextRef;
 import org.jboss.naming.Util;
 
 import javax.annotation.PostConstruct;
@@ -63,20 +66,19 @@
 import javax.naming.NamingException;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Annotation;
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Comment
@@ -101,7 +103,8 @@
 
    protected ClassLoader classloader;
 
-   protected Injector[] injectors;
+   // for performance there is an array.
+   protected List<Injector> injectors = new ArrayList<Injector>();
 
    protected Context enc;
    protected Context encEnv;
@@ -113,18 +116,12 @@
 
    protected Hashtable initialContextProperties;
 
-   protected HashMap envEntries = new HashMap();
+   protected Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
 
-   protected HashMap<String, String> encLinkRefEntries = new HashMap<String, String>();
-
-   protected HashMap<String, String> ejbRefDependencies = new HashMap<String, String>();
-   protected HashMap<String, String> puEncXmlEntries = new HashMap<String, String>();
-   protected HashMap<String, PersistenceContextRef> pcEncXmlEntries = new HashMap<String, PersistenceContextRef>();
-
    protected EnterpriseBean xml;
    protected AssemblyDescriptor assembly;
 
-   protected HashMap<AccessibleObject, Injector> encInjections = new HashMap<AccessibleObject, Injector>();
+   protected Map<String, Map<AccessibleObject, Injector>> encInjections = new HashMap<String, Map<AccessibleObject, Injector>>();
 
    protected InterceptorInfoRepository interceptorRepository;
 
@@ -132,14 +129,13 @@
 
    protected LinkedHashSet<InterceptorInfo> applicableInterceptors;
 
-   private HashMap<Class, InterceptorInjector> interceptorInjectors;
+   private HashMap<Class, InterceptorInjector> interceptorInjectors = new HashMap<Class, InterceptorInjector>();
 
    private Ejb3Deployment deployment;
 
    private DependencyPolicy dependencyPolicy;
 
    private String jaccContextId;
-   protected HashMap extendedPCs = new HashMap();
 
    protected HashMap invokedMethod = new HashMap();
 
@@ -160,7 +156,6 @@
                        InterceptorInfoRepository interceptorRepository, Ejb3Deployment deployment)
    {
       super(name, manager);
-      this.xml = xml;
       this.deployment = deployment;
       this.beanClassName = beanClassName;
       this.classloader = cl;
@@ -198,21 +193,12 @@
       this.interceptorRepository.addBeanClass(clazz.getName());
    }
 
-   public HashMap<String, String> getEjbRefDependencies()
+   public List<Injector> getInjectors()
    {
-      return ejbRefDependencies;
+      return injectors;
    }
 
-   public HashMap<String, String> getPuEncXmlEntries()
-   {
-      return puEncXmlEntries;
-   }
 
-   public HashMap<String, PersistenceContextRef> getPcEncXmlEntries()
-   {
-      return pcEncXmlEntries;
-   }
-
    public String getJaccContextId()
    {
       return jaccContextId;
@@ -254,24 +240,46 @@
    public void processMetadata(DependencyPolicy dependencyPolicy)
    {
       this.dependencyPolicy = dependencyPolicy;
-      PersistenceContextHandler.loadDependencies(xml, this, clazz);
-      PersistenceUnitHandler.loadDependencies(xml, this, clazz);
-      if (xml != null)
+      // XML must be done first so that any annotation overrides are initialized
+
+      // todo injection handlers should be pluggable from XML
+      Collection<InjectionHandler> handlers = new ArrayList<InjectionHandler>();
+      handlers.add(new EJBHandler());
+      handlers.add(new DependsHandler());
+      handlers.add(new JndiInjectHandler());
+      handlers.add(new PersistenceContextHandler());
+      handlers.add(new PersistenceUnitHandler());
+      handlers.add(new ResourceHandler());
+      handlers.add(new WebServiceHandler());
+
+      ClassLoader old = Thread.currentThread().getContextClassLoader();
+      Thread.currentThread().setContextClassLoader(classloader);
+      try
       {
-         for (String depends : xml.getDependencies())
+         // EJB container's XML must be processed before interceptor's as it may override interceptor's references
+         for (InjectionHandler handler : handlers) handler.loadXml(xml, this);
+
+         Map<AccessibleObject, Injector> tmp = InjectionUtil.processAnnotations(this, handlers, getBeanClass());
+         injectors.addAll(tmp.values());
+
+         initialiseInterceptors();
+         for (InterceptorInfo interceptorInfo : applicableInterceptors)
          {
-            dependencyPolicy.addDependency(depends);
+            for (InjectionHandler handler : handlers)
+            {
+               handler.loadXml(interceptorInfo.getXml(), this);
+            }
          }
+         for (InterceptorInfo interceptorInfo : applicableInterceptors)
+         {
+            Map<AccessibleObject, Injector> tmpInterceptor = InjectionUtil.processAnnotations(this, handlers, interceptorInfo.getClazz());
+            InterceptorInjector injector = new InterceptorInjector(this, interceptorInfo, tmpInterceptor);
+            interceptorInjectors.put(interceptorInfo.getClazz(), injector);
+         }
       }
-      DependsHandler.loadDependencies(this, clazz);
-      EJBHandler.loadDependencies(xml, this, clazz);
-      initialiseInterceptors();
-      for (InterceptorInfo interceptorInfo : applicableInterceptors)
+      finally
       {
-         PersistenceContextHandler.loadDependencies(interceptorInfo.getXml(), this, interceptorInfo.getClazz());
-         PersistenceUnitHandler.loadDependencies(interceptorInfo.getXml(), this, interceptorInfo.getClazz());
-         DependsHandler.loadDependencies(this, interceptorInfo.getClazz());
-         EJBHandler.loadDependencies(interceptorInfo.getXml(), this, interceptorInfo.getClazz());
+         Thread.currentThread().setContextClassLoader(old);
       }
    }
 
@@ -318,19 +326,15 @@
       return interceptorInjectors;
    }
 
-   public ClassLoader getClassloader()
-   {
-      return classloader;
-   }
 
-   public HashMap<String, String> getEncLinkRefEntries()
+   public Map<String, EncInjector> getEncInjectors()
    {
-      return encLinkRefEntries;
+      return encInjectors;
    }
 
-   public void addEncInjector(AccessibleObject acc, Injector inj)
+   public ClassLoader getClassloader()
    {
-      encInjections.put(acc, inj);
+      return classloader;
    }
 
    public InitialContext getInitialContext()
@@ -348,26 +352,11 @@
       }
    }
 
-   public HashMap<AccessibleObject, Injector> getEncInjections()
+   public Map<String, Map<AccessibleObject, Injector>> getEncInjections()
    {
       return encInjections;
    }
 
-   public boolean hasEnvEntry(String name)
-   {
-      return envEntries.containsKey(name);
-   }
-
-   public void addEnvEntry(String name, String type, String value) throws ClassNotFoundException
-   {
-      envEntries.put(name, getEnvEntryValue(name, type, value));
-   }
-
-   public boolean hasEncEntry(String name)
-   {
-      return encLinkRefEntries.containsKey(name);
-   }
-
    public Context getEnc()
    {
       return enc;
@@ -378,63 +367,6 @@
       return enc;
    }
 
-   protected Object getEnvEntryValue(String name, String entryType, String value) throws ClassNotFoundException
-   {
-      Class type = this.classloader.loadClass(entryType);
-      if (type == String.class)
-      {
-         return value;
-      }
-      else if (type == Integer.class)
-      {
-         return new Integer(value);
-      }
-      else if (type == Long.class)
-      {
-         return new Long(value);
-      }
-      else if (type == Double.class)
-      {
-         return new Double(value);
-      }
-      else if (type == Float.class)
-      {
-         return new Float(value);
-      }
-      else if (type == Byte.class)
-      {
-         return new Byte(value);
-      }
-      else if (type == Character.class)
-      {
-         String input = value;
-         if (input == null || input.length() == 0)
-         {
-            return new Character((char) 0);
-         }
-         else
-         {
-            if (input.length() > 1)
-               // TODO: Add deployment context
-               log.warn("Warning character env-entry is too long: binding="
-                       + name + " value=" + input);
-            return new Character(input.charAt(0));
-         }
-      }
-      else if (type == Short.class)
-      {
-         return new Short(value);
-      }
-      else if (type == Boolean.class)
-      {
-         return new Boolean(value);
-      }
-      else
-      {
-         return value;
-      }
-   }
-
    public Hashtable getInitialContextProperties()
    {
       return initialContextProperties;
@@ -519,34 +451,22 @@
             break;
          }
       }
-      createEnvEntries();
       initializePool();
-      resolveInterceptorInjectors();
 
-      // add extendedPC injectors to be first in list
-      ArrayList injectors2 = new ArrayList();
-      injectors2.addAll(extendedPCs.values());
-      if (injectors != null) injectors2.addAll(Arrays.asList(injectors));
-      injectors = (Injector[]) injectors2.toArray(new Injector[injectors2.size()]);
-      if (pool != null) pool.setInjectors(injectors);
+      for (EncInjector injector : encInjectors.values())
+      {
+         injector.inject(this);   
+      }
 
+      // creating of injector array should come after injection into ENC as an ENC injector
+      // may add additional injectors into the injector list.  An example is an extended persistence
+      // context which mush be created and added to the SFSB bean context.
+
+      Injector[] injectors2 = injectors.toArray(new Injector[injectors.size()]);
+      if (pool != null) pool.setInjectors(injectors2);
+
       createCallbackHandler();
 
-      for (String encName : encLinkRefEntries.keySet())
-      {
-         String mappedName = encLinkRefEntries.get(encName);
-         try
-         {
-            Util.bind(enc, encName, new LinkRef(mappedName));
-            log.debug("binding enc: " + encName + " to " + mappedName);
-         }
-         catch (NamingException e)
-         {
-            NamingException namingException = new NamingException("Could not bind EJB container with ejb name " + ejbName + " into JNDI under jndiName: " + enc.getNameInNamespace() + "/" + encName);
-            namingException.setRootCause(e);
-            throw namingException;
-         }
-      }
       JaccHelper.configureContainer(jaccContextId, this);
       log.info("STARTED EJB: " + clazz.getName() + " ejbName: " + ejbName);
    }
@@ -559,29 +479,6 @@
    {
    }
 
-   protected void createEnvEntries() throws NamingException
-   {
-      Iterator names = envEntries.keySet().iterator();
-      while (names.hasNext())
-      {
-         String name = (String) names.next();
-         Object value = envEntries.get(name);
-
-         try
-         {
-            Util.bind(encEnv,
-                    name,
-                    value);
-         }
-         catch (NamingException e)
-         {
-            NamingException namingException = new NamingException("Could not bind env entry for ejb name " + ejbName + " into JNDI under jndiName: " + encEnv.getNameInNamespace() + "/" + name);
-            namingException.setRootCause(e);
-            throw namingException;
-         }
-      }
-   }
-
    public void initializePool() throws Exception
    {
       PoolClass poolClass = (PoolClass) resolveAnnotation(PoolClass.class);
@@ -592,7 +489,7 @@
       pool.initialize(this, beanContextClass, clazz, maxSize, timeout);
 
       resolveInjectors();
-      pool.setInjectors(injectors);
+      pool.setInjectors(injectors.toArray(new Injector[injectors.size()]));
    }
 
    public void invokePostConstruct(BeanContext beanContext)
@@ -630,11 +527,6 @@
 
    public static final String ENTITY_MANAGER_FACTORY = "EntityManagerFactory";
 
-   public HashMap getExtendedPCs()
-   {
-      return extendedPCs;
-   }
-
    protected void resolveInjectors() throws Exception
    {
       ThreadLocalENCFactory.push(enc);
@@ -651,17 +543,6 @@
             namingException.setRootCause(e);
             throw namingException;
          }
-
-         List list = new ArrayList();
-         PersistenceContextHandler.loadInjectors(this);
-         PersistenceUnitHandler.loadInjectors(this);
-         list.addAll(JndiInjectHandler.loadInjectors(this));
-         ResourceHandler.loadInjectors(this);
-         WebServiceHandler.loadInjectors(this);
-         EJBHandler.loadInjectors(this);
-         list.addAll(DependsHandler.loadInjectors(this));
-         list.addAll(encInjections.values());
-         injectors = (Injector[]) list.toArray(new Injector[list.size()]);
       }
       finally
       {
@@ -669,28 +550,6 @@
       }
    }
 
-   protected void resolveInterceptorInjectors() throws Exception
-   {
-      ThreadLocalENCFactory.push(enc);
-      try
-      {
-         Thread.currentThread().setContextClassLoader(classloader);
-         if (applicableInterceptors != null && applicableInterceptors.size() > 0)
-         {
-            interceptorInjectors = new HashMap<Class, InterceptorInjector>();
-            for (InterceptorInfo interceptorInfo : applicableInterceptors)
-            {
-               InterceptorInjector injector = new InterceptorInjector(this, interceptorInfo);
-               interceptorInjectors.put(interceptorInfo.getClazz(), injector);
-            }
-         }
-      }
-      finally
-      {
-         ThreadLocalENCFactory.pop();
-      }
-   }
-
    protected void createCallbackHandler()
    {
       try
@@ -900,7 +759,7 @@
          return (T) resolveAnnotation(method, annotationType);
       }
       Class aclass = annotationType;
-      return (T)method.getAnnotation(aclass);
+      return (T) method.getAnnotation(aclass);
    }
 
    public <T> T getAnnotation(Class<T> annotationType, Class clazz, Field field)
@@ -910,7 +769,7 @@
          return (T) resolveAnnotation(field, annotationType);
       }
       Class aclass = annotationType;
-      return (T)field.getAnnotation(aclass);
+      return (T) field.getAnnotation(aclass);
    }
 
    public String getIdentifier()

Modified: trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Ejb3DescriptorHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -21,43 +21,47 @@
  */
 package org.jboss.ejb3;
 
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.StringTokenizer;
-import javax.annotation.security.DenyAll;
-import javax.annotation.security.PermitAll;
-import javax.annotation.security.RolesAllowed;
-import javax.annotation.security.DeclareRoles;
-import javax.annotation.PostConstruct;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.ExcludeClassInterceptors;
-import javax.interceptor.ExcludeDefaultInterceptors;
-import javax.ejb.Init;
-import javax.interceptor.Interceptors;
-import javax.ejb.Local;
-import javax.ejb.LocalHome;
-import javax.ejb.MessageDriven;
-import javax.ejb.PostActivate;
-import javax.annotation.PreDestroy;
-import javax.ejb.PrePassivate;
-import javax.ejb.Remote;
-import javax.ejb.RemoteHome;
-import javax.ejb.Remove;
-import javax.ejb.Stateless;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.ejb.TransactionManagement;
-
 import javassist.bytecode.ClassFile;
-import org.jboss.annotation.*;
-import org.jboss.annotation.ejb.*;
-import org.jboss.annotation.ejb.cache.*;
+import org.jboss.annotation.IgnoreDependency;
+import org.jboss.annotation.IgnoreDependencyImpl;
+import org.jboss.annotation.ejb.Clustered;
+import org.jboss.annotation.ejb.ClusteredImpl;
+import org.jboss.annotation.ejb.Consumer;
+import org.jboss.annotation.ejb.ConsumerImpl;
+import org.jboss.annotation.ejb.CurrentMessage;
+import org.jboss.annotation.ejb.CurrentMessageImpl;
+import org.jboss.annotation.ejb.DefaultActivationSpecs;
+import org.jboss.annotation.ejb.DefaultActivationSpecsImpl;
+import org.jboss.annotation.ejb.DeliveryMode;
+import org.jboss.annotation.ejb.Depends;
+import org.jboss.annotation.ejb.DependsImpl;
+import org.jboss.annotation.ejb.ExcludeClassInterceptorsImpl;
+import org.jboss.annotation.ejb.ExcludeDefaultInterceptorsImpl;
+import org.jboss.annotation.ejb.LocalBinding;
+import org.jboss.annotation.ejb.LocalBindingImpl;
+import org.jboss.annotation.ejb.LocalHomeImpl;
+import org.jboss.annotation.ejb.Management;
+import org.jboss.annotation.ejb.ManagementImpl;
+import org.jboss.annotation.ejb.MessageProperties;
+import org.jboss.annotation.ejb.MessagePropertiesImpl;
+import org.jboss.annotation.ejb.PoolClass;
+import org.jboss.annotation.ejb.PoolClassImpl;
+import org.jboss.annotation.ejb.Producers;
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.annotation.ejb.RemoteBindingImpl;
+import org.jboss.annotation.ejb.RemoteBindings;
+import org.jboss.annotation.ejb.RemoteBindingsImpl;
+import org.jboss.annotation.ejb.RemoteHomeImpl;
+import org.jboss.annotation.ejb.ResourceAdapter;
+import org.jboss.annotation.ejb.ResourceAdapterImpl;
+import org.jboss.annotation.ejb.SerializedConcurrentAccess;
+import org.jboss.annotation.ejb.SerializedConcurrentAccessImpl;
+import org.jboss.annotation.ejb.Service;
+import org.jboss.annotation.ejb.ServiceImpl;
+import org.jboss.annotation.ejb.TransactionTimeout;
+import org.jboss.annotation.ejb.TransactionTimeoutImpl;
+import org.jboss.annotation.ejb.cache.Cache;
+import org.jboss.annotation.ejb.cache.CacheImpl;
 import org.jboss.annotation.ejb.cache.simple.PersistenceManager;
 import org.jboss.annotation.ejb.cache.simple.PersistenceManagerImpl;
 import org.jboss.annotation.internal.DefaultInterceptorMarker;
@@ -68,6 +72,7 @@
 import org.jboss.aop.annotation.AnnotationRepository;
 import org.jboss.ejb.ActivationConfigPropertyImpl;
 import org.jboss.ejb.AroundInvokeImpl;
+import org.jboss.ejb.DeclareRolesImpl;
 import org.jboss.ejb.DenyAllImpl;
 import org.jboss.ejb.InitImpl;
 import org.jboss.ejb.InterceptorsImpl;
@@ -81,11 +86,15 @@
 import org.jboss.ejb.RemoteImpl;
 import org.jboss.ejb.RemoveImpl;
 import org.jboss.ejb.RolesAllowedImpl;
-import org.jboss.ejb.DeclareRolesImpl;
 import org.jboss.ejb.RunAsImpl;
 import org.jboss.ejb.StatelessImpl;
 import org.jboss.ejb.TransactionAttributeImpl;
 import org.jboss.ejb.TransactionManagementImpl;
+import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
+import org.jboss.ejb3.mdb.ConsumerContainer;
+import org.jboss.ejb3.mdb.MDB;
+import org.jboss.ejb3.mdb.ProducerImpl;
+import org.jboss.ejb3.mdb.ProducersImpl;
 import org.jboss.ejb3.metamodel.ActivationConfig;
 import org.jboss.ejb3.metamodel.AssemblyDescriptor;
 import org.jboss.ejb3.metamodel.CacheConfig;
@@ -107,29 +116,47 @@
 import org.jboss.ejb3.metamodel.RemoveMethod;
 import org.jboss.ejb3.metamodel.SecurityIdentity;
 import org.jboss.ejb3.metamodel.SessionEnterpriseBean;
-import org.jboss.ejb3.injection.InjectionUtil;
-import org.jboss.ejb3.injection.Injector;
-import org.jboss.ejb3.injection.JndiFieldInjector;
-import org.jboss.ejb3.injection.JndiMethodInjector;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.ejb3.mdb.ConsumerContainer;
-import org.jboss.ejb3.mdb.MDB;
-import org.jboss.ejb3.mdb.ProducerImpl;
-import org.jboss.ejb3.mdb.ProducersImpl;
 import org.jboss.ejb3.service.ServiceContainer;
 import org.jboss.ejb3.stateful.StatefulContainer;
 import org.jboss.ejb3.stateless.StatelessContainer;
 import org.jboss.logging.Logger;
-
-import org.jboss.metamodel.descriptor.EnvEntry;
 import org.jboss.metamodel.descriptor.InjectionTarget;
 import org.jboss.metamodel.descriptor.MessageDestinationRef;
 import org.jboss.metamodel.descriptor.NameValuePair;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
 import org.jboss.metamodel.descriptor.ResourceRef;
 import org.jboss.metamodel.descriptor.RunAs;
 import org.jboss.metamodel.descriptor.SecurityRole;
 
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.annotation.security.DeclareRoles;
+import javax.annotation.security.DenyAll;
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Init;
+import javax.ejb.Local;
+import javax.ejb.LocalHome;
+import javax.ejb.MessageDriven;
+import javax.ejb.PostActivate;
+import javax.ejb.PrePassivate;
+import javax.ejb.Remote;
+import javax.ejb.RemoteHome;
+import javax.ejb.Remove;
+import javax.ejb.Stateless;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.ejb.TransactionManagement;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.ExcludeClassInterceptors;
+import javax.interceptor.ExcludeDefaultInterceptors;
+import javax.interceptor.Interceptors;
+import java.lang.reflect.Member;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
 /**
  * @version <tt>$Revision$</tt>
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
@@ -1022,16 +1049,10 @@
 
          addInterceptorMethodAnnotations(container, enterpriseBean);
 
-         handleEnvEntries(container, enterpriseBean.getEnvEntries(), container
-               .getBeanClass(), container.getEncInjections());
-
          handleResourceRefs(container, enterpriseBean.getResourceRefs());
 
-         handleResourceEnvRefs(container, enterpriseBean.getResourceEnvRefs());
+         addMessageDestinationAnnotations(container, enterpriseBean.getMessageDestinationRefs());
 
-         addMessageDestinationAnnotations(container, enterpriseBean
-               .getMessageDestinationRefs(), container.getEncInjections());
-
          addSecurityIdentityAnnotation(container, enterpriseBean
                .getSecurityIdentity());
 
@@ -1410,40 +1431,6 @@
       }
    }
 
-   private void handleEnvEntries(EJBContainer container,
-         Collection<EnvEntry> envEntryList, Class clazz,
-         HashMap<AccessibleObject, Injector> injectors)
-         throws ClassNotFoundException, NoSuchMethodException,
-         NoSuchFieldException, javax.naming.NamingException
-   {
-      Iterator refs = envEntryList.iterator();
-      while (refs.hasNext())
-      {
-         EnvEntry entry = (EnvEntry) refs.next();
-
-         container.addEnvEntry(entry.getEnvEntryName(),
-               entry.getEnvEntryType(), entry.getEnvEntryValue());
-
-         if (entry.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz,
-                  entry.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/"
-                     + entry.getEnvEntryName(), container.getEnc()));
-            } else
-            {
-               injectors.put(ao, new JndiMethodInjector(
-                     (java.lang.reflect.Method) ao, "env/"
-                           + entry.getEnvEntryName(), container.getEnc()));
-            }
-         }
-
-      }
-   }
-
    private void handleResourceRefs(EJBContainer container,
          Collection<ResourceRef> resourceRefList)
    {
@@ -1461,19 +1448,8 @@
       }
    }
 
-   private void handleResourceEnvRefs(EJBContainer container,
-         Collection<ResourceEnvRef> resourceEnvRefList)
-   {
-      Iterator refs = resourceEnvRefList.iterator();
-      while (refs.hasNext())
-      {
-         ResourceEnvRef ref = (ResourceEnvRef) refs.next();
-      }
-   }
-
    private void addMessageDestinationAnnotations(EJBContainer container,
-         Collection destinationRefList,
-         HashMap<AccessibleObject, Injector> injectors)
+         Collection destinationRefList)
 
    {
       Iterator refs = destinationRefList.iterator();
@@ -1494,32 +1470,6 @@
                }
             }
          }
-
-         if (ref.getMappedName() == null || ref.getMappedName().equals(""))
-            throw new RuntimeException("mapped-name is required for "
-                  + ref.getMessageDestinationRefName() + " of EJB "
-                  + container.getEjbName());
-         else
-            container.encLinkRefEntries.put("env/"
-                  + ref.getMessageDestinationRefName(), ref.getMappedName());
-
-         if (ref.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, ref
-                  .getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/"
-                     + ref.getMessageDestinationRefName(), container.getEnc()));
-            } else
-            {
-               injectors.put(ao, new JndiMethodInjector(
-                     (java.lang.reflect.Method) ao, "env/"
-                           + ref.getMessageDestinationRefName(), container
-                           .getEnc()));
-            }
-         }
       }
    }
 

Modified: trunk/ejb3/src/main/org/jboss/ejb3/Pool.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/Pool.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/Pool.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -21,7 +21,7 @@
   */
 package org.jboss.ejb3;
 
-import org.jboss.ejb3.injection.Injector;
+import org.jboss.injection.Injector;
 
 /**
  * Minimally a pool acts as a factory for a bean.  It will handle callbacks

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsFieldInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsFieldInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsFieldInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,76 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.Field;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.mx.util.MBeanProxyExt;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision$
- */
-public class DependsFieldInjector implements Injector
-{
-   Field field;
-   ObjectName on;
-
-   public DependsFieldInjector(Field field, ObjectName on)
-   {
-      this.field = field;
-      this.on = on;
-      field.setAccessible(true);
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      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(ctx.getInstance(), value);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return field.getType();
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,169 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import javax.management.ObjectName;
-import org.jboss.annotation.ejb.Depends;
-import org.jboss.aop.Advisor;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.logging.Logger;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision$
- */
-public class DependsHandler
-{
-   private static final Logger log = Logger.getLogger(DependsHandler.class);
-
-   public static void loadDependencies(EJBContainer container, Class clazz)
-   {
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadClassDepends(container, clazz);
-      loadMethodDepends(visitedMethods, clazz, container);
-      loadFieldDepends(clazz, container);
-   }
-
-   public static void loadClassDepends(EJBContainer container, Class clazz)
-   {
-      Depends dep = (Depends)((Advisor)container).resolveAnnotation(Depends.class);
-      if (dep == null) return;
-      for (String dependency : dep.value())
-      {
-         container.getDependencyPolicy().addDependency(dependency);
-      }
-   }
-
-   private static void loadMethodDepends(HashSet<String> visitedMethods, Class clazz, InjectionContainer container)
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getMethods();
-      for (int i = 0; i < methods.length; i++)
-      {
-         Depends dep = (Depends) ((Advisor) container).resolveAnnotation(methods[i], Depends.class);
-         if (dep != null)
-         {
-            if (!Modifier.isPrivate(methods[i].getModifiers()))
-            {
-               if (visitedMethods.contains(methods[i].getName())) continue;
-               else visitedMethods.add(methods[i].getName());
-            }
-            if (!methods[i].getName().startsWith("set")) throw new RuntimeException("@Depends can only be used with a set method: " + methods[i]);
-            if (methods[i].getParameterTypes().length != 1) throw new RuntimeException("@Depends annotated setter methods can only take one parameter: " + methods[i]);
-
-            String[] names = dep.value();
-            if (names.length != 1) throw new RuntimeException("@Depends on a method can only take one object name: " + methods[i]);
-            container.getDependencyPolicy().addDependency(names[0]);
-         }
-      }
-      
-      loadMethodDepends(visitedMethods, clazz.getSuperclass(), container);
-   }
-
-   private static void loadFieldDepends(Class clazz, InjectionContainer container)
-   {
-      if (clazz == null || clazz.equals(java.lang.Object.class)) return;
-      loadFieldDepends(clazz.getSuperclass(), container);
-      Field[] fields = clazz.getDeclaredFields();
-      for (int i = 0; i < fields.length; i++)
-      {
-         Depends dep = (Depends) ((Advisor) container).resolveAnnotation(fields[i], Depends.class);
-         if (dep != null)
-         {
-            String[] names = dep.value();
-            if (names.length != 1) throw new RuntimeException("@Depends on a field can only take one object name: " + fields[i]);
-            container.getDependencyPolicy().addDependency(names[0]);
-         }
-      }
-   }
-
-   public static List loadInjectors(Container container) throws Exception
-   {
-      Class clazz = container.getBeanClass();
-      HashSet<String> visitedMethods = new HashSet<String>();
-      ArrayList list = new ArrayList();
-      loadMethodInjectors(visitedMethods, clazz, (InjectionContainer)container, list);
-      loadFieldInjectors(clazz, (InjectionContainer)container, list);
-      return list;
-   }
-   
-   private static void loadMethodInjectors(HashSet<String> visitedMethods, Class clazz, InjectionContainer container, ArrayList list) throws Exception
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getMethods();
-      for (int i = 0; i < methods.length; i++)
-      {
-         Depends dep = (Depends) ((Advisor) container).resolveAnnotation(methods[i], Depends.class);
-         if (dep != null)
-         {
-            if (!Modifier.isPrivate(methods[i].getModifiers()))
-            {
-               if (visitedMethods.contains(methods[i].getName())) continue;
-               else visitedMethods.add(methods[i].getName());
-            }
-
-            if (!methods[i].getName().startsWith("set")) throw new RuntimeException("@Depends can only be used with a set method: " + methods[i]);
-            if (methods[i].getParameterTypes().length != 1) throw new RuntimeException("@Depends annotated setter methods can only take one parameter: " + methods[i]);
-
-            String[] names = dep.value();
-            if (names.length != 1) throw new RuntimeException("@Depends on a method can only take one object name: " + methods[i]);
-            ObjectName on = new ObjectName(names[0]);
-            list.add(new DependsMethodInjector(methods[i], on));
-         }
-      }
-      if (clazz != null && !clazz.equals(Object.class))
-      {
-         loadMethodInjectors(visitedMethods, clazz.getSuperclass(), container, list);
-      }
-   }
-
-   private static void loadFieldInjectors(Class clazz, InjectionContainer container, ArrayList list) throws Exception
-   {
-      if (clazz == null || clazz.equals(java.lang.Object.class)) return;
-      loadFieldInjectors(clazz.getSuperclass(), container, list);
-      Field[] fields = clazz.getDeclaredFields();
-      for (int i = 0; i < fields.length; i++)
-      {
-         Depends dep = (Depends) ((Advisor) container).resolveAnnotation(fields[i], Depends.class);
-         if (dep != null)
-         {
-            String[] names = dep.value();
-            if (names.length != 1) throw new RuntimeException("@Depends on a field can only take one object name: " + fields[i]);
-            ObjectName on = new ObjectName(names[0]);
-            list.add(new DependsFieldInjector(fields[i], on));
-         }
-      }
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsMethodInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsMethodInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/DependsMethodInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,80 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectName;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.mx.util.MBeanProxyExt;
-
-/**
- * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
- * @version $Revision$
- */
-public class DependsMethodInjector implements Injector
-{
-   Method method;
-   ObjectName on;
-
-   public DependsMethodInjector(Method method, ObjectName on)
-   {
-      this.method = method;
-      this.on = on;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      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(ctx.getInstance(), value);
-      }
-      catch (InvocationTargetException e)
-      {
-         throw new RuntimeException(e);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return method.getParameterTypes()[0];
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBContextFieldInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBContextFieldInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBContextFieldInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,63 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.Field;
-import org.jboss.ejb3.BeanContext;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EJBContextFieldInjector implements Injector, PojoInjector
-{
-   private Field field;
-
-   public EJBContextFieldInjector(Field field)
-   {
-      this.field = field;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      inject(ctx, ctx.getInstance());
-   }
-   
-   public void inject(BeanContext ctx, Object instance)
-   {
-      try
-      {
-         field.set(instance, ctx.getEJBContext());
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return field.getType();
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBContextMethodInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBContextMethodInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBContextMethodInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,74 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import org.jboss.ejb3.BeanContext;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EJBContextMethodInjector implements Injector, PojoInjector
-{
-   private Method setMethod;
-
-   public EJBContextMethodInjector(Method setMethod)
-   {
-      this.setMethod = setMethod;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      inject(ctx, ctx.getInstance());
-   }
-   
-   public void inject(BeanContext ctx, Object instance)
-   {
-
-      Object[] args = {ctx.getEJBContext()};
-      try
-      {
-         setMethod.invoke(instance, args);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException("Failed in setting EntityManager on setter method: " + setMethod.toString());
-      }
-      catch (InvocationTargetException e)
-      {
-         throw new RuntimeException(e.getCause());  //To change body of catch statement use Options | File Templates.
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return setMethod.getParameterTypes()[0];
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/EJBHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,654 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.metamodel.Injectable;
-import org.jboss.ejb3.interceptor.InterceptorInjector;
-import org.jboss.logging.Logger;
-import org.jboss.annotation.IgnoreDependency;
-
-import org.jboss.metamodel.descriptor.EjbLocalRef;
-import org.jboss.metamodel.descriptor.EjbRef;
-
-import javax.ejb.EJB;
-import javax.ejb.EJBs;
-import javax.naming.Context;
-import javax.naming.NameNotFoundException;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-
-/**
- * Searches bean class for all @Inject and create Injectors
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EJBHandler
-{
-   private static final Logger log = Logger.getLogger(EJBHandler.class);
-
-   public static void loadDependencies(Injectable xml, InjectionContainer container, Class clazz)
-   {
-      if (xml != null)
-      {
-         loadEjbLocalRefXmlDependencies(xml.getEjbLocalRefs(), container);
-         loadEjbRefXmlDependencies(xml.getEjbRefs(), container);
-      }
-      loadClassDependencies(container, clazz);
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadMethodDependencies(visitedMethods, clazz, container);
-      loadFieldDependencies(clazz, container);
-
-   }
-
-   private static void loadEjbLocalRefXmlDependencies(Collection<EjbLocalRef> refs, InjectionContainer container)
-   {
-      for (EjbLocalRef ref : refs)
-      {
-         if (ref.isIgnoreDependency())
-         {
-            container.getEjbRefDependencies().put("env/" + ref.getEjbRefName(), "env/" + ref.getEjbRefName());
-            continue;
-         }
-         
-         EJBContainer refcon = null;
-         String link = ref.getEjbLink();
-         
-         try
-         {
-            if (ref.getLocal() != null)
-            {
-               Class refClass = container.getClassloader().loadClass(ref.getLocal());
-            
-               if (link != null && !"".equals(link))
-               {
-                  refcon = (EJBContainer)container.resolveEjbContainer(link, refClass);
-                  if (refcon == null)
-                     log.warn("unable to find <ejb-local-ref> of interface " + ref.getLocal() + " and ejbLink of " + link + " in  " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-               }
-               else
-               {
-                  try
-                  {
-                     refcon = (EJBContainer)container.resolveEjbContainer(refClass);
-                     if (refcon == null)
-                        log.warn("unable to find <ejb-local-ref> of interface " + ref.getLocal() + " and ejbLink of " + link + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-                  }
-                  catch (NameNotFoundException e)
-                  {
-                     throw new RuntimeException("could not find <ejb-local-ref> by local interface " + ref.getLocal() + " only in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier() + " " + e.getMessage());
-
-                  }
-               }
-            }
-         }
-         catch (ClassNotFoundException e)
-         {
-            throw new RuntimeException("could not find ejb-local-ref's local interface " + ref.getLocal() + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-         }
-         
-         if (ref.getMappedName() == null || ref.getMappedName().equals(""))
-         {
-            if (container.getEjbRefDependencies().containsKey("env/" + ref.getEjbRefName())) return;
-        
-            if (refcon != null)
-            {
-               addDependency("env/" + ref.getEjbRefName(), refcon, container);
-            }
-         }
-         else
-         {
-            // put it in list just in case there is an @EJB annotation without a mappedName
-            container.getEjbRefDependencies().put("env/" + ref.getEjbRefName(), "env/" + ref.getEjbRefName());
-            
-            if (refcon != null)
-            {
-               addDependency(ref.getEjbRefName(), refcon, container);
-            }
-         }
-      }
-   }
-
-   private static void loadEjbRefXmlDependencies(Collection<EjbRef> refs, InjectionContainer container)
-   {
-      for (EjbRef ref : refs)
-      {
-         if (ref.isIgnoreDependency())
-         {
-            container.getEjbRefDependencies().put("env/" + ref.getEjbRefName(), "env/" + ref.getEjbRefName());
-            continue;
-         }
-         
-         EJBContainer refcon = null;
-         String link = ref.getEjbLink();
-         
-         try
-         {
-            if (ref.getRemote() != null)
-            {
-               Class refClass = container.getClassloader().loadClass(ref.getRemote());
-               
-               if (link != null && !"".equals(link))
-               {
-                  refcon = (EJBContainer)container.resolveEjbContainer(link, refClass);
-                  
-                  if (refcon == null)
-                     log.warn("unable to find <ejb-ref> of interface " + ref.getRemote() + " and ejbLink of " + link + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-               }
-               else
-               {
-                  try
-                  {
-                     refcon = (EJBContainer)container.resolveEjbContainer(refClass);
-                     if (refcon == null)
-                        log.warn("unable to find <ejb-ref> of interface " + ref.getRemote() + " and ejbLink of " + link + " in  " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-                  }
-                  catch (NameNotFoundException e)
-                  {
-                     log.warn("could not find <ejb-ref> by remote` interface " + ref.getRemote() + " only in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier() + ":" + e.getMessage());
-                  }
-               }
-            }
-         }
-         catch (ClassNotFoundException e)
-         {
-            throw new RuntimeException("could not find ejb-ref's remote interface " + ref.getRemote() + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-         }
-      
-         if (ref.getMappedName() == null || ref.getMappedName().equals(""))
-         {
-            if (container.getEjbRefDependencies().containsKey("env/" + ref.getEjbRefName())) return;
-            
-            if (refcon != null)
-            {
-               addDependency("env/" + ref.getEjbRefName(), refcon, container);
-            }
-         }
-         else
-         {
-            // put it in list just in case there is an @EJB annotation without a mappedName
-            container.getEjbRefDependencies().put("env/" + ref.getEjbRefName(), "env/" + ref.getEjbRefName());
-            
-            if (refcon != null)
-            {
-               addDependency(ref.getEjbRefName(), refcon, container);
-            }
-         }
-      }
-   }
-
-   private static void loadClassDependencies(InjectionContainer container, Class clazz)
-   {
-      EJBs resources = container.getAnnotation(EJBs.class, clazz);
-
-      if (resources != null)
-      {
-         for (EJB ref : resources.value())
-         {
-            loadRefDependency(ref, container, null);
-         }
-      }
-      EJB ejb = container.getAnnotation(EJB.class, clazz);
-      if (ejb != null) loadRefDependency(ejb, container, null);
-   }
-
-   private static void loadRefDependency(EJB ref, InjectionContainer container, AccessibleObject member)
-   {
-      String encName = ref.name();
-      Class memberType = null;
-      if (member != null)
-      {
-         if (member instanceof Method)
-         {
-            encName = InjectionUtil.getEncName((Method)member);
-            memberType = ((Method)member).getParameterTypes()[0];
-         }
-         else
-         {
-            encName = InjectionUtil.getEncName((Field)member);
-            memberType = ((Field)member).getType();
-         }
-      }
-      else if (encName == null || encName.equals(""))
-      {
-         throw new RuntimeException("JBoss requires name() for class level @EJB");
-      }
-      // skip if already loaded by XML
-      if (container.getEjbRefDependencies().containsKey("env/" + encName)) return;
-      EJBContainer refContainer = getEjbContainer(ref, container, memberType);
-      if (refContainer != null) addDependency(encName, refContainer, container);
-   }
-
-   private static void addDependency(String refName, EJBContainer refcon, InjectionContainer container)
-   {
-      container.getEjbRefDependencies().put(refName, refName);
-      container.getDependencyPolicy().addDependency(refcon.getObjectName().getCanonicalName());
-   }
-
-   private static void loadMethodDependencies(HashSet<String> visitedMethods, Class clazz, InjectionContainer container)
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getDeclaredMethods();
-      for (int i = 0; i < methods.length; i++)
-      {
-         EJB ref = container.getAnnotation(EJB.class, clazz, methods[i]);
-         if (ref != null)
-         {
-            if (container.getAnnotation(IgnoreDependency.class, clazz, methods[i]) != null) continue;
-            if (ref.mappedName() == null || ref.mappedName().equals("")) continue;
-            if (!Modifier.isPrivate(methods[i].getModifiers()))
-            {
-               if (visitedMethods.contains(methods[i].getName())) continue;
-               else visitedMethods.add(methods[i].getName());
-            }
-            if (!methods[i].getName().startsWith("set"))
-               throw new RuntimeException("@EJB can only be used with a set method: " + methods[i]);
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(methods[i]);
-            }
-            else
-            {
-               encName = "env/" + encName;
-            }
-            if (container.getEjbRefDependencies().containsKey(encName)) continue;
-            loadRefDependency(ref, container, methods[i]);
-         }
-      }
-      loadMethodDependencies(visitedMethods, clazz.getSuperclass(), container);
-   }
-
-   private static void loadFieldDependencies(Class clazz, InjectionContainer container)
-   {
-      if (clazz == null || clazz.equals(Object.class)) return;
-      loadFieldDependencies(clazz.getSuperclass(), container);
-      Field[] fields = clazz.getDeclaredFields();
-      for (Field field : fields)
-      {
-         EJB ref = container.getAnnotation(EJB.class, clazz, field);
-         if (ref != null)
-         {
-            if (container.getAnnotation(IgnoreDependency.class, clazz, field) != null) continue;
-            if (ref.mappedName() == null || ref.mappedName().equals(""))
-            {
-               loadRefDependency(ref, container, field);
-               continue;
-            }
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(field);
-            }
-            else
-            {
-               encName = "env/" + encName;
-            }
-
-            if (container.getEjbRefDependencies().containsKey(encName)) continue;
-            loadRefDependency(ref, container, field);
-         }
-      }
-   }
-
-   public static void loadInjectors(Container container) throws Exception
-   {
-      EJBContainer ejb = (EJBContainer) container;
-      Class clazz = container.getBeanClass();
-      loadInjectors(clazz, ejb.getXml(), ejb, ejb.getEncInjections());
-   }
-
-   public static void loadInjectors(InterceptorInjector injector) throws Exception
-   {
-      loadInjectors(injector.getClazz(), injector.getXml(), (EJBContainer) injector.getContainer(), injector.getEncInjections());
-   }
-
-   private static void loadInjectors(Class clazz, Injectable xml, InjectionContainer container, HashMap<AccessibleObject, Injector> encInjections)
-   {
-      if (xml != null)
-      {
-         loadEjbLocalXml(xml.getEjbLocalRefs(), container, clazz, encInjections);
-         loadEjbRefXml(xml.getEjbRefs(), container, clazz, encInjections);
-      }
-
-      Context ctx = container.getEnc();
-      loadClassLevelEnc(clazz, container, ctx);
-
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadMethodInjectors(visitedMethods, clazz, container, encInjections);
-      loadFieldInjectors(clazz, container, encInjections);
-   }
-
-
-   private static void loadEjbLocalXml(Collection<EjbLocalRef> refs, InjectionContainer container, Class clazz, HashMap<AccessibleObject, Injector> injectors)
-   {
-
-      for (EjbLocalRef ref : refs)
-      {
-         if (container.hasEncEntry("env/" + ref.getEjbRefName())) continue;
-
-         String jndiName = ref.getMappedName();
-
-         if (jndiName == null || jndiName.equals(""))
-         {
-            if (ref.getLocal() == null) continue;  // we have just a jboss.xml listing only, no ejb-jar.xml
-            String link = ref.getEjbLink();
-            Class refClass = null;
-            try
-            {
-               refClass = container.getClassloader().loadClass(ref.getLocal());
-            }
-            catch (ClassNotFoundException e)
-            {
-               throw new RuntimeException("could not find ejb-local-ref's local interface " + ref.getLocal() + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-            }
-            if (link != null && !"".equals(link))
-            {
-               jndiName = container.getEjbJndiName(link, refClass);
-            }
-            else
-            {
-               try
-               {
-                  jndiName = container.getEjbJndiName(refClass);
-               }
-               catch (NameNotFoundException e)
-               {
-                  throw new RuntimeException("could not find <ejb-local-ref> by local interface " + ref.getLocal() + " only " + e.getMessage());
-               }
-            }
-         }
-
-         container.getEncLinkRefEntries().put("env/" + ref.getEjbRefName(), jndiName);
-
-         if (ref.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, ref.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/" + ref.getEjbRefName(), container.getEnc()));
-            }
-            else
-            {
-               injectors.put(ao, new JndiMethodInjector((java.lang.reflect.Method) ao, "env/" + ref.getEjbRefName(), container.getEnc()));
-            }
-         }
-      }
-   }
-
-   private static void loadEjbRefXml(Collection<EjbRef> refs, InjectionContainer container, Class clazz, HashMap<AccessibleObject, Injector> injectors)
-   {
-      for (EjbRef ref : refs)
-      {
-         if (container.hasEncEntry("env/" + ref.getEjbRefName())) continue;
-
-         String jndiName = ref.getMappedName();
-
-         if (jndiName == null || jndiName.equals(""))
-         {
-            if (ref.getRemote() == null) continue;  // we have just a jboss.xml listing only, no ejb-jar.xml
-            String link = ref.getEjbLink();
-            Class refClass = null;
-            try
-            {
-               refClass = container.getClassloader().loadClass(ref.getRemote());
-            }
-            catch (ClassNotFoundException e)
-            {
-               throw new RuntimeException("could not find ejb-ref's remote interface " + ref.getRemote() + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier());
-            }
-            if (link != null && !"".equals(link))
-            {
-               jndiName = container.getEjbJndiName(link, refClass);
-            }
-            else
-            {
-               try
-               {
-                  jndiName = container.getEjbJndiName(refClass);
-               }
-               catch (NameNotFoundException e)
-               {
-                  throw new RuntimeException("could not find <ejb-ref> by remote interface " + ref.getRemote() + " only " + e.getMessage());
-               }
-            }
-         }
-
-         container.getEncLinkRefEntries().put("env/" + ref.getEjbRefName(), jndiName);
-
-         if (ref.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, ref.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/" + ref.getEjbRefName(), container.getEnc()));
-            }
-            else
-            {
-               injectors.put(ao, new JndiMethodInjector((java.lang.reflect.Method) ao, "env/" + ref.getEjbRefName(), container.getEnc()));
-            }
-         }
-      }
-   }
-
-   private static Class getBeanInterface(EJB ref, Class defaultInterface)
-   {
-      if(!ref.beanInterface().equals(Object.class))
-         return ref.beanInterface();
-      return defaultInterface;
-   }
-   
-   public static EJBContainer getEjbContainer(EJB ref, InjectionContainer container, Class memberType)
-   {
-      EJBContainer rtn = null;
-
-      if (ref.mappedName() != null && !"".equals(ref.mappedName()))
-      {
-         return null;
-      }
-
-      if (ref.beanName().equals("") && memberType == null)
-         throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
-
-      Class beanInterface = getBeanInterface(ref, memberType);
-
-      if (ref.beanName().equals(""))
-      {
-         try
-         {
-            rtn = (EJBContainer)container.resolveEjbContainer(beanInterface);
-         }
-         catch (NameNotFoundException e)
-         {
-            log.warn("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + beanInterface.getName() + ") " + e.getMessage());
-         }
-      }
-      else
-      {
-         rtn = (EJBContainer)container.resolveEjbContainer(ref.beanName(), beanInterface);
-      }
-
-      return rtn;
-   }
-
-   public static String getJndiName(EJB ref, InjectionContainer container, Class memberType)
-   {
-      String jndiName;
-      
-      if (ref.mappedName() != null && !"".equals(ref.mappedName()))
-      {
-         return ref.mappedName();
-      }
-
-      if (ref.beanName().equals("") && memberType == null)
-         throw new RuntimeException("For deployment " + container.getIdentifier() + "not enough information for @EJB.  Please fill out the beanName and/or businessInterface attributes");
-
-      Class beanInterface = getBeanInterface(ref, memberType);
-
-      if (ref.beanName().equals(""))
-      {
-         try
-         {
-            jndiName = container.getEjbJndiName(beanInterface);
-         }
-         catch (NameNotFoundException e)
-         {
-            throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + beanInterface.getName() + ") " + e.getMessage());
-         }
-         if (jndiName == null)
-         {
-            throw new RuntimeException("For deployment " + container.getIdentifier() + " could not find jndi binding based on interface only for @EJB(" + beanInterface.getName() + ")");
-         }
-      }
-      else
-      {
-         jndiName = container.getEjbJndiName(ref.beanName(), beanInterface);
-         if (jndiName == null)
-         {
-            throw new RuntimeException("For EJB " + container.getIdentifier() + "could not find jndi binding based on beanName and business interface for @EJB(" + ref.beanName() + ", " + beanInterface.getName() + ")");
-         }
-      }
-
-      return jndiName;
-   }
-
-   private static void loadClassLevelEnc(Class clazz, InjectionContainer container, Context ctx)
-   {
-      EJBs ref = container.getAnnotation(EJBs.class, clazz);
-      if (ref != null)
-      {
-         EJB[] ejbs = ref.value();
-
-         for (EJB ejb : ejbs)
-         {
-            loadClassAnnotation(ejb, clazz, container);
-         }
-      }
-      EJB ejbref = container.getAnnotation(EJB.class, clazz);
-      if (ejbref != null) loadClassAnnotation(ejbref, clazz, container);
-
-   }
-
-   private static void loadClassAnnotation(EJB ejb, Class clazz, InjectionContainer container)
-   {
-      String encName = ejb.name();
-      if (encName == null || encName.equals(""))
-      {
-         throw new RuntimeException("JBoss requires the name of the @EJB in the @EJBs: " + clazz);
-      }
-      encName = "env/" + encName;
-      if (!container.hasEncEntry(encName))
-      {
-         String jndiName = getJndiName(ejb, container, null);
-         container.getEncLinkRefEntries().put(encName, jndiName);
-      }
-   }
-
-   private static void loadMethodInjectors(HashSet<String> visitedMethods, Class clazz, InjectionContainer container, HashMap<AccessibleObject, Injector> injectors)
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getDeclaredMethods();
-      for (int i = 0; i < methods.length; i++)
-      {
-         EJB ref = container.getAnnotation(EJB.class, clazz, methods[i]);
-         if (ref != null)
-         {
-            if (!Modifier.isPrivate(methods[i].getModifiers()))
-            {
-               if (visitedMethods.contains(methods[i].getName())) continue;
-               else visitedMethods.add(methods[i].getName());
-            }
-            if (!methods[i].getName().startsWith("set"))
-               throw new RuntimeException("@EJB can only be used with a set method: " + methods[i]);
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(methods[i]);
-            }
-            else
-            {
-               encName = "env/" + encName;
-            }
-            EJBContainer ejb = (EJBContainer) container;
-            if (!ejb.hasEncEntry(encName))
-            {
-               String jndiName = getJndiName(ref, container, methods[i].getParameterTypes()[0]);
-               ejb.getEncLinkRefEntries().put(encName, jndiName);
-            }
-            if (!injectors.containsKey(methods[i]))
-            {
-               injectors.put(methods[i], new JndiMethodInjector(methods[i], encName, container.getEnc()));
-            }
-         }
-      }
-      loadMethodInjectors(visitedMethods, clazz.getSuperclass(), container, injectors);
-   }
-
-   private static void loadFieldInjectors(Class clazz, InjectionContainer container, HashMap<AccessibleObject, Injector> injectors)
-   {
-      if (clazz == null || clazz.equals(Object.class)) return;
-      loadFieldInjectors(clazz.getSuperclass(), container, injectors);
-      Field[] fields = clazz.getDeclaredFields();
-      for (Field field : fields)
-      {
-         EJB ref = container.getAnnotation(EJB.class, clazz, field);
-         if (ref != null)
-         {
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(field);
-            }
-            else
-            {
-               encName = "env/" + encName;
-            }
-
-            EJBContainer ejb = (EJBContainer) container;
-            if (!ejb.hasEncEntry(encName))
-            {
-               String jndiName = getJndiName(ref, container, field.getType());
-               ejb.getEncLinkRefEntries().put(encName, jndiName);
-            }
-            if (!injectors.containsKey(field))
-            {
-               injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
-            }
-         }
-      }
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/EntityManagerFactoryFieldInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/EntityManagerFactoryFieldInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/EntityManagerFactoryFieldInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,74 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.Field;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EntityManagerFactoryFieldInjector implements Injector, PojoInjector
-{
-   private static final Logger log = Logger.getLogger(EntityManagerFactoryFieldInjector.class);
-   private Field field;
-   private Object factory;
-
-   public EntityManagerFactoryFieldInjector(Field field, Object factory)
-   {
-      this.field = field;
-      this.field.setAccessible(true);
-      this.factory = factory;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      inject(ctx, ctx.getInstance());
-   }
-   
-   public void inject(BeanContext ctx, Object instance)
-   {
-      try
-      {
-         field.set(instance, factory);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException("Failed in setting EntityManager on setter field: " + field.toString());
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return field.getType();
-   }
-
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/EntityManagerFactoryMethodInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/EntityManagerFactoryMethodInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/EntityManagerFactoryMethodInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,78 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class EntityManagerFactoryMethodInjector implements Injector, PojoInjector
-{
-   private static final Logger log = Logger.getLogger(EntityManagerFactoryMethodInjector.class);
-   private Method setMethod;
-   private Object factory;
-
-   public EntityManagerFactoryMethodInjector(Method setMethod, Object factory)
-   {
-      this.setMethod = setMethod;
-      this.factory = factory;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      inject(ctx, ctx.getInstance());
-   }
-   
-   public void inject(BeanContext ctx, Object instance)
-   {
-      try
-      {
-         Object[] args = {factory};
-         setMethod.invoke(instance, args);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException("Failed in setting EntityManager on setter method: " + setMethod.toString());
-      }
-      catch (InvocationTargetException e)
-      {
-         throw new RuntimeException(e.getCause());  //To change body of catch statement use Options | File Templates.
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return setMethod.getParameterTypes()[0];
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/ExtendedPersistenceContextInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/ExtendedPersistenceContextInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/ExtendedPersistenceContextInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,69 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContextType;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.entity.ManagedEntityManagerFactory;
-import org.jboss.ejb3.stateful.StatefulBeanContext;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class ExtendedPersistenceContextInjector implements Injector, PojoInjector
-{
-   protected static final Logger log = Logger.getLogger(ExtendedPersistenceContextInjector.class);
-   protected ManagedEntityManagerFactory factory;
-
-   protected ExtendedPersistenceContextInjector(ManagedEntityManagerFactory factory)
-   {
-      this.factory = factory;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      inject(ctx, ctx.getInstance());
-   }
-
-   public void inject(BeanContext beanContext, Object instance)
-   {
-      StatefulBeanContext ctx = (StatefulBeanContext)beanContext;
-      EntityManager pc = ctx.getExtendedPersistenceContext(factory.getKernelName());
-      if (pc == null)
-      {
-         pc = factory.createEntityManager();
-         ctx.addExtendedPersistenceContext(factory.getKernelName(), pc);
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return null;
-   }
-
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionContainer.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionContainer.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,119 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.ejb3.injection;
-
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-
-import javax.naming.Context;
-import javax.naming.NameNotFoundException;
-import java.util.Map;
-import java.util.HashMap;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Field;
-import java.lang.reflect.AccessibleObject;
-
-/**
- * This is the container that manages all injections.  Could be an EJB Container
- * or a WAR.
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface InjectionContainer
-{
-   /**
-    * Some identifier that can be used in error messages
-    *
-    * @return
-    */
-   String getIdentifier();
-
-   /**
-    * For error messages
-    *
-    * @return  ejb-jar.xml, web.xml, etc..
-    */
-   String getDeploymentDescriptorType();
-
-   ClassLoader getClassloader();
-
-   Map<String, String> getEjbRefDependencies();
-   Map<String, String> getEncLinkRefEntries();
-   void addEncInjector(AccessibleObject acc, Injector inj);
-   Map<AccessibleObject, Injector> getEncInjections();
-   boolean hasEnvEntry(String name);
-   void addEnvEntry(String name, String type, String value) throws ClassNotFoundException;
-   boolean hasEncEntry(String name);
-
-   Context getEnc();
-   Context getEncEnv();
-
-
-   Map<String, String> getPuEncXmlEntries();
-   PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException;
-   Map getExtendedPCs();
-
-
-   Container resolveEjbContainer(String link, Class businessIntf);
-   Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException;
-   String getEjbJndiName(Class businessInterface) throws NameNotFoundException;
-   String getEjbJndiName(String link, Class businessInterface);
-
-   /**
-    * If class has container overridable annotations, this method will
-    * discover those overriden annotations.
-    *
-    * @param annotationType
-    * @param clazz
-    * @return
-    */
-   <T> T getAnnotation(Class<T> annotationType, Class clazz);
-
-   /**
-    * If class has container overridable annotations, this method will
-    * discover those overriden annotations.
-
-    * @param annotationType
-    * @param clazz
-    * @param method
-    * @return
-    */
-   <T> T getAnnotation(Class<T> annotationType, Class clazz, Method method);
-
-   /**
-    * If class has container overridable annotations, this method will
-    * discover those overriden annotations.
-
-    * @param annotationType
-    * @param clazz
-    * @param field
-    * @return
-    */
-   <T> T getAnnotation(Class<T> annotationType, Class clazz, Field field);
-
-   DependencyPolicy getDependencyPolicy();
-
-
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,40 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/
-package org.jboss.ejb3.injection;
-
-import org.jboss.ejb3.metamodel.Injectable;
-import org.jboss.ejb3.EJBContainer;
-
-import java.lang.reflect.AccessibleObject;
-import java.util.HashMap;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface InjectionHandler
-{
-   void loadDependencies(Injectable xml, InjectionContainer container, Class clazz);
-   void loadInjectors(Class clazz, Injectable xml, InjectionContainer container, HashMap<AccessibleObject, Injector> encInjections);
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionUtil.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionUtil.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/InjectionUtil.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,132 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.logging.Logger;
-
-import org.jboss.metamodel.descriptor.InjectionTarget;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class InjectionUtil
-{
-   private static final Logger log = Logger
-   .getLogger(InjectionUtil.class);
-   
-   public static AccessibleObject findInjectionTarget(Class injectionClass, InjectionTarget target)
-   {
-      Class clazz = injectionClass;
-      if (clazz == null) throw new NullPointerException("clazz was null???");
-      String targetClass = target.getTargetClass();
-      String targetName = target.getTargetName();
-      String className = clazz.getName();
-      if (targetClass == null) throw new NullPointerException("injection-target-class was null");
-      if (className == null) throw new NullPointerException("className was null");
-    
-      while (!className.equals(targetClass))
-      {
-         if (clazz.equals(Object.class))
-            throw new RuntimeException("invocation target class not found: " + targetClass + " of class: " + injectionClass);
-         clazz = clazz.getSuperclass();
-      }
-
-      for (Field field : clazz.getDeclaredFields())
-      {
-         if (target.getTargetName().equals(field.getName())) return field;
-      }
-
-      for (java.lang.reflect.Method method : clazz.getDeclaredMethods())
-      {
-         if (method.getName().equals(target.getTargetName())) return method;
-      }
-
-      throw new RuntimeException("invocation target could not be found: " + target.getTargetClass() + "." + target.getTargetName() + " of class: " + injectionClass);
-
-   }
-
-   public static String getEncName(Method method)
-   {
-      String encName = method.getName().substring(3);
-      if (encName.length() > 1)
-      {
-         encName = encName.substring(0, 1).toLowerCase() + encName.substring(1);
-      }
-      else
-      {
-         encName = encName.toLowerCase();
-      }
-
-      encName = "env/" + method.getDeclaringClass().getName() + "/" + encName;
-      return encName;
-   }
-
-   public static String getEncName(Field field)
-   {
-      return "env/" + field.getDeclaringClass().getName() + "/" + field.getName();
-   }
-   
-   public static Object getAnnotation(Class annotation, EJBContainer container, Class annotatedClass, boolean isContainer)
-   {
-      if (isContainer)
-      {
-         return container.resolveAnnotation(annotation);
-      }
-      else
-      {
-         return annotatedClass.getAnnotation(annotation);
-      }
-   }
-
-   public static Object getAnnotation(Class annotation, EJBContainer container, Method method, boolean isContainer)
-   {
-      if (isContainer)
-      {
-         return container.resolveAnnotation(method, annotation);
-      }
-      else
-      {
-         return method.getAnnotation(annotation);
-      }
-   }
-
-   public static Object getAnnotation(Class annotation, EJBContainer container, Field field, boolean isContainer)
-   {
-      if (isContainer)
-      {
-         return container.resolveAnnotation(field, annotation);
-      }
-      else
-      {
-         return field.getAnnotation(annotation);
-      }
-   }
-
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/Injector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/Injector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/Injector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,37 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import org.jboss.ejb3.BeanContext;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public interface Injector
-{
-   void inject(BeanContext ctx);
-   
-   Class getInjectionClass();
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiFieldInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiFieldInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiFieldInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,127 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.Field;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
-import org.jboss.logging.Logger;
-
-import org.jboss.ejb3.BeanContext;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class JndiFieldInjector implements Injector, PojoInjector
-{
-   private static final Logger log = Logger.getLogger(JndiFieldInjector.class);
-   
-   private Field field;
-   private String jndiName;
-   private Context ctx;
-
-   public JndiFieldInjector(Field field, String jndiName, Context ctx)
-   {
-      this.field = field;
-      this.field.setAccessible(true);
-      this.jndiName = jndiName;
-      this.ctx = ctx;
-   }
-
-   public JndiFieldInjector(Field field, Context ctx)
-   {
-      this(field, field.getName(), ctx);
-   }
-
-   public void inject(BeanContext bctx)
-   {
-      inject(bctx, bctx.getInstance());
-   }
-
-   public Class getInjectionClass()
-   {
-      return field.getType();
-   }
-
-   public Field getField()
-   {
-      return field;
-   }
-
-   protected Object lookup(String jndiName, Class field)
-   {
-      Object dependency = null;
-
-      try
-      {
-         dependency = ctx.lookup(jndiName);
-
-         if (dependency instanceof javax.xml.rpc.Service && !field.isAssignableFrom(javax.xml.rpc.Service.class))
-         {
-            javax.xml.rpc.Service service = (javax.xml.rpc.Service)dependency;
-            dependency = service.getPort(field);
-         }
-      }
-      catch (NamingException e)
-      {
-         e.printStackTrace();
-         throw new RuntimeException("Unable to inject jndi dependency: " + jndiName + " into field " + field, e);
-      }
-      catch (javax.xml.rpc.ServiceException e)
-      {
-         e.printStackTrace();
-         throw new RuntimeException("Unable to inject jndi webservice dependency: " + jndiName + " into field " + field, e);
-      }
-      
-      return dependency;
-   }
-   
-   public void inject(BeanContext bctx, Object instance)
-   {
-      Object dependency = lookup(jndiName, field.getType());
-     
-      try
-      {
-         field.set(instance, dependency);
-      }
-      catch (IllegalArgumentException e)
-      {
-         String type = "UNKNOWN";
-         String interfaces = "";
-         if (dependency != null)
-         {
-            type = dependency.getClass().getName();
-            Class[] intfs = dependency.getClass().getInterfaces();
-            for (Class intf : intfs) interfaces += ", " + intf.getName();
-         }
-         throw new RuntimeException("Non matching type for inject of field: " + field + " for type: " + type + " of jndiName " + jndiName + "\nintfs: " + interfaces, e);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiInjectHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiInjectHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiInjectHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,160 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import javax.naming.InitialContext;
-import org.jboss.annotation.JndiInject;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.metamodel.Injectable;
-import org.jboss.metamodel.descriptor.JndiRef;
-import org.jboss.ejb3.interceptor.InterceptorInjector;
-import org.jboss.logging.Logger;
-
-/**
- * Searches bean class for all @Inject and create Injectors
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class JndiInjectHandler
-{
-   private static final Logger log = Logger.getLogger(JndiInjectHandler.class);
-   
-   private static void loadXmlJndiRefs(EJBContainer container, Collection<JndiRef> refs, Class clazz, HashMap<AccessibleObject, Injector> injectors)
-   {
-      for (JndiRef ref : refs)
-      {
-         if (ref.getMappedName() == null || ref.getMappedName().equals(""))
-            throw new RuntimeException("mapped-name is required for " + ref.getJndiRefName() + " of EJB " + container.getEjbName());
-         else
-            container.getEncLinkRefEntries().put("env/" + ref.getJndiRefName(), ref.getMappedName());
-
-         if (ref.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, ref.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/" + ref.getJndiRefName(), container.getEnc()));
-            }
-            else
-            {
-               injectors.put(ao, new JndiMethodInjector((java.lang.reflect.Method) ao, "env/" + ref.getJndiRefName(), container.getEnc()));
-            }
-         }
-      }
-   }
-   
-   public static List loadInjectors(Container container) throws Exception
-   {
-      Class clazz = container.getBeanClass();
-      EJBContainer ejb = (EJBContainer)container;
-      return loadInjectors(clazz, ejb.getXml(), ejb, ejb.getEncInjections(), true);
-   }
-
-   public static List loadInjectors(InterceptorInjector injector) throws Exception
-   {
-      return loadInjectors(injector.getClazz(), injector.getXml(), (EJBContainer)injector.getContainer(), injector.getEncInjections(), false);
-   }
-   
-   private static List loadInjectors(Class clazz, Injectable xml, EJBContainer container, HashMap<AccessibleObject, Injector> injectors, boolean isContainer) throws Exception
-   {
-      if (xml != null)
-      {
-         loadXmlJndiRefs(container, xml.getJndiRefs(), clazz, injectors);
-      }
-      
-      ArrayList list = new ArrayList();
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadMethodInjectors(visitedMethods, clazz, container, list, isContainer);
-      loadFieldInjectors(clazz, container, list, isContainer);
-      return list;
-   }
-   
-   private static void loadMethodInjectors(HashSet<String> visitedMethods, Class clazz, EJBContainer container, ArrayList list, boolean isContainer) throws Exception
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getDeclaredMethods();
-      InitialContext ctx = container.getInitialContext();
-      for (int i = 0; i < methods.length; i++)
-      {
-         JndiInject ref = (JndiInject)InjectionUtil.getAnnotation(
-               JndiInject.class, container, methods[i], isContainer); 
-         if (ref != null)
-         {
-            if (!Modifier.isPrivate(methods[i].getModifiers()))
-            {
-               if (visitedMethods.contains(methods[i].getName())) continue;
-               else visitedMethods.add(methods[i].getName());
-            }
-            if (!methods[i].getName().startsWith("set")) throw new RuntimeException("@JndiInject can only be used with a set method: " + methods[i]);
-            if (methods[i].getParameterTypes().length != 1) throw new RuntimeException("@JndiInject can only be used with a set method of one parameter: " + methods[i]);
-            String jndiName = methods[i].getName().substring(3);
-            if (ref.jndiName() != null && !ref.jndiName().equals(""))
-            {
-               jndiName = ref.jndiName();
-            }
-            list.add(new JndiMethodInjector(methods[i], jndiName, ctx));
-         }
-      }
-      if (clazz != null && !clazz.equals(Object.class))
-      {
-         loadMethodInjectors(visitedMethods, clazz.getSuperclass(), container, list, isContainer);
-      }
-
-   }
-   
-   private static void loadFieldInjectors(Class clazz, EJBContainer container, ArrayList list, boolean isContainer) throws Exception
-   {
-      if (clazz == null || clazz.equals(Object.class)) return;
-      loadFieldInjectors(clazz.getSuperclass(), container, list, isContainer);
-      Field[] fields = clazz.getDeclaredFields();
-      InitialContext ctx = container.getInitialContext();
-      for (int i = 0; i < fields.length; i++)
-      {
-         JndiInject ref = (JndiInject)InjectionUtil.getAnnotation(
-               JndiInject.class, container, fields[i], isContainer); 
-         if (ref != null)
-         {
-            String jndiName = fields[i].getName();
-            if (ref.jndiName() != null && !ref.jndiName().equals(""))
-            {
-               jndiName = ref.jndiName();
-            }
-            list.add(new JndiFieldInjector(fields[i], jndiName, ctx));
-         }
-      }
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiMethodInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiMethodInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/JndiMethodInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,114 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.logging.Logger;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class JndiMethodInjector implements Injector, PojoInjector
-{
-   private static final Logger log = Logger.getLogger(JndiMethodInjector.class);
-   
-   private Method setMethod;
-   private String jndiName;
-   private Context ctx;
-
-   public JndiMethodInjector(Method setMethod, String jndiName, Context ctx)
-   {
-      this.setMethod = setMethod;
-      this.jndiName = jndiName;
-      this.ctx = ctx;
-   }
-
-   public void inject(BeanContext bctx)
-   {
-      inject(bctx, bctx.getInstance());
-   }
-   
-   public Class getInjectionClass()
-   {
-      return setMethod.getParameterTypes()[0];
-   }
-   
-   protected Object lookup(String jndiName, Class param)
-   {
-      Object dependency = null;
-      
-      try
-      {
-         dependency = ctx.lookup(jndiName);
-            
-         if (dependency instanceof javax.xml.rpc.Service && !param.isAssignableFrom(javax.xml.rpc.Service.class))
-         {
-            javax.xml.rpc.Service service = (javax.xml.rpc.Service)dependency;
-            dependency = service.getPort(param);
-         }
-      }
-      catch (NamingException e)
-      {
-         e.printStackTrace();
-         throw new RuntimeException("Unable to @Inject jndi dependency: " + jndiName + " into method " + setMethod, e);
-      }
-      catch (javax.xml.rpc.ServiceException e)
-      {
-         e.printStackTrace();
-         throw new RuntimeException("Unable to @Inject webservice jndi dependency: " + jndiName + " into method " + setMethod, e);
-      }
-      
-      return dependency;
-   }
-   
-   public void inject(BeanContext bctx, Object instance)
-   {
-      Object dependency = lookup(jndiName, setMethod.getParameterTypes()[0]);
-     
-      Object[] args = {dependency};
-      try
-      {
-         setMethod.invoke(instance, args);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         String type = "UNKNOWN";
-         if (dependency != null) type = dependency.getClass().getName();
-         throw new RuntimeException("Non matching type for @Inject of setter: " + setMethod + " for type: " + type, e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (InvocationTargetException e)
-      {
-         throw new RuntimeException(e.getCause());  //To change body of catch statement use Options | File Templates.
-      }
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/PersistenceContextHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/PersistenceContextHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/PersistenceContextHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,505 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.ejb3.injection;
-
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.stateful.StatefulContainer;
-import org.jboss.ejb3.metamodel.Injectable;
-import org.jboss.metamodel.descriptor.PersistenceContextRef;
-import org.jboss.ejb3.entity.*;
-import org.jboss.ejb3.interceptor.InterceptorInjector;
-import org.jboss.logging.Logger;
-import org.jboss.naming.Util;
-
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceContextType;
-import javax.persistence.PersistenceContexts;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-
-/**
- * Searches bean class for all
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- * @Inject and create Injectors
- */
-public class PersistenceContextHandler
-{
-   private static final Logger log = Logger
-           .getLogger(PersistenceContextHandler.class);
-
-   private static void loadXmlDependencies(List<PersistenceContextRef> refs,
-                                           InjectionContainer container)
-   {
-      for (PersistenceContextRef ref : refs)
-      {
-         container.getPuEncXmlEntries().put("env/" + ref.getRefName(),
-                 ref.getUnitName());
-         try
-         {
-            PersistenceUnitHandler
-                    .addPUDependency(ref.getUnitName(), container);
-         }
-         catch (NameNotFoundException e)
-         {
-            throw new RuntimeException("Illegal <persistence-context-ref> of "
-                    + ref.getRefName() + " :" + e.getMessage());
-
-         }
-      }
-   }
-
-   private static void loadXml(List<PersistenceContextRef> refs,
-                               InjectionContainer container, Class clazz,
-                               HashMap<AccessibleObject, Injector> injectors)
-   {
-      for (PersistenceContextRef ref : refs)
-      {
-         String encName = "env/" + ref.getRefName();
-         // add it to list of
-         String error = "unable to load <persistence-context-ref> for unitName: "
-                 + ref.getUnitName() + " <ref-name>: " + ref.getRefName();
-         PersistenceContextType type = ref.getPersistenceContextType();
-         String unitName = ref.getUnitName();
-         Class injectionType = null;
-         if (ref.getInjectionTarget() != null)
-         {
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, ref
-                    .getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectionType = ((Field) ao).getType();
-               injectors.put(ao, new JndiFieldInjector((Field) ao, encName,
-                       container.getEnc()));
-            }
-            else
-            {
-               injectionType = ((Method) ao).getParameterTypes()[0];
-               injectors.put(ao,
-                       new JndiMethodInjector((java.lang.reflect.Method) ao,
-                               encName, container.getEnc()));
-            }
-         }
-         bindPersistenceContext(container, unitName, error, type, encName,
-                 injectionType);
-      }
-   }
-
-   private static void bindPersistenceContext(InjectionContainer container,
-                                              String unitName, String error, PersistenceContextType type,
-                                              String encName, Class injectionType)
-   {
-      ManagedEntityManagerFactory factory = null;
-      try
-      {
-         factory = PersistenceUnitHandler.getManagedEntityManagerFactory(
-                 container, unitName);
-      }
-      catch (NameNotFoundException e)
-      {
-         error += " " + e.getMessage();
-      }
-      if (factory == null)
-      {
-         throw new RuntimeException(error);
-      }
-      if (type == PersistenceContextType.EXTENDED)
-      {
-         if (!(container instanceof StatefulContainer)) throw new RuntimeException("It is illegal to inject an EXTENDED PC into something other than a SFSB");
-         container.getExtendedPCs().put(factory.getKernelName(),
-                 new ExtendedPersistenceContextInjector(factory));
-         Object extendedPc = null;
-         if (injectionType == null
-                 || injectionType.getName().equals(EntityManager.class.getName()))
-         {
-            extendedPc = new ExtendedEntityManager(factory.getKernelName());
-         }
-         else
-         {
-            extendedPc = new ExtendedHibernateSession(factory.getKernelName());
-         }
-         try
-         {
-            Util.bind(container.getEnc(), encName, extendedPc);
-         }
-         catch (NamingException e)
-         {
-            throw new RuntimeException(error, e);
-         }
-      }
-      else
-      {
-         Object entityManager = null;
-         if (injectionType == null
-                 || injectionType.getName().equals(EntityManager.class.getName()))
-         {
-            entityManager = new TransactionScopedEntityManager(factory);
-         }
-         else
-         {
-            entityManager = new TransactionScopedHibernateSession(factory);
-         }
-         try
-         {
-            Util.bind(container.getEnc(), encName, entityManager);
-         }
-         catch (NamingException e)
-         {
-            throw new RuntimeException(error, e);
-         }
-      }
-   }
-
-   private static void loadPersistenceContextClassAnnotations(
-           InjectionContainer container, Class clazz)
-   {
-      PersistenceContexts resources = container.getAnnotation(PersistenceContexts.class, clazz);
-      if (resources != null)
-      {
-         for (PersistenceContext ref : resources.value())
-         {
-            loadPersistenceContextClassAnnotation(ref, container);
-         }
-      }
-      PersistenceContext pc = container.getAnnotation(PersistenceContext.class, clazz);
-
-      if (pc != null)
-      {
-         loadPersistenceContextClassAnnotation(pc, container);
-      }
-
-   }
-
-   private static void loadPersistenceContextClassAnnotation(
-           PersistenceContext ref, InjectionContainer container)
-   {
-      String encName = ref.name();
-      if (encName == null || encName.equals(""))
-      {
-         throw new RuntimeException(
-                 "JBoss requires name() for class level @PersistenceContext");
-      }
-      encName = "env/" + ref.name();
-      if (container.getPuEncXmlEntries().containsKey(encName))
-         return;
-
-      String error = "Unable to load class-level @PersistenceContext("
-              + ref.unitName() + ") on " + container.getIdentifier();
-      bindPersistenceContext(container, ref.unitName(), error, ref.type(),
-              encName, null);
-   }
-
-   private static void loadClassPUDependencies(InjectionContainer container,
-                                               Class clazz)
-   {
-      PersistenceContexts resources = container.getAnnotation(PersistenceContexts.class, clazz);
-      if (resources != null)
-      {
-         for (PersistenceContext ref : resources.value())
-         {
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               throw new RuntimeException(
-                       "JBoss requires name() for class level @PersistenceContext");
-            }
-            if (container.getPuEncXmlEntries().containsKey("env/" + encName))
-               continue;
-            try
-            {
-               PersistenceUnitHandler.addPUDependency(ref.unitName(),
-                       (EJBContainer) container);
-            }
-            catch (NameNotFoundException e)
-            {
-               throw new RuntimeException("Invalid " + clazz.getName()
-                       + " annotation @PersistenceContext: " + e.getMessage());
-            }
-         }
-      }
-      PersistenceContext pu = container.getAnnotation(PersistenceContext.class, clazz);
-      if (pu != null)
-      {
-         String encName = pu.name();
-         if (encName == null || encName.equals(""))
-         {
-            throw new RuntimeException(
-                    "JBoss requires name() for class level @PersistenceContext");
-         }
-         if (container.getPuEncXmlEntries().containsKey("env/" + encName))
-            return;
-         try
-         {
-            PersistenceUnitHandler.addPUDependency(pu.unitName(),
-                    (EJBContainer) container);
-         }
-         catch (NameNotFoundException e)
-         {
-            throw new RuntimeException("Invalid " + clazz.getName()
-                    + " annotation @PersistenceContext: " + e.getMessage());
-         }
-      }
-   }
-
-   public static void loadMethodDependencies(HashSet<String> visitedMethods,
-                                             InjectionContainer container, Class clazz)
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getDeclaredMethods();
-      for (int i = 0; i < methods.length; i++)
-      {
-         PersistenceContext ref = container.getAnnotation(PersistenceContext.class, clazz, methods[i]);
-         if (ref != null)
-         {
-            if (!Modifier.isPrivate(methods[i].getModifiers()))
-            {
-               if (visitedMethods.contains(methods[i].getName()))
-                  continue;
-               else
-                  visitedMethods.add(methods[i].getName());
-            }
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(methods[i]);
-            }
-            else
-            {
-               encName = "env/" + encName;
-            }
-            if (container.getPuEncXmlEntries().containsKey(encName))
-               continue;
-            try
-            {
-               PersistenceUnitHandler
-                       .addPUDependency(ref.unitName(), container);
-            }
-            catch (NameNotFoundException e)
-            {
-               throw new RuntimeException("Method " + methods[i].toString()
-                       + " @PersistenceContext in error: " + e.getMessage());
-            }
-         }
-      }
-      loadMethodDependencies(visitedMethods, container, clazz.getSuperclass());
-   }
-
-   private static void loadFieldDependencies(Class clazz,
-                                             InjectionContainer container)
-   {
-      if (clazz == null || clazz.equals(Object.class))
-         return;
-      loadFieldDependencies(clazz.getSuperclass(), container);
-      Field[] fields = clazz.getDeclaredFields();
-      for (int i = 0; i < fields.length; i++)
-      {
-         PersistenceContext ref = container.getAnnotation(PersistenceContext.class, clazz, fields[i]);
-         if (ref != null)
-         {
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(fields[i]);
-            }
-            else
-            {
-               encName = "env/" + encName;
-            }
-            if (container.getPuEncXmlEntries().containsKey(encName))
-               continue;
-            try
-            {
-               PersistenceUnitHandler
-                       .addPUDependency(ref.unitName(), container);
-            }
-            catch (NameNotFoundException e)
-            {
-               throw new RuntimeException("Field " + fields[i].toString()
-                       + " @PersistenceUnit in error: " + e.getMessage());
-            }
-         }
-      }
-   }
-
-   public static void loadInjectors(EJBContainer ejb) throws Exception
-   {
-      Class clazz = ejb.getBeanClass();
-      if (clazz == null)
-         throw new RuntimeException("CLAZZ CANNOT BE NULL");
-      loadInjectors(clazz, ejb.getXml(), ejb, ejb.getEncInjections());
-   }
-
-   public static void loadInjectors(InterceptorInjector injector)
-           throws Exception
-   {
-      loadInjectors(injector.getClazz(), injector.getXml(),
-              (EJBContainer) injector.getContainer(),
-              injector.getEncInjections());
-   }
-
-   private static void loadInjectors(Class clazz, Injectable xml,
-                                     InjectionContainer container,
-                                     HashMap<AccessibleObject, Injector> encInjections)
-           throws Exception
-   {
-      if (xml != null)
-      {
-         loadXml(xml.getPersistenceContextRefs(), container, clazz,
-                 encInjections);
-      }
-
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadPersistenceContextClassAnnotations(container, clazz);
-
-      loadMethodInjectors(visitedMethods, container, clazz, encInjections);
-      loadFieldInjectors(clazz, container, encInjections);
-   }
-
-   public static void loadDependencies(Injectable xml, InjectionContainer container,
-                                       Class clazz)
-   {
-      if (xml != null)
-      {
-         loadXmlDependencies(xml.getPersistenceContextRefs(), container);
-      }
-      loadClassPUDependencies(container, clazz);
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadMethodDependencies(visitedMethods, container, clazz);
-      loadFieldDependencies(clazz, container);
-
-   }
-
-   private static void loadMethodInjectors(HashSet<String> visitedMethods,
-                                           InjectionContainer container, Class clazz,
-                                           HashMap<AccessibleObject, Injector> injectors)
-           throws Exception
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getDeclaredMethods();
-      for (int i = 0; i < methods.length; i++)
-      {
-         PersistenceContext ref = container.getAnnotation(PersistenceContext.class,
-                         clazz, methods[i]);
-         if (ref != null)
-         {
-            if (!Modifier.isPrivate(methods[i].getModifiers()))
-            {
-               if (visitedMethods.contains(methods[i].getName()))
-                  continue;
-               else
-                  visitedMethods.add(methods[i].getName());
-            }
-
-            if (!methods[i].getName().startsWith("set"))
-               throw new RuntimeException(
-                       "@PersistenceContext can only be used with a set method: "
-                               + methods[i]);
-            if (methods[i].getParameterTypes().length != 1)
-               throw new RuntimeException(
-                       "@PersistenceContext can only be used with a set method of one parameter: "
-                               + methods[i]);
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(methods[i]);
-            }
-            else
-            {
-               encName = "env/" + ref.name();
-            }
-            String error = "@PersistenceContext(name='" + encName
-                    + "',unitName='" + ref.unitName() + "') on EJB: "
-                    + container.getIdentifier() + " failed to inject on method "
-                    + methods[i].toString();
-            boolean bindingExists = container.getPuEncXmlEntries().containsKey(
-                    encName);
-            if (!injectors.containsKey(methods[i]))
-            {
-               if (!bindingExists)
-                  bindPersistenceContext(container, ref.unitName(), error, ref
-                          .type(), encName, methods[i].getParameterTypes()[0]);
-               injectors.put(methods[i], new JndiMethodInjector(methods[i],
-                       encName, container.getEnc()));
-            }
-         }
-      }
-      loadMethodInjectors(visitedMethods, container, clazz.getSuperclass(),
-              injectors);
-   }
-
-   private static void loadFieldInjectors(Class clazz, InjectionContainer container,
-                                          HashMap<AccessibleObject, Injector> injectors)
-           throws Exception
-   {
-      if (clazz == null || clazz.equals(Object.class))
-         return;
-      loadFieldInjectors(clazz.getSuperclass(), container, injectors);
-      Field[] fields = clazz.getDeclaredFields();
-      for (int i = 0; i < fields.length; i++)
-      {
-         PersistenceContext ref = container.getAnnotation(PersistenceContext.class,
-                         clazz, fields[i]);
-         if (ref != null)
-         {
-            fields[i].setAccessible(true);
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(fields[i]);
-            }
-            else
-            {
-               encName = "env/" + ref.name();
-            }
-            String error = "@PersistenceContext(name='" + encName
-                    + "',unitName='" + ref.unitName() + "') on EJB: "
-                    + container.getIdentifier() + " failed to inject on field "
-                    + fields[i].toString();
-            boolean bindingExists = container.getPuEncXmlEntries().containsKey(
-                    encName);
-            if (!injectors.containsKey(fields[i]))
-            {
-               if (!bindingExists)
-                  bindPersistenceContext(container, ref.unitName(), error, ref
-                          .type(), encName, fields[i].getType());
-               injectors.put(fields[i], new JndiFieldInjector(fields[i],
-                       encName, container.getEnc()));
-            }
-         }
-      }
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/PersistenceUnitHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/PersistenceUnitHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/PersistenceUnitHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,522 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import org.hibernate.SessionFactory;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.metamodel.Injectable;
-import org.jboss.metamodel.descriptor.PersistenceUnitRef;
-import org.jboss.ejb3.entity.InjectedEntityManagerFactory;
-import org.jboss.ejb3.entity.InjectedSessionFactory;
-import org.jboss.ejb3.entity.ManagedEntityManagerFactory;
-import org.jboss.ejb3.entity.PersistenceUnitDeployment;
-import org.jboss.ejb3.interceptor.InterceptorInjector;
-import org.jboss.naming.Util;
-import org.jboss.logging.Logger;
-
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.PersistenceUnit;
-import javax.persistence.PersistenceUnits;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-
-/**
- * Searches bean class for all @Inject and create Injectors
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class PersistenceUnitHandler
-{
-   private static final Logger log = Logger
-           .getLogger(PersistenceContextHandler.class);
-
-   private static void loadXmlPUDependencies(List<PersistenceUnitRef> refs, InjectionContainer container)
-   {
-      for (PersistenceUnitRef ref : refs)
-      {
-         container.getPuEncXmlEntries().put("env/" + ref.getRefName(), ref.getUnitName());
-         try
-         {
-            addPUDependency(ref.getUnitName(), container);
-         }
-         catch (NameNotFoundException e)
-         {
-            throw new RuntimeException("Illegal <persistence-unit-ref> of " + ref.getRefName() + " :" + e.getMessage());
-         }
-      }
-   }
-
-   private static void loadPersistenceUnitRefXml(List<PersistenceUnitRef> refs, InjectionContainer container, Class clazz, HashMap<AccessibleObject, Injector> injectors)
-   {
-
-      for (PersistenceUnitRef ref : refs)
-      {
-         Class injectionType = null;
-         if (ref.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, ref.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectionType = ((Field) ao).getType();
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/" + ref.getRefName(), container.getEnc()));
-            }
-            else
-            {
-               injectionType = ((Method) ao).getParameterTypes()[0];
-               injectors.put(ao, new JndiMethodInjector((java.lang.reflect.Method) ao, "env/" + ref.getRefName(), container.getEnc()));
-            }
-         }
-         Object factory = null;
-         try
-         {
-            factory = getFactory(injectionType, ref.getUnitName(), container);
-         }
-         catch (NameNotFoundException e)
-         {
-            throw new RuntimeException(e);
-         }
-         if (factory == null)
-         {
-            throw new RuntimeException("Failed to load <persistence-unit-ref> of unit name: " + ref.getUnitName() + " for EJB " + container.getIdentifier());
-         }
-
-         try
-         {
-            Util.bind(container.getEnc(), "env/" + ref.getRefName(), factory);
-         }
-         catch (Exception e)
-         {
-            throw new RuntimeException("Failed to load <persistence-unit-ref> of unit name: " + ref.getUnitName() + " ref-name" + ref.getRefName() + container.getIdentifier(), e);
-         }
-      }
-   }
-
-
-   private static void loadPUsAnnotation(InjectionContainer container, Class clazz) throws Exception
-   {
-      PersistenceUnits resources = container.getAnnotation(
-              PersistenceUnits.class, clazz);
-      if (resources != null)
-      {
-         for (PersistenceUnit ref : resources.value())
-         {
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               throw new RuntimeException("JBoss requires name() for class level @PersistenceUnit");
-            }
-            // skip if already loaded by XML
-            if (container.getPuEncXmlEntries().containsKey("env/" + encName)) continue;
-
-            EntityManagerFactory factory = getEntityManagerFactory(ref, container);
-            bindEntityManagerFactoryToEnc(container, "env/" + encName, factory);
-         }
-      }
-      PersistenceUnit pu = container.getAnnotation(PersistenceUnit.class, clazz);
-      if (pu != null)
-      {
-         String encName = pu.name();
-         if (encName == null || encName.equals(""))
-         {
-            throw new RuntimeException("JBoss requires name() for class level @PersistenceUnit");
-         }
-         // skip if already loaded by XML
-         if (container.getPuEncXmlEntries().containsKey("env/" + encName)) return;
-
-         EntityManagerFactory factory = getEntityManagerFactory(pu, container);
-         if (factory == null)
-            throw new RuntimeException("Unable to find @PersistenceUnit: " + pu.unitName() + " on " + clazz.getName());
-         bindEntityManagerFactoryToEnc(container, "env/" + encName, factory);
-      }
-   }
-
-   private static void loadClassPUDependencies(InjectionContainer container, Class clazz)
-   {
-      PersistenceUnits resources = container.getAnnotation(
-              PersistenceUnits.class, clazz);
-      if (resources != null)
-      {
-         for (PersistenceUnit ref : resources.value())
-         {
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               throw new RuntimeException("JBoss requires name() for class level @PersistenceUnit");
-            }
-            // skip if already loaded by XML
-            if (container.getPuEncXmlEntries().containsKey("env/" + encName)) continue;
-            try
-            {
-               addPUDependency(ref.unitName(), container);
-            }
-            catch (NameNotFoundException e)
-            {
-               throw new RuntimeException("Invalid " + clazz.getName() + " annotation @PersistenceUnit: " + e.getMessage());
-            }
-         }
-      }
-      PersistenceUnit pu = container.getAnnotation(
-              PersistenceUnit.class, clazz);
-      if (pu != null)
-      {
-         String encName = pu.name();
-         if (encName == null || encName.equals(""))
-         {
-            throw new RuntimeException("JBoss requires name() for class level @PersistenceUnit");
-         }
-         // skip if already loaded by XML
-         if (container.getPuEncXmlEntries().containsKey("env/" + encName)) return;
-         try
-         {
-            addPUDependency(pu.unitName(), container);
-         }
-         catch (NameNotFoundException e)
-         {
-            throw new RuntimeException("Invalid " + clazz.getName() + " annotation @PersistenceUnit: " + e.getMessage());
-         }
-      }
-   }
-
-   public static void addPUDependency(String unitName, InjectionContainer container) throws NameNotFoundException
-   {
-      PersistenceUnitDeployment deployment = null;
-      // look in EAR first
-      deployment = container.getPersistenceUnitDeployment(unitName);
-      if (deployment != null)
-      {
-         container.getDependencyPolicy().addDependency(deployment.getKernelName());
-         return;
-      }
-      // probably not deployed yet.
-      container.getDependencyPolicy().addDependency(PersistenceUnitDeployment.getDefaultKernelName(unitName));
-   }
-
-   public static ManagedEntityManagerFactory getManagedEntityManagerFactory(InjectionContainer container, String unitName)
-           throws NameNotFoundException
-   {
-      ManagedEntityManagerFactory factory;
-      PersistenceUnitDeployment deployment = container.getPersistenceUnitDeployment(unitName);
-      if (deployment != null)
-      {
-         factory = deployment.getManagedFactory();
-      }
-      else
-      {
-         throw new NameNotFoundException("Unable to find persistence unit: " + unitName + " for deployment: " + container.getIdentifier());
-      }
-      return factory;
-   }
-
-
-   private static EntityManagerFactory getEntityManagerFactory(PersistenceUnit ref, InjectionContainer container) throws NameNotFoundException
-   {
-      return getEntityManagerFactory(ref.unitName(), container);
-   }
-
-   private static Object getFactory(Class type, String unitName, InjectionContainer container) throws NameNotFoundException
-   {
-      if (type != null && type.getName().equals(SessionFactory.class.getName()))
-         return getSessionFactory(unitName, container);
-      return getEntityManagerFactory(unitName, container);
-   }
-
-   private static EntityManagerFactory getEntityManagerFactory(String unitName, InjectionContainer container) throws NameNotFoundException
-   {
-      ManagedEntityManagerFactory managedFactory;
-      PersistenceUnitDeployment deployment = container.getPersistenceUnitDeployment(unitName);
-      if (deployment != null)
-      {
-         managedFactory = deployment.getManagedFactory();
-      }
-      else
-      {
-         return null;
-      }
-      return new InjectedEntityManagerFactory(managedFactory);
-   }
-
-
-   private static SessionFactory getSessionFactory(String ref, InjectionContainer container) throws NameNotFoundException
-   {
-      ManagedEntityManagerFactory managedFactory;
-      PersistenceUnitDeployment deployment = container.getPersistenceUnitDeployment(ref);
-      if (deployment != null)
-      {
-         managedFactory = deployment.getManagedFactory();
-      }
-      else
-      {
-         return null;
-      }
-      return new InjectedSessionFactory(managedFactory);
-   }
-
-   public static void loadInjectors(EJBContainer ejb) throws Exception
-   {
-      Class clazz = ejb.getBeanClass();
-      loadInjectors(clazz, ejb.getXml(), ejb, ejb.getEncInjections());
-   }
-
-   public static void loadInjectors(InterceptorInjector injector) throws Exception
-   {
-      loadInjectors(injector.getClazz(), injector.getXml(), (EJBContainer) injector.getContainer(), injector.getEncInjections());
-   }
-
-   private static void loadInjectors(Class clazz, Injectable xml, InjectionContainer container, HashMap<AccessibleObject, Injector> encInjections) throws Exception
-   {
-      if (xml != null)
-      {
-         loadPersistenceUnitRefXml(xml.getPersistenceUnitRefs(), container, clazz, encInjections);
-      }
-
-      HashSet<String> visitedMethods = new HashSet<String>();
-
-      loadPUsAnnotation(container, clazz);
-      loadMethodInjectors(visitedMethods, container, clazz, encInjections);
-      loadFieldInjectors(clazz, container, encInjections);
-   }
-
-   public static void loadDependencies(Injectable xml, InjectionContainer container, Class clazz)
-   {
-      if (xml != null)
-      {
-         loadXmlPUDependencies(xml.getPersistenceUnitRefs(), container);
-      }
-      loadClassPUDependencies(container, clazz);
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadMethodDependencies(visitedMethods, container, clazz);
-      loadFieldDependencies(clazz, container);
-
-   }
-
-   private static void bindEntityManagerFactoryToEnc(InjectionContainer container, String encName, Object factory)
-           throws NamingException
-   {
-      try
-      {
-         Util.bind(container.getEnc(), encName, factory);
-      }
-      catch (Exception e)
-      {
-         NamingException namingException = new NamingException("Could not bind entity manager factory for EJB container with ejb name " + container.getIdentifier() + " into JNDI under jndiName: " + container.getEnc().getNameInNamespace() + "/" + encName);
-         namingException.setRootCause(e);
-         throw namingException;
-      }
-   }
-
-   public static void loadMethodInjectors(HashSet<String> visitedMethods, InjectionContainer container, Class clazz, HashMap<AccessibleObject, Injector> injectors) throws Exception
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getDeclaredMethods();
-      for (int i = 0; i < methods.length; i++)
-      {
-         PersistenceUnit ref = container.getAnnotation(
-                 PersistenceUnit.class, clazz, methods[i]);
-         try
-         {
-            if (ref != null)
-            {
-               if (!Modifier.isPrivate(methods[i].getModifiers()))
-               {
-                  if (visitedMethods.contains(methods[i].getName())) continue;
-                  else visitedMethods.add(methods[i].getName());
-               }
-               if (!methods[i].getName().startsWith("set"))
-                  throw new RuntimeException("@PersistenceContext can only be used with a set method: " + methods[i]);
-               if (methods[i].getParameterTypes().length != 1)
-                  throw new RuntimeException("@PersistenceContext can only be used with a set method of one parameter: " + methods[i]);
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(methods[i]);
-               }
-               else
-               {
-                  encName = "env/" + ref.name();
-               }
-               String unitName = container.getPuEncXmlEntries().get(encName);
-               boolean bindingExists = false;
-               if (unitName == null) unitName = ref.unitName();
-               else bindingExists = true;
-               if (!injectors.containsKey(methods[i]))
-               {
-                  if (methods[i].getParameterTypes()[0].getName().equals(EntityManagerFactory.class.getName()))
-                  {
-                     EntityManagerFactory factory = getEntityManagerFactory(unitName, container);
-                     injectors.put(methods[i], new EntityManagerFactoryMethodInjector(methods[i], factory));
-                     if (!bindingExists) bindEntityManagerFactoryToEnc(container, encName, factory);
-                  }
-                  else
-                  {
-                     SessionFactory factory = getSessionFactory(unitName, container);
-                     injectors.put(methods[i], new EntityManagerFactoryMethodInjector(methods[i], factory));
-                     if (!bindingExists) bindEntityManagerFactoryToEnc(container, encName, factory);
-                  }
-               }
-            }
-         }
-         catch (Exception ex)
-         {
-            throw new RuntimeException("failed in processing injection annotation on method: " + methods[i].toString(), ex);
-         }
-      }
-      loadMethodInjectors(visitedMethods, container, clazz.getSuperclass(), injectors);
-   }
-
-   public static void loadMethodDependencies(HashSet<String> visitedMethods, InjectionContainer container, Class clazz)
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      Method[] methods = clazz.getDeclaredMethods();
-      for (int i = 0; i < methods.length; i++)
-      {
-         PersistenceUnit ref = container.getAnnotation(
-                 PersistenceUnit.class, clazz, methods[i]);
-         if (ref != null)
-         {
-            if (!Modifier.isPrivate(methods[i].getModifiers()))
-            {
-               if (visitedMethods.contains(methods[i].getName())) continue;
-               else visitedMethods.add(methods[i].getName());
-            }
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(methods[i]);
-            }
-            else
-            {
-               encName = "env/" + encName;
-            }
-            if (container.getPuEncXmlEntries().containsKey(encName)) continue;
-            try
-            {
-               addPUDependency(ref.unitName(), container);
-            }
-            catch (NameNotFoundException e)
-            {
-               throw new RuntimeException("Method " + methods[i].toString() + " @PersistenceUnit in error: " + e.getMessage());
-            }
-         }
-      }
-      loadMethodDependencies(visitedMethods, container, clazz.getSuperclass());
-   }
-
-   private static void loadFieldDependencies(Class clazz, InjectionContainer container)
-   {
-      if (clazz == null || clazz.equals(Object.class)) return;
-      loadFieldDependencies(clazz.getSuperclass(), container);
-      Field[] fields = clazz.getDeclaredFields();
-      for (int i = 0; i < fields.length; i++)
-      {
-         PersistenceUnit ref = container.getAnnotation(
-                 PersistenceUnit.class, clazz, fields[i]);
-         if (ref != null)
-         {
-            String encName = ref.name();
-            if (encName == null || encName.equals(""))
-            {
-               encName = InjectionUtil.getEncName(fields[i]);
-            }
-            else
-            {
-               encName = "env/" + encName;
-            }
-            if (container.getPuEncXmlEntries().containsKey(encName)) continue;
-            try
-            {
-               addPUDependency(ref.unitName(), container);
-            }
-            catch (NameNotFoundException e)
-            {
-               throw new RuntimeException("Field " + fields[i].toString() + " @PersistenceUnit in error: " + e.getMessage());
-            }
-         }
-      }
-   }
-
-   private static void loadFieldInjectors(Class clazz, InjectionContainer container, HashMap<AccessibleObject, Injector> injectors) throws Exception
-   {
-      if (clazz == null || clazz.equals(Object.class)) return;
-      loadFieldInjectors(clazz.getSuperclass(), container, injectors);
-      Field[] fields = clazz.getDeclaredFields();
-      for (int i = 0; i < fields.length; i++)
-      {
-         try
-         {
-            PersistenceUnit ref = container.getAnnotation(
-                    PersistenceUnit.class, clazz, fields[i]);
-            if (ref != null)
-            {
-               fields[i].setAccessible(true);
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(fields[i]);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-               String unitName = container.getPuEncXmlEntries().get(encName);
-               boolean bindingExists = false;
-               if (unitName == null) unitName = ref.unitName();
-               else bindingExists = true;
-               if (!injectors.containsKey(fields[i]))
-               {
-                  if (fields[i].getType().getName().equals(EntityManagerFactory.class.getName()))
-                  {
-                     EntityManagerFactory factory = getEntityManagerFactory(unitName, container);
-                     injectors.put(fields[i], new EntityManagerFactoryFieldInjector(fields[i], factory));
-                     if (!bindingExists) bindEntityManagerFactoryToEnc(container, encName, factory);
-                  }
-                  else
-                  {
-                     SessionFactory factory = getSessionFactory(unitName, container);
-                     injectors.put(fields[i], new EntityManagerFactoryFieldInjector(fields[i], factory));
-                     if (!bindingExists) bindEntityManagerFactoryToEnc(container, encName, factory);
-                  }
-               }
-            }
-         }
-         catch (Exception ex)
-         {
-            throw new RuntimeException("failed in processing injection annotation on field: " + fields[i].toString(), ex);
-         }
-      }
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/PojoInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/PojoInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/PojoInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,34 +0,0 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt in the distribution for a
-* full listing of individual contributors.
-*
-* This is free software; you can redistribute it and/or modify it
-* under the terms of the GNU Lesser General Public License as
-* published by the Free Software Foundation; either version 2.1 of
-* the License, or (at your option) any later version.
-*
-* This software is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this software; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
-package org.jboss.ejb3.injection;
-
-import org.jboss.ejb3.BeanContext;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- */
-public interface PojoInjector
-{
-   void inject(BeanContext ctx, Object instance);
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/ResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/ResourceHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/ResourceHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,394 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.interceptor.InterceptorInjector;
-import org.jboss.ejb3.metamodel.Injectable;
-import org.jboss.logging.Logger;
-import org.jboss.metamodel.descriptor.MessageDestinationRef;
-import org.jboss.metamodel.descriptor.ResourceEnvRef;
-import org.jboss.metamodel.descriptor.ResourceRef;
-
-import javax.annotation.Resource;
-import javax.annotation.Resources;
-import javax.ejb.EJBContext;
-import javax.ejb.TimerService;
-import javax.naming.Context;
-import javax.transaction.UserTransaction;
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-
-/**
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class ResourceHandler
-{
-   private static final Logger log = Logger.getLogger(ResourceHandler.class);
-
-
-   private static void loadXmlResourceRefs(InjectionContainer container, Collection<ResourceRef> refs, Class clazz, HashMap<AccessibleObject, Injector> injectors)
-   {
-      for (ResourceRef envRef : refs)
-      {
-         if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
-         {
-            throw new RuntimeException("mapped-name is required for " + envRef.getResRefName() + " of deployment " + container.getIdentifier());
-         }
-         else
-            container.getEncLinkRefEntries().put("env/" + envRef.getResRefName(), envRef.getMappedName());
-
-         if (envRef.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, envRef.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/" + envRef.getResRefName(), container.getEnc()));
-            }
-            else
-            {
-               injectors.put(ao, new JndiMethodInjector((java.lang.reflect.Method) ao, "env/" + envRef.getResRefName(), container.getEnc()));
-            }
-         }
-      }
-   }
-
-   private static void loadXmlResourceEnvRefs(InjectionContainer container, Collection<ResourceEnvRef> refs, Class clazz, HashMap<AccessibleObject, Injector> injectors)
-   {
-      for (ResourceEnvRef envRef : refs)
-      {
-         if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
-            log.warn("mapped-name is required for " + envRef.getResRefName() + " of deployment " + container.getIdentifier());
-         else
-            container.getEncLinkRefEntries().put("env/" + envRef.getResRefName(), envRef.getMappedName());
-
-         if (envRef.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, envRef.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/" + envRef.getResRefName(), container.getEnc()));
-            }
-            else
-            {
-               injectors.put(ao, new JndiMethodInjector((java.lang.reflect.Method) ao, "env/" + envRef.getResRefName(), container.getEnc()));
-            }
-         }
-      }
-   }
-
-   private static void loadXmlMessageDestinationRefs(InjectionContainer container, Collection<MessageDestinationRef> refs, Class clazz, HashMap<AccessibleObject, Injector> injectors)
-   {
-      for (MessageDestinationRef envRef : refs)
-      {
-         if (envRef.getMappedName() == null || envRef.getMappedName().equals(""))
-            log.warn("mapped-name is required for " + envRef.getMessageDestinationRefName() + " of deployment " + container.getIdentifier());
-         else
-            container.getEncLinkRefEntries().put("env/" + envRef.getMessageDestinationRefName(), envRef.getMappedName());
-
-         if (envRef.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, envRef.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/" + envRef.getMessageDestinationRefName(), container.getEnc()));
-            }
-            else
-            {
-               injectors.put(ao, new JndiMethodInjector((java.lang.reflect.Method) ao, "env/" + envRef.getMessageDestinationRefName(), container.getEnc()));
-            }
-         }
-      }
-   }
-
-   private static void loadClassRefs(InjectionContainer container, Class clazz) throws Exception
-   {
-      Resources resources = container.getAnnotation(Resources.class, clazz);
-      if (resources == null) return;
-      for (Resource ref : resources.value())
-      {
-         String encName = ref.name();
-         if (encName == null || encName.equals(""))
-         {
-            throw new RuntimeException("JBoss requires name() for class level @Resource");
-         }
-         encName = "env/" + encName;
-         String mappedName = ref.mappedName();
-         if (mappedName == null || mappedName.equals(""))
-         {
-            if (!container.getEncLinkRefEntries().containsKey(encName))
-            {
-               throw new RuntimeException("You did not specify a @Resource.mappedName() on " + clazz.getName() + " and there is no binding for that enc name in XML");
-            }
-            continue;
-         }
-
-         if (!container.hasEncEntry(encName))
-         {
-            container.getEncLinkRefEntries().put(encName, mappedName);
-         }
-      }
-   }
-
-
-   private static void loadMethodInjectors(HashSet<String> methods, InjectionContainer container, Class clazz, HashMap<AccessibleObject, Injector> injectors, Context ctx)
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      for (Method method : clazz.getDeclaredMethods())
-      {
-         Resource ref = container.getAnnotation(Resource.class, clazz, method);
-         if (ref != null)
-         {
-            if (!Modifier.isPrivate(method.getModifiers()))
-            {
-               if (methods.contains(method.getName())) continue;
-               else methods.add(method.getName());
-            }
-            method.setAccessible(true);
-
-            if (injectors.containsKey(method)) continue;
-
-            if (!method.getName().startsWith("set"))
-               throw new RuntimeException("@Resource can only be used with a set method: " + method);
-            if (method.getParameterTypes().length != 1)
-               throw new RuntimeException("@Resource can only be used with a set method of one parameter: " + method);
-            Class type = method.getParameterTypes()[0];
-            if (!ref.type().equals(Object.class))
-            {
-               type = ref.type();
-            }
-            if (type.equals(UserTransaction.class))
-            {
-               injectors.put(method, new UserTransactionMethodInjector(method, container));
-            }
-            else if (type.equals(TimerService.class))
-            {
-               injectors.put(method, new TimerServiceMethodInjector(method, (Container) container)); // only EJBs
-            }
-            else if (EJBContext.class.isAssignableFrom(type))
-            {
-               injectors.put(method, new EJBContextMethodInjector(method));
-            }
-            else if (type.equals(String.class)
-                    || type.equals(Character.class)
-                    || type.equals(Byte.class)
-                    || type.equals(Short.class)
-                    || type.equals(Integer.class)
-                    || type.equals(Long.class)
-                    || type.equals(Boolean.class)
-                    || type.equals(Double.class)
-                    || type.equals(Float.class)
-                    || type.isPrimitive()
-                    )
-            {
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(method);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-
-               if (container.hasEnvEntry(encName.substring(4)))
-               {
-                  injectors.put(method, new JndiMethodInjector(method, encName, ctx));
-               }
-            }
-            else
-            {
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(method);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-
-               if (!injectors.containsKey(method))
-               {
-                  injectors.put(method, new JndiMethodInjector(method, encName, ctx));
-               }
-
-               String mappedName = ref.mappedName();
-               if (mappedName == null || mappedName.equals(""))
-               {
-                  if (!container.getEncLinkRefEntries().containsKey(encName))
-                  {
-                     throw new RuntimeException("You did not specify a @Resource.mappedName() on " + method + " and there is no binding for that enc name in XML");
-                  }
-                  continue;
-               }
-
-               if (!container.hasEncEntry(encName))
-               {
-                  container.getEncLinkRefEntries().put(encName, mappedName);
-               }
-            }
-         }
-      }
-      if (clazz != null && !clazz.equals(Object.class))
-      {
-         loadMethodInjectors(methods, container, clazz.getSuperclass(), injectors, ctx);
-      }
-   }
-
-
-   private static void loadFieldInjectors(InjectionContainer container, Class clazz, HashMap<AccessibleObject, Injector> injectors, Context ctx)
-   {
-      if (clazz != null && !clazz.equals(Object.class))
-      {
-         loadFieldInjectors(container, clazz.getSuperclass(), injectors, ctx);
-      }
-      for (Field field : clazz.getDeclaredFields())
-      {
-         Resource ref = container.getAnnotation(Resource.class, clazz, field);
-         if (ref != null)
-         {
-            field.setAccessible(true);
-
-            if (injectors.containsKey(field)) continue;
-
-            Class type = field.getType();
-            if (!ref.type().equals(Object.class))
-            {
-               type = ref.type();
-            }
-            if (type.equals(UserTransaction.class))
-            {
-               injectors.put(field, new UserTransactionFieldInjector(field, container));
-            }
-            else if (type.equals(TimerService.class))
-            {
-               injectors.put(field, new TimerServiceFieldInjector(field, (Container) container));
-            }
-            else if (EJBContext.class.isAssignableFrom(type))
-            {
-               injectors.put(field, new EJBContextFieldInjector(field));
-            }
-            else if (type.equals(String.class)
-                    || type.equals(Character.class)
-                    || type.equals(Byte.class)
-                    || type.equals(Short.class)
-                    || type.equals(Integer.class)
-                    || type.equals(Long.class)
-                    || type.equals(Boolean.class)
-                    || type.equals(Double.class)
-                    || type.equals(Float.class)
-                    || type.isPrimitive()
-                    )
-            {
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(field);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-
-               if (container.hasEnvEntry(encName.substring(4)))
-               {
-                  injectors.put(field, new JndiFieldInjector(field, encName, ctx));
-               }
-            }
-            else
-            {
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(field);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-
-               if (!injectors.containsKey(field))
-               {
-                  injectors.put(field, new JndiFieldInjector(field, encName, ctx));
-               }
-
-               String mappedName = ref.mappedName();
-               if (mappedName == null || mappedName.equals(""))
-               {
-                  if (!container.getEncLinkRefEntries().containsKey(encName))
-                  {
-                     throw new RuntimeException("You did not specify a @Resource.mappedName() on " + field + " and there is no binding for that enc name in XML");
-                  }
-                  continue;
-               }
-
-
-               if (!container.hasEncEntry(encName))
-               {
-                  container.getEncLinkRefEntries().put(encName, mappedName);
-               }
-            }
-         }
-      }
-   }
-
-   public static void loadInjectors(Container container) throws Exception
-   {
-      Class clazz = container.getBeanClass();
-      EJBContainer ejb = (EJBContainer) container;
-      loadInjectors(clazz, ejb.getXml(), ejb, ejb.getEncInjections());
-   }
-
-   public static void loadInjectors(InterceptorInjector injector) throws Exception
-   {
-      loadInjectors(injector.getClazz(), injector.getXml(), (EJBContainer) injector.getContainer(), injector.getEncInjections());
-   }
-
-   private static void loadInjectors(Class clazz, Injectable xml, InjectionContainer ejb, HashMap<AccessibleObject, Injector> injectors) throws Exception
-   {
-      Context resourceCtx = ejb.getEnc();
-      if (xml != null)
-      {
-         loadXmlResourceRefs(ejb, xml.getResourceRefs(), clazz, injectors);
-         loadXmlResourceEnvRefs(ejb, xml.getResourceEnvRefs(), clazz, injectors);
-         loadXmlMessageDestinationRefs(ejb, xml.getMessageDestinationRefs(), clazz, injectors);
-      }
-      loadClassRefs(ejb, clazz);
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadMethodInjectors(visitedMethods, ejb, clazz, injectors, resourceCtx);
-      loadFieldInjectors(ejb, clazz, injectors, resourceCtx);
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/TimerServiceFieldInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/TimerServiceFieldInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/TimerServiceFieldInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,66 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.Field;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class TimerServiceFieldInjector implements Injector
-{
-   private Field field;
-   private Container container;
-
-   public TimerServiceFieldInjector(Field field, Container container)
-   {
-      this.field = field;
-      this.field.setAccessible(true);
-      this.container = container;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      try
-      {
-         field.set(ctx.getInstance(), container.getTimerService());
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException("Failed in setting EntityManager on setter field: " + field.toString());
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return field.getType();
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/TimerServiceMethodInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/TimerServiceMethodInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/TimerServiceMethodInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,72 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class TimerServiceMethodInjector implements Injector
-{
-   private Method setMethod;
-   private Container container;
-
-   public TimerServiceMethodInjector(Method setMethod, Container container)
-   {
-      this.setMethod = setMethod;
-      this.container = container;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-
-      Object[] args = {container.getTimerService()};
-      try
-      {
-         setMethod.invoke(ctx.getInstance(), args);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException("Failed in setting EntityManager on setter method: " + setMethod.toString());
-      }
-      catch (InvocationTargetException e)
-      {
-         throw new RuntimeException(e.getCause());  //To change body of catch statement use Options | File Templates.
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return setMethod.getParameterTypes()[0];
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/UserTransactionFieldInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/UserTransactionFieldInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/UserTransactionFieldInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,76 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.Field;
-import javax.ejb.TransactionManagementType;
-import javax.transaction.UserTransaction;
-import org.jboss.aop.Advisor;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.tx.TxUtil;
-import org.jboss.ejb3.tx.UserTransactionImpl;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class UserTransactionFieldInjector implements Injector
-{
-   private Field field;
-
-   public UserTransactionFieldInjector(Field field, InjectionContainer container)
-   {
-      if (container instanceof Container)
-      {
-         TransactionManagementType type = TxUtil.getTransactionManagementType(((Advisor) container));
-         if (type != TransactionManagementType.BEAN)
-            throw new IllegalStateException("Container " + ((Container) container).getEjbName() + ": it is illegal to inject UserTransaction into a CMT bean");
-      }
-      this.field = field;
-      this.field.setAccessible(true);
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      UserTransaction ut = new UserTransactionImpl();
-      try
-      {
-         field.set(ctx.getInstance(), ut);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException("Failed in setting EntityManager on setter field: " + field.toString());
-      }
-   }
-   
-   public Class getInjectionClass()
-   {
-      return field.getType();
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/UserTransactionMethodInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/UserTransactionMethodInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/UserTransactionMethodInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,82 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import org.jboss.aop.Advisor;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.tx.TxUtil;
-import org.jboss.ejb3.tx.UserTransactionImpl;
-
-import javax.ejb.TransactionManagementType;
-import javax.transaction.UserTransaction;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Comment
- *
- * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
- * @version $Revision$
- */
-public class UserTransactionMethodInjector implements Injector
-{
-   private Method setMethod;
-
-   public UserTransactionMethodInjector(Method setMethod, InjectionContainer container)
-   {
-      if (container instanceof Container)
-      {
-         TransactionManagementType type = TxUtil.getTransactionManagementType(((Advisor) container));
-         if (type != TransactionManagementType.BEAN)
-            throw new IllegalStateException("Container " + ((Container) container).getEjbName() + ": it is illegal to inject UserTransaction into a CMT bean");
-      }
-      this.setMethod = setMethod;
-   }
-
-   public void inject(BeanContext ctx)
-   {
-      UserTransaction ut = new UserTransactionImpl();
-      Object[] args = {ut};
-      try
-      {
-         setMethod.invoke(ctx.getInstance(), args);
-      }
-      catch (IllegalAccessException e)
-      {
-         throw new RuntimeException(e);  //To change body of catch statement use Options | File Templates.
-      }
-      catch (IllegalArgumentException e)
-      {
-         throw new RuntimeException("Failed in setting EntityManager on setter method: " + setMethod.toString());
-      }
-      catch (InvocationTargetException e)
-      {
-         throw new RuntimeException(e.getCause());  //To change body of catch statement use Options | File Templates.
-      }
-   }
-
-   public Class getInjectionClass()
-   {
-      return setMethod.getParameterTypes()[0];
-   }
-}

Deleted: trunk/ejb3/src/main/org/jboss/ejb3/injection/WebServiceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/injection/WebServiceHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/injection/WebServiceHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -1,350 +0,0 @@
-/*
-  * JBoss, Home of Professional Open Source
-  * Copyright 2005, JBoss Inc., and individual contributors as indicated
-  * by the @authors tag. See the copyright.txt in the distribution for a
-  * full listing of individual contributors.
-  *
-  * This is free software; you can redistribute it and/or modify it
-  * under the terms of the GNU Lesser General Public License as
-  * published by the Free Software Foundation; either version 2.1 of
-  * the License, or (at your option) any later version.
-  *
-  * This software is distributed in the hope that it will be useful,
-  * but WITHOUT ANY WARRANTY; without even the implied warranty of
-  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-  * Lesser General Public License for more details.
-  *
-  * You should have received a copy of the GNU Lesser General Public
-  * License along with this software; if not, write to the Free
-  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
-  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-  */
-package org.jboss.ejb3.injection;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-
-import javax.ejb.EJBContext;
-import javax.ejb.TimerService;
-import javax.naming.Context;
-import javax.transaction.UserTransaction;
-import org.jboss.ejb3.Container;
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.ejb3.metamodel.Injectable;
-import org.jboss.metamodel.descriptor.WebServiceRef;
-import org.jboss.ejb3.interceptor.InterceptorInjector;
-import org.jboss.logging.Logger;
-
-/**
- * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
- * @version <tt>$Revision$</tt>
- */
-public class WebServiceHandler
-{
-   private static final Logger log = Logger.getLogger(WebServiceHandler.class);
-   
-   private static void loadXmlWebServiceRefs(EJBContainer container, Collection<WebServiceRef> refs, Class clazz, HashMap<AccessibleObject, Injector> injectors)
-   {
-      for (WebServiceRef wsRef : refs)
-      {
-         if (wsRef.getMappedName() == null || wsRef.getMappedName().equals(""))
-            throw new RuntimeException("mapped-name is required for " + wsRef.getServiceRefName() + " of EJB " + container.getEjbName());
-         else
-            container.getEncLinkRefEntries().put("env/" + wsRef.getServiceRefName(), wsRef.getMappedName());
-
-         if (wsRef.getInjectionTarget() != null)
-         {
-            // todo, get injection target class
-            AccessibleObject ao = InjectionUtil.findInjectionTarget(clazz, wsRef.getInjectionTarget());
-            if (ao instanceof Field)
-            {
-               injectors.put(ao, new JndiFieldInjector((Field) ao, "env/" + wsRef.getServiceRefName(), container.getEnc()));
-            }
-            else
-            {
-               injectors.put(ao, new JndiMethodInjector((java.lang.reflect.Method) ao, "env/" + wsRef.getServiceRefName(), container.getEnc()));
-            }
-         }
-      }
-   }
-
- /*  private static void loadClassRefs(EJBContainer container, Class clazz, boolean isContainer) throws Exception
-   {
-      Resources resources = (Resources) InjectionUtil.getAnnotation(Resources.class, container, clazz, isContainer);
-      if (resources == null) return;
-      for (WebServiceRef ref : resources.value())
-      {
-         String encName = ref.name();
-         if (encName == null || encName.equals(""))
-         {
-            throw new RuntimeException("JBoss requires name() for class level @WebServiceRef");
-         }
-         String mappedName = ref.mappedName();
-         if (mappedName == null || mappedName.equals(""))
-         {
-            if (!container.getEncLinkRefEntries().containsKey(encName))
-            {
-               throw new RuntimeException("You did not specify a @WebServiceRef.mappedName() on " + clazz.getName() + " and there is no binding for that enc name in XML");
-            }
-            continue;
-         }
-
-         if (!container.hasEncEntry(encName))
-         {
-            container.addEncLinkRefEntry(encName, mappedName);
-         }
-      }
-   }*/
-
-   private static void loadMethodInjectors(HashSet<String> methods, EJBContainer container, Class clazz, HashMap<AccessibleObject, Injector> injectors, Context ctx, boolean isContainer)
-   {
-      if (clazz == null || clazz.equals(Object.class))
-      {
-         return;
-      }
-      for (Method method : clazz.getDeclaredMethods())
-      {
-         javax.xml.ws.WebServiceRef ref = (javax.xml.ws.WebServiceRef)InjectionUtil.getAnnotation(javax.xml.ws.WebServiceRef.class, container, method, isContainer);
-         if (ref != null)
-         {
-            if (!Modifier.isPrivate(method.getModifiers()))
-            {
-               if (methods.contains(method.getName())) continue;
-               else methods.add(method.getName());
-            }
-            method.setAccessible(true);
-
-            if (injectors.containsKey(method)) continue;
-
-            if (!method.getName().startsWith("set")) throw new RuntimeException("@WebServiceRef can only be used with a set method: " + method);
-            if (method.getParameterTypes().length != 1) throw new RuntimeException("@WebServiceRef can only be used with a set method of one parameter: " + method);
-            Class type = method.getParameterTypes()[0];
-            if (!ref.type().equals(Object.class))
-            {
-               type = ref.type();
-            }
-            if (type.equals(UserTransaction.class))
-            {
-               injectors.put(method, new UserTransactionMethodInjector(method, container));
-            }
-            else if (type.equals(TimerService.class))
-            {
-               injectors.put(method, new TimerServiceMethodInjector(method, container));
-            }
-            else if (EJBContext.class.isAssignableFrom(type))
-            {
-               injectors.put(method, new EJBContextMethodInjector(method));
-            }
-            else if (type.equals(String.class)
-                     || type.equals(Character.class)
-                     || type.equals(Byte.class)
-                     || type.equals(Short.class)
-                     || type.equals(Integer.class)
-                     || type.equals(Long.class)
-                     || type.equals(Boolean.class)
-                     || type.equals(Double.class)
-                     || type.equals(Float.class)
-                     || type.isPrimitive()
-                    )
-            {
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(method);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-
-               if (container.hasEnvEntry(encName.substring(4)))
-               {
-                  injectors.put(method, new JndiMethodInjector(method, encName, ctx));
-               }
-            }
-            else
-            {
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(method);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-
-               if (!injectors.containsKey(method))
-               {
-                  injectors.put(method, new JndiMethodInjector(method, encName, ctx));
-               }
-
-               String mappedName = ref.mappedName();
-               if (mappedName == null || mappedName.equals(""))
-               {
-                  if (!container.getEncLinkRefEntries().containsKey(encName))
-                  {
-                     throw new RuntimeException("You did not specify a @WebServiceRef.mappedName() on " + method + " and there is no binding for that enc name in XML");
-                  }
-                  continue;
-               }
-
-               if (!container.hasEncEntry(encName))
-               {
-                  container.getEncLinkRefEntries().put(encName, mappedName);
-               }
-            }
-         }
-      }
-      if (clazz != null && !clazz.equals(Object.class))
-      {
-         loadMethodInjectors(methods, container, clazz.getSuperclass(), injectors, ctx, isContainer);
-      }
-   }
-
-
-   private static void loadFieldInjectors(EJBContainer container, Class clazz, HashMap<AccessibleObject, Injector> injectors, Context ctx, boolean isContainer)
-   {
-      if (clazz != null && !clazz.equals(Object.class))
-      {
-         loadFieldInjectors(container, clazz.getSuperclass(), injectors, ctx, isContainer);
-      }
-      for (Field field : clazz.getDeclaredFields())
-      {
-         javax.xml.ws.WebServiceRef ref = (javax.xml.ws.WebServiceRef)InjectionUtil.getAnnotation(javax.xml.ws.WebServiceRef.class, container, field, isContainer);
-         if (ref != null)
-         {
-            field.setAccessible(true);
-
-            if (injectors.containsKey(field)) continue;
-
-            Class type = field.getType();
-            if (!ref.type().equals(Object.class))
-            {
-               type = ref.type();
-            }
-            if (type.equals(UserTransaction.class))
-            {
-               if (!isContainer)
-               {
-                  log.debug("Skipping UserTransaction for interceptor " + clazz);
-               }
-               else
-               {
-                  injectors.put(field, new UserTransactionFieldInjector(field, container));
-               }
-            }
-            else if (type.equals(TimerService.class))
-            {
-               if (!isContainer)
-               {
-                  log.debug("Skipping TimerService for interceptor " + clazz);
-               }
-               else
-               {
-                  injectors.put(field, new TimerServiceFieldInjector(field, container));
-               }
-            }
-            else if (EJBContext.class.isAssignableFrom(type))
-            {
-               injectors.put(field, new EJBContextFieldInjector(field));
-            }
-            else if (type.equals(String.class)
-                     || type.equals(Character.class)
-                     || type.equals(Byte.class)
-                     || type.equals(Short.class)
-                     || type.equals(Integer.class)
-                     || type.equals(Long.class)
-                     || type.equals(Boolean.class)
-                     || type.equals(Double.class)
-                     || type.equals(Float.class)
-                     || type.isPrimitive()
-                    )
-            {
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(field);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-                
-               if (container.hasEnvEntry(encName.substring(4)))
-               {
-                  injectors.put(field, new JndiFieldInjector(field, encName, ctx));
-               }
-            }
-            else
-            {
-               String encName = ref.name();
-               if (encName == null || encName.equals(""))
-               {
-                  encName = InjectionUtil.getEncName(field);
-               }
-               else
-               {
-                  encName = "env/" + encName;
-               }
-
-               if (!injectors.containsKey(field))
-               {
-                  injectors.put(field, new JndiFieldInjector(field, encName, ctx));
-               }
-
-               String mappedName = ref.mappedName();
-               if (mappedName == null || mappedName.equals(""))
-               {
-                  if (!container.getEncLinkRefEntries().containsKey(encName))
-                  {
-                     throw new RuntimeException("You did not specify a @WebServiceRef.mappedName() on " + field + " and there is no binding for that enc name in XML");
-                  }
-                  continue;
-               }
-            
-
-               if (!container.hasEncEntry(encName))
-               {
-                  container.getEncLinkRefEntries().put(encName, mappedName);
-               }
-            }
-         }
-      }
-   }
-
-   public static void loadInjectors(Container container) throws Exception
-   {
-      Class clazz = container.getBeanClass();
-      EJBContainer ejb = (EJBContainer)container;
-      loadInjectors(clazz, ejb.getXml(), ejb, ejb.getEncInjections(), true);
-   }
-   
-   public static void loadInjectors(InterceptorInjector injector)throws Exception
-   {
-      loadInjectors(injector.getClazz(), injector.getXml(), (EJBContainer)injector.getContainer(), injector.getEncInjections(), false);
-   }
-   
-   private static void loadInjectors(Class clazz, Injectable xml, EJBContainer ejb, HashMap<AccessibleObject, Injector> injectors, boolean isContainer) throws Exception
-   {
-      try
-      {
-      Context resourceCtx = ejb.getEnc();
-      if (xml != null)
-      {
-         loadXmlWebServiceRefs(ejb, xml.getWebServiceRefs(), clazz, injectors);
-      }
- //     loadClassRefs(ejb, clazz, isContainer);
-      HashSet<String> visitedMethods = new HashSet<String>();
-      loadMethodInjectors(visitedMethods, ejb, clazz, injectors, resourceCtx, isContainer);
-      loadFieldInjectors(ejb, clazz, injectors, resourceCtx, isContainer);
-      } catch (Exception e){
-         e.printStackTrace();
-      }
-   }
-}

Modified: trunk/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsInterceptor.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsInterceptor.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/interceptor/EJB3InterceptorsInterceptor.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -53,7 +53,7 @@
    public Object invoke(Invocation invocation) throws Throwable
    {
       EJBContainerInvocation inv = (EJBContainerInvocation) invocation;
-      
+                                
       //We need to do this every time to make sure we have interceptor instances corresponding 
       //to the bean instance
       //TODO Cache this for non-stateful beans?

Modified: trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/interceptor/InterceptorInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -21,23 +21,16 @@
 */ 
 package org.jboss.ejb3.interceptor;
 
-import java.lang.reflect.AccessibleObject;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
 import org.jboss.ejb3.BeanContext;
 import org.jboss.ejb3.Container;
 import org.jboss.ejb3.EJBContainer;
+import org.jboss.injection.Injector;
+import org.jboss.injection.PojoInjector;
 import org.jboss.ejb3.metamodel.Interceptor;
-import org.jboss.ejb3.injection.EJBHandler;
-import org.jboss.ejb3.injection.Injector;
-import org.jboss.ejb3.injection.JndiInjectHandler;
-import org.jboss.ejb3.injection.PersistenceContextHandler;
-import org.jboss.ejb3.injection.PersistenceUnitHandler;
-import org.jboss.ejb3.injection.PojoInjector;
-import org.jboss.ejb3.injection.ResourceHandler;
-import org.jboss.ejb3.injection.WebServiceHandler;
 
+import java.lang.reflect.AccessibleObject;
+import java.util.Map;
+
 /**
  * 
  * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
@@ -48,30 +41,15 @@
    EJBContainer container;
    InterceptorInfo info;
    PojoInjector[] injectors;
-   protected HashMap<AccessibleObject, Injector> encInjections = new HashMap<AccessibleObject, Injector>();
+   protected Map<AccessibleObject, Injector> encInjections;
    
-   public InterceptorInjector(Container container, InterceptorInfo info) throws Exception
+   public InterceptorInjector(Container container, InterceptorInfo info, Map<AccessibleObject, Injector> injections)
    {
       this.container = (EJBContainer)container;
       this.info = info;
-
-      List list = new ArrayList();
-      list.addAll(JndiInjectHandler.loadInjectors(this));
-      ResourceHandler.loadInjectors(this);
-      EJBHandler.loadInjectors(this);
-      WebServiceHandler.loadInjectors(this);
-      //list.addAll(DependsHandler.loadInjectors(this));
-      PersistenceContextHandler.loadInjectors(this);
-      PersistenceUnitHandler.loadInjectors(this);
-      list.addAll(encInjections.values());
-      injectors = (PojoInjector[]) list.toArray(new PojoInjector[list.size()]);
+      injectors = injections.values().toArray(new PojoInjector[injections.size()]);
    }
 
-   public HashMap<AccessibleObject, Injector> getEncInjections()
-   {
-      return encInjections;
-   }
-   
    public Interceptor getXml()
    {
       return info.getXml();

Modified: trunk/ejb3/src/main/org/jboss/ejb3/interceptor/LifecycleInterceptorHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/interceptor/LifecycleInterceptorHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/interceptor/LifecycleInterceptorHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -34,7 +34,9 @@
 
 import org.jboss.ejb3.BeanContext;
 import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.stateful.StatefulBeanContext;
 import org.jboss.util.MethodHashing;
+import org.jboss.logging.Logger;
 
 /**
  * 
@@ -43,6 +45,8 @@
  */
 public class LifecycleInterceptorHandler
 {
+   private static final Logger log = Logger.getLogger(LifecycleInterceptorHandler.class);
+
    private EJBContainer container;
    private InterceptorInfo[] postConstructs;
    private InterceptorInfo[] postActivates;
@@ -54,7 +58,7 @@
    private Method[] beanPreDestroys;
    private Method timeoutCallbackMethod;
    private long timeoutCalllbackHash;
-   
+
    public LifecycleInterceptorHandler(EJBContainer container, Class[] handledCallbacks)
    {
       this.container = container;
@@ -87,7 +91,7 @@
          }
       }
    }
-   
+
    public long getTimeoutCalllbackHash()
    {
       return timeoutCalllbackHash;
@@ -98,9 +102,9 @@
       try
       {
          InvocationContext ic = LifecycleInvocationContextImpl.getLifecycleInvocationContext(
-               PostConstruct.class, 
-               ctx, 
-               postConstructs, 
+               PostConstruct.class,
+               ctx,
+               postConstructs,
                beanPostConstructs);
          ic.proceed();
       }
@@ -112,11 +116,16 @@
 
    public void preDestroy(BeanContext ctx)
    {
+      Object id = null;
+      if (ctx instanceof StatefulBeanContext)
+      {
+         id = ((StatefulBeanContext)ctx).getId();
+      }
       try
       {
          InvocationContext ic = LifecycleInvocationContextImpl.getLifecycleInvocationContext(
                PreDestroy.class,
-               ctx, 
+               ctx,
                preDestroys,
                beanPreDestroys);
          ic.proceed();
@@ -132,8 +141,8 @@
       try
       {
          InvocationContext ic = LifecycleInvocationContextImpl.getLifecycleInvocationContext(
-               PostActivate.class, 
-               ctx, 
+               PostActivate.class,
+               ctx,
                postActivates,
                beanPostActivates);
          ic.proceed();
@@ -149,7 +158,7 @@
       try
       {
          InvocationContext ic = LifecycleInvocationContextImpl.getLifecycleInvocationContext(
-               PrePassivate.class, 
+               PrePassivate.class,
                ctx,
                prePassivates,
                beanPrePassivates);
@@ -173,8 +182,8 @@
       {
          if (container.resolveAnnotation(method, Timeout.class) != null)
          {
-            if (Modifier.isPublic(method.getModifiers()) && 
-                  method.getReturnType().equals(Void.TYPE) && 
+            if (Modifier.isPublic(method.getModifiers()) &&
+                  method.getReturnType().equals(Void.TYPE) &&
                   method.getParameterTypes().length == 1 &&
                   method.getParameterTypes()[0].equals(Timer.class))
             {
@@ -186,24 +195,24 @@
             }
          }
       }
-      
-      try 
+
+      try
       {
          if (timeoutCallbackMethod == null && javax.ejb.TimedObject.class.isAssignableFrom(container.getBeanClass()))
          {
             Class[] params = new Class[]{Timer.class};
             timeoutCallbackMethod = container.getBeanClass().getMethod("ejbTimeout", params);
          }
-      } 
+      }
       catch (Exception e)
       {
          e.printStackTrace();
       }
-      
+
       if (timeoutCallbackMethod != null)
       {
          timeoutCalllbackHash = MethodHashing.calculateHash(timeoutCallbackMethod);
       }
-   }   
+   }
 
 }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -18,7 +18,7 @@
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-*/ 
+*/
 package org.jboss.ejb3.service;
 
 import java.lang.reflect.Method;
@@ -61,6 +61,7 @@
 import org.jboss.ejb3.timerservice.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.TimerServiceFactory;
 import org.jboss.logging.Logger;
+import org.jboss.injection.Injector;
 
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
@@ -115,12 +116,12 @@
 //         throw new IllegalArgumentException("service bean create method must take no arguments");
       throw new RuntimeException("NYI");
    }
-   
+
    public Object getSingleton()
    {
       return singleton;
    }
-   
+
    public void create() throws Exception
    {
       super.create();
@@ -130,33 +131,31 @@
    public void start() throws Exception
    {
       super.start();
-      
+
       try
-      {              
-         singleton = super.construct(); 
-                         
-         resolveInterceptorInjectors();
-         
+      {
+         singleton = super.construct();
+
          initBeanContext();
-         
-         // make sure the timer service is there before injection takes place 
+
+         // make sure the timer service is there before injection takes place
          timerService = TimerServiceFactory.createTimerService(this.getObjectName(), this);
-         
+
          injectDependencies(beanContext);
-         
+
          registerManagementInterface();
       }
       catch (Exception e)
       {
          e.printStackTrace();
          stop();
-      }     
+      }
    }
 
    public void stop() throws Exception
    {
       if (timerService != null) TimerServiceFactory.removeTimerService(timerService);
-      
+
       super.stop();
 
       if (delegate != null)
@@ -165,7 +164,7 @@
       }
       injected = false;
    }
-   
+
    public void destroy() throws Exception
    {
       super.destroy();
@@ -280,7 +279,7 @@
          Thread.currentThread().setContextClassLoader(oldLoader);
       }
    }
-   
+
    protected void initBeanContext() throws RuntimeException
    {
       if (beanContext == null)
@@ -323,11 +322,11 @@
          try
          {
             ThreadLocalENCFactory.push(enc);
-         for (int i = 0; i < injectors.length; i++)
-         {
-            injectors[i].inject(ctx);
+            for (Injector injector : injectors)
+            {
+               injector.inject(ctx);
+            }
          }
-         }
          finally
          {
             ThreadLocalENCFactory.pop();
@@ -405,10 +404,10 @@
          {
             if (mbeanServer == null)
                mbeanServer = org.jboss.mx.util.MBeanServerLocator.locateJBoss();
-            
+
             if (mbeanServer == null)
                throw new RuntimeException("There is a @Management interface on " + ejbName + " but the MBeanServer has not been initialized for it");
-            
+
             Service service = (Service)resolveAnnotation(Service.class);
 
             String objname = service.objectName();
@@ -416,11 +415,11 @@
                             new ObjectName(getObjectName().getCanonicalName() + ",type=ManagementInterface") : new ObjectName(service.objectName());
 
             delegate = new ServiceMBeanDelegate(mbeanServer, this, intf, delegateObjectName);
-            
+
             Object securityDomainAnnotation = resolveAnnotation(org.jboss.annotation.security.SecurityDomain.class);
-                    
+
             getDeployment().getKernelAbstraction().installMBean(delegateObjectName, getDependencyPolicy(), delegate);
-          
+
          }
       }
       catch (Exception e)

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -272,9 +272,6 @@
       {
          throw new RuntimeException(e);
       }
-
-      // Finally, remove myself
-      ((StatefulContainer)getContainer()).getCache().remove(id);
    }
 
    private void closeExtendedPCs()

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -41,9 +41,8 @@
 import org.jboss.ejb3.SessionContainer;
 import org.jboss.ejb3.ThreadLocalENCFactory;
 import org.jboss.ejb3.cache.StatefulCache;
-import org.jboss.ejb3.iiop.IORFactory;
-import org.jboss.ejb3.injection.Injector;
-import org.jboss.ejb3.injection.JndiFieldInjector;
+import org.jboss.injection.Injector;
+import org.jboss.injection.JndiFieldInjector;
 import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
 import org.jboss.ejb3.proxy.EJBMetaDataImpl;
 import org.jboss.ejb3.proxy.handle.HomeHandleImpl;
@@ -261,7 +260,7 @@
    {
       getCache().remove(id);
    }
-   
+
    /**
     * This should be a remote invocation call
     *
@@ -524,7 +523,7 @@
       return false;
    }
 
-   protected Object invokeEJBLocalObjectMethod(Object id, MethodInfo info,
+   private Object invokeEJBLocalObjectMethod(Object id, MethodInfo info,
                                              Object[] args) throws Exception
    {
       Method unadvisedMethod = info.getUnadvisedMethod();

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoveInterceptor.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoveInterceptor.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoveInterceptor.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -125,8 +125,7 @@
       {
          // Release it properly.
          StatefulBeanContext ctx = container.getCache().get(id);
-         container.getPool().remove(ctx);
-//         container.getCache().remove(id);
+         container.getCache().remove(id);
       }
    }
 }

Modified: trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -47,6 +47,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.proxy.ejb.handle.HomeHandleImpl;
 import org.jboss.proxy.ejb.handle.StatelessHandleImpl;
+import org.jboss.injection.EncInjector;
 
 import javax.ejb.EJBException;
 import javax.ejb.Handle;
@@ -56,6 +57,7 @@
 import java.lang.reflect.Method;
 import java.util.Hashtable;
 import java.util.Map;
+import java.util.HashMap;
 
 
 /**

Modified: trunk/ejb3/src/main/org/jboss/injection/DependsHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/DependsHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/DependsHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -30,15 +30,20 @@
 
 import org.jboss.annotation.ejb.Depends;
 import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.EnvironmentRefGroup;
 
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
  * @version $Revision$
  */
-public class DependsHandler
+public class DependsHandler implements InjectionHandler
 {
    private static final Logger log = Logger.getLogger(DependsHandler.class);
 
+   public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
+   {
+   }
+
    public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors)
    {
       Depends dep = container.getAnnotation(Depends.class, method.getDeclaringClass(), method);

Modified: trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/EJBHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -134,13 +134,13 @@
 
       if (refClass != null)
       {
-         if (link != null)
+         if (link != null && !link.trim().equals(""))
          {
             refcon = (EJBContainer) container.resolveEjbContainer(link, refClass);
             if (refcon == null)
             {
                String msg = "IGNORING DEPENDENCY: unable to find " + errorType + " of interface " + refClass.getName() + " and ejbLink of " + link + " in  " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier() + " it might not be deployed yet";
-               log.debug(msg);
+               log.warn(msg);
             }
          }
          else
@@ -150,21 +150,21 @@
                refcon = (EJBContainer) container.resolveEjbContainer(refClass);
                if (refcon == null)
                {
-                  String msg = "IGNORING DEPENDENCY: unable to find " + errorType + " of interface " + refClass.getName() + " and ejbLink of " + link + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier();
-                  log.debug(msg);
+                  String msg = "IGNORING DEPENDENCY: unable to find " + errorType + " from interface only " + refClass.getName() + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier();
+                  log.warn(msg);
                }
             }
             catch (NameNotFoundException e)
             {
-               String msg = "IGNORING DEPENDENCY: unable to find " + errorType + " of interface " + refClass.getName() + " and ejbLink of " + link + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier() + e.getMessage();
-               log.debug(msg);
+               String msg = "IGNORING DEPENDENCY: unable to find " + errorType + " from interface only " + refClass.getName() + " in " + container.getDeploymentDescriptorType() + " of " + container.getIdentifier() + e.getMessage();
+               log.warn(msg);
             }
          }
       }
       else
       {
-         String msg = "IGNORING DEPENDENCY: unable to resolve EJB";
-         log.debug(msg);
+         String msg = "IGNORING DEPENDENCY: unable to resolve dependency of EJB, there is too little information";
+         log.warn(msg);
       }
 
       if (refcon != null)

Modified: trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectionContainer.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -28,6 +28,7 @@
 import javax.naming.Context;
 import javax.naming.NameNotFoundException;
 import java.util.Map;
+import java.util.List;
 import java.lang.reflect.Method;
 import java.lang.reflect.Field;
 import java.lang.reflect.AccessibleObject;
@@ -57,24 +58,18 @@
 
    ClassLoader getClassloader();
 
-   Map<String, String> getEncLinkRefEntries();
-
-   boolean hasEnvEntry(String name);
-   void addEnvEntry(String name, String type, String value) throws ClassNotFoundException;
-   boolean hasEncEntry(String name);
-   //-----------------------
-
    Map<String, EncInjector> getEncInjectors();
-   Map <String, Map<AccessibleObject, Injector>> getEncInjections();
+   Map<String, Map<AccessibleObject, Injector>> getEncInjections();
 
+   // EncInjectors/Handlers may need to add extra instance injectors
+   List<Injector> getInjectors();
+
    Context getEnc();
    Context getEncEnv();
 
 
    PersistenceUnitDeployment getPersistenceUnitDeployment(String unitName) throws NameNotFoundException;
-   Map getExtendedPCs();
 
-
    Container resolveEjbContainer(String link, Class businessIntf);
    Container resolveEjbContainer(Class businessIntf) throws NameNotFoundException;
    String getEjbJndiName(Class businessInterface) throws NameNotFoundException;

Modified: trunk/ejb3/src/main/org/jboss/injection/InjectionUtil.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/InjectionUtil.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/InjectionUtil.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -21,20 +21,21 @@
   */
 package org.jboss.injection;
 
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.logging.Logger;
+import org.jboss.metamodel.descriptor.InjectionTarget;
+import org.jboss.metamodel.descriptor.Ref;
+
 import java.lang.reflect.AccessibleObject;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
-import java.util.HashMap;
+import java.util.Set;
 
-import org.jboss.ejb3.EJBContainer;
-import org.jboss.logging.Logger;
-
-import org.jboss.metamodel.descriptor.InjectionTarget;
-import org.jboss.metamodel.descriptor.Ref;
-
 /**
  * Comment
  *
@@ -44,7 +45,7 @@
 public class InjectionUtil
 {
    private static final Logger log = Logger
-   .getLogger(InjectionUtil.class);
+           .getLogger(InjectionUtil.class);
 
 
    /**
@@ -56,34 +57,109 @@
     * @param xmlDefinedInjectors
     * @param classInjectors
     */
-   public static void collapseXmlMethodInjectors(HashSet<String> visitedMethods, Class clazz, Map<String, Map<AccessibleObject, Injector>> xmlDefinedInjectors, Map<AccessibleObject, Injector> classInjectors)
+   public static void collapseXmlMethodInjectors(Set<String> visitedMethods, Class clazz, Map<String, Map<AccessibleObject, Injector>> xmlDefinedInjectors, Map<AccessibleObject, Injector> classInjectors)
    {
       if (clazz == null || clazz.equals(Object.class))
       {
          return;
       }
       Map<AccessibleObject, Injector> xmlInjectors = xmlDefinedInjectors.get(clazz.getName());
+      if (xmlInjectors != null)
+      {
+         Method[] methods = clazz.getDeclaredMethods();
+         for (Method method : methods)
+         {
+            if (method.getParameterTypes().length != 1) continue;
+
+            if (!Modifier.isPrivate(method.getModifiers()))
+            {
+               if (visitedMethods.contains(method.getName()))
+               {
+                  xmlInjectors.remove(method); // if not private then it has been overriden
+                  continue;
+               }
+               visitedMethods.add(method.getName());
+            }
+         }
+         classInjectors.putAll(xmlInjectors);
+      }
+      // recursion needs to come last as the method could be overriden and we don't want the overriding method to be ignored
+      collapseXmlMethodInjectors(visitedMethods, clazz.getSuperclass(), xmlDefinedInjectors, classInjectors);
+   }
+
+   public static void processMethodAnnotations(InjectionContainer container, Collection<InjectionHandler> handlers, Set<String> visitedMethods, Class clazz, Map<AccessibleObject, Injector> classInjectors)
+   {
+      if (clazz == null || clazz.equals(Object.class))
+      {
+         return;
+      }
       Method[] methods = clazz.getDeclaredMethods();
-      for (int i = 0; i < methods.length; i++)
+      for (Method method : methods)
       {
-         if (methods[i].getParameterTypes().length != 1) continue;
+         if (method.getParameterTypes().length != 1) continue;
 
-         if (!Modifier.isPrivate(methods[i].getModifiers()))
+         if (!Modifier.isPrivate(method.getModifiers()))
          {
-            if (visitedMethods.contains(methods[i].getName()))
+            if (visitedMethods.contains(method.getName()))
             {
-               xmlInjectors.remove(methods[i]); // if not private then it has been overriden
                continue;
             }
-            visitedMethods.add(methods[i].getName());
+            visitedMethods.add(method.getName());
          }
+         for (InjectionHandler handler : handlers)
+         {
+            handler.handleMethodAnnotations(method, container, classInjectors);
+         }
       }
-      classInjectors.putAll(xmlInjectors);
       // recursion needs to come last as the method could be overriden and we don't want the overriding method to be ignored
-      collapseXmlMethodInjectors(visitedMethods, clazz.getSuperclass(), xmlDefinedInjectors, classInjectors);
+      processMethodAnnotations(container, handlers, visitedMethods, clazz.getSuperclass(), classInjectors);
    }
 
+   public static void processFieldAnnotations(InjectionContainer container, Collection<InjectionHandler> handlers, Class clazz, Map<AccessibleObject, Injector> classInjectors)
+   {
+      if (clazz == null || clazz.equals(Object.class))
+      {
+         return;
+      }
+      Field[] fields = clazz.getDeclaredFields();
+      for (Field field : fields)
+      {
+         for (InjectionHandler handler : handlers)
+         {
+            handler.handleFieldAnnotations(field, container, classInjectors);
+         }
+      }
+      // recursion needs to come last as the method could be overriden and we don't want the overriding method to be ignored
+      processFieldAnnotations(container, handlers, clazz.getSuperclass(), classInjectors);
+   }
 
+   public static void processClassAnnotations(InjectionContainer container, Collection<InjectionHandler> handlers, Class clazz)
+   {
+      if (clazz == null || clazz.equals(Object.class))
+      {
+         return;
+      }
+      for (InjectionHandler handler : handlers)
+      {
+         handler.handleClassAnnotations(clazz, container);
+      }
+      // recursion needs to come last as the method could be overriden and we don't want the overriding method to be ignored
+      processClassAnnotations(container, handlers, clazz.getSuperclass());
+   }
+
+   public static Map<AccessibleObject, Injector> processAnnotations(InjectionContainer container, Collection<InjectionHandler> handlers, Class clazz)
+   {
+      Map<AccessibleObject, Injector> classInjectors = new HashMap<AccessibleObject, Injector>();
+      HashSet<String> visitedMethods = new HashSet<String>();
+      collapseXmlMethodInjectors(visitedMethods, clazz, container.getEncInjections(), classInjectors);
+
+      processClassAnnotations(container, handlers, clazz);
+      visitedMethods = new HashSet<String>();
+      processMethodAnnotations(container, handlers, visitedMethods, clazz, classInjectors);
+      processFieldAnnotations(container, handlers, clazz, classInjectors);
+      return classInjectors;
+   }
+
    public static AccessibleObject findInjectionTarget(ClassLoader loader, InjectionTarget target)
    {
       Class clazz = null;

Modified: trunk/ejb3/src/main/org/jboss/injection/JndiInjectHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/JndiInjectHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/JndiInjectHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -43,6 +43,7 @@
    
    public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
    {
+      if (xml == null) return;
       if (xml.getJndiRefs() == null) return;
       for (JndiRef ref : xml.getJndiRefs())
       {

Modified: trunk/ejb3/src/main/org/jboss/injection/PcEncInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/PcEncInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/PcEncInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -78,8 +78,7 @@
       {
          if (!(container instanceof StatefulContainer))
             throw new RuntimeException("It is illegal to inject an EXTENDED PC into something other than a SFSB");
-         container.getExtendedPCs().put(factory.getKernelName(),
-                 new ExtendedPersistenceContextInjector(factory));
+         container.getInjectors().add(0, new ExtendedPersistenceContextInjector(factory));
          Object extendedPc = null;
          if (injectionType == null
                  || injectionType.getName().equals(EntityManager.class.getName()))

Modified: trunk/ejb3/src/main/org/jboss/injection/PersistenceContextHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/PersistenceContextHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/PersistenceContextHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -49,6 +49,7 @@
 
    public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
    {
+      if (xml == null) return;
       if (xml.getPersistenceContextRefs() == null) return;
       for (PersistenceContextRef ref : xml.getPersistenceContextRefs())
       {

Modified: trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/PersistenceUnitHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -53,6 +53,7 @@
 
    public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
    {
+      if (xml == null) return;
       if (xml.getPersistenceUnitRefs() == null) return;
 
       for (PersistenceUnitRef ref : xml.getPersistenceUnitRefs())

Modified: trunk/ejb3/src/main/org/jboss/injection/PuEncInjector.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/PuEncInjector.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/PuEncInjector.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -51,7 +51,7 @@
       Object factory = null;
       try
       {
-         factory = PersistenceUnitHandler.getFactory(injectionType, encName, container);
+         factory = PersistenceUnitHandler.getFactory(injectionType, unitName, container);
       }
       catch (NameNotFoundException e)
       {

Modified: trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/ResourceHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -106,6 +106,7 @@
 
    public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
    {
+      if (xml == null) return;
       if (xml.getMessageDestinationRefs() != null) loadXmlMessageDestinationRefs(container, xml.getMessageDestinationRefs());
       if (xml.getResourceEnvRefs() != null) loadXmlResourceEnvRefs(container, xml.getResourceEnvRefs());
       if (xml.getResourceRefs() != null) loadXmlResourceRefs(container, xml.getResourceRefs());

Modified: trunk/ejb3/src/main/org/jboss/injection/WebServiceHandler.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/injection/WebServiceHandler.java	2006-08-03 22:58:10 UTC (rev 55143)
+++ trunk/ejb3/src/main/org/jboss/injection/WebServiceHandler.java	2006-08-03 23:12:56 UTC (rev 55144)
@@ -40,6 +40,7 @@
 
    public void loadXml(EnvironmentRefGroup xml, InjectionContainer container)
    {
+      if (xml == null) return;
       if (xml.getWebServiceRefs() == null) return;
       for (WebServiceRef wsRef : xml.getWebServiceRefs())
       {
@@ -58,7 +59,7 @@
    public void handleClassAnnotations(Class clazz, InjectionContainer container)
    {
       javax.xml.ws.WebServiceRef ref = container.getAnnotation(javax.xml.ws.WebServiceRef.class, clazz);
-
+      if (ref == null) return;
       String encName = ref.name();
       if (encName == null || encName.equals(""))
       {




More information about the jboss-cvs-commits mailing list