[jboss-cvs] JBossAS SVN: r101946 - in projects/ejb3/components/singleton/trunk: aop-impl/src/assembly and 12 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Mar 5 06:50:18 EST 2010


Author: jaikiran
Date: 2010-03-05 06:50:16 -0500 (Fri, 05 Mar 2010)
New Revision: 101946

Added:
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/ENCFieldInjector.java
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/ENCMethodInjector.java
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/PersistenceContextEncInjector.java
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/PersistenceContextInjectorFactory.java
   projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/deployment/
   projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/deployment/EJB3DeploymentImpl.java
Removed:
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/deployment/LegacyEJB3DeploymentAdapter.java
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/deployment/MCBasedEJB3DeploymentUnit.java
Modified:
   projects/ejb3/components/singleton/trunk/aop-impl/pom.xml
   projects/ejb3/components/singleton/trunk/aop-impl/src/assembly/package-assembler.xml
   projects/ejb3/components/singleton/trunk/aop-impl/src/assembly/package.xml
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedInterceptorRegistry.java
   projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedSingletonContainer.java
   projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/AOPBasedSingletonContainerTestCase.java
   projects/ejb3/components/singleton/trunk/deployer/src/main/java/org/jboss/ejb3/singleton/deployer/EJB3DeploymentDeployer.java
   projects/ejb3/components/singleton/trunk/deployer/src/main/java/org/jboss/ejb3/singleton/deployer/SingletonContainerDeployer.java
   projects/ejb3/components/singleton/trunk/deployer/src/main/resources/META-INF/jboss-ejb3-singleton-deployer-jboss-beans.xml
   projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonContainer.java
   projects/ejb3/components/singleton/trunk/impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit/SimpleSingletonContainerTest.java
   projects/ejb3/components/singleton/trunk/testsuite/pom.xml
   projects/ejb3/components/singleton/trunk/testsuite/src/test/java/org/jboss/ejb3/singleton/integration/test/tx/TxAwareSingletonBean.java
Log:
EJBTHREE-2010 Singleton implementation

Modified: projects/ejb3/components/singleton/trunk/aop-impl/pom.xml
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/pom.xml	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/aop-impl/pom.xml	2010-03-05 11:50:16 UTC (rev 101946)
@@ -26,8 +26,7 @@
     
     <properties>
         <version.ejb3.singleton.impl>${project.version}</version.ejb3.singleton.impl>
-	    <version.ejb3.core>1.2.3</version.ejb3.core>
-        <version.ejb3.vfs.impl>1.0.0-alpha-1</version.ejb3.vfs.impl>
+	    <version.ejb3.core>1.2.4-SNAPSHOT</version.ejb3.core>
     </properties>
     
     <build>
@@ -96,11 +95,6 @@
             </exclusions>
         </dependency>
 
-        <dependency>
-            <groupId>org.jboss.ejb3.vfs</groupId>
-            <artifactId>jboss-ejb3-vfs-impl-vfs2</artifactId>
-            <version>${version.ejb3.vfs.impl}</version>
-        </dependency>
         
         <!-- ***************************** -->
         <!--  Test dependencies -->

Modified: projects/ejb3/components/singleton/trunk/aop-impl/src/assembly/package-assembler.xml
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/assembly/package-assembler.xml	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/assembly/package-assembler.xml	2010-03-05 11:50:16 UTC (rev 101946)
@@ -34,8 +34,6 @@
       <includes>
         <include>org.jboss.ejb3.singleton:jboss-ejb3-singleton-aop-impl:jar</include>
         <include>org.jboss.ejb3:jboss-ejb3-core:jar</include>
-        <include>org.jboss.ejb3.vfs:jboss-ejb3-vfs-spi:jar</include>
-        <include>org.jboss.ejb3.vfs:jboss-ejb3-vfs-impl-vfs2:jar</include>
       </includes>      
       
     </dependencySet>

Modified: projects/ejb3/components/singleton/trunk/aop-impl/src/assembly/package.xml
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/assembly/package.xml	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/assembly/package.xml	2010-03-05 11:50:16 UTC (rev 101946)
@@ -29,8 +29,6 @@
   <file name="jboss-ejb3-singleton-aop-impl.jar" dest-path="common/lib" type="library"/>
   <!-- Hack -->
   <file name="jboss-ejb3-core.jar" dest-path="common/lib" type="library"/>
-  <file name="jboss-ejb3-vfs-spi.jar" dest-path="common/lib" type="library"/>
-  <file name="jboss-ejb3-vfs-impl-vfs2.jar" dest-path="common/lib" type="library"/>
   
   <!--  The xml file containing the AOP interceptors -->
   <file name="singleton-container-aop.xml" dest-path="server/default/deploy" type="config"/>

Modified: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedInterceptorRegistry.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedInterceptorRegistry.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedInterceptorRegistry.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -21,6 +21,7 @@
 */
 package org.jboss.ejb3.singleton.aop.impl;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.jboss.aop.MethodInfo;
@@ -29,6 +30,8 @@
 import org.jboss.ejb3.container.spi.ContainerInvocation;
 import org.jboss.ejb3.container.spi.EJBContainer;
 import org.jboss.ejb3.container.spi.InterceptorRegistry;
+import org.jboss.ejb3.container.spi.injection.InstanceInjector;
+import org.jboss.ejb3.interceptor.InterceptorInjector;
 
 /**
  * A AOP based implementation of the {@link InterceptorRegistry} for a
@@ -52,7 +55,9 @@
     * the {@link AOPBasedSingletonContainer} to expose this {@link LegacySingletonBeanContext}
     */
    private LegacySingletonBeanContext legacySingletonBeanContext;
-   
+
+   private List<InstanceInjector> interceptorInjectors = new ArrayList<InstanceInjector>();
+
    /**
     * Construct an {@link AOPBasedInterceptorRegistry} for a {@link AOPBasedSingletonContainer}
     * 
@@ -91,7 +96,7 @@
       AOPBasedContainerInvocationContext aopInvocationContext = (AOPBasedContainerInvocationContext) containerInvocation;
       // form a AOP invocation
       MethodInfo methodInfo = aopInvocationContext.getMethodInfo();
-      
+
       EJBContainerInvocation<AOPBasedSingletonContainer, LegacySingletonBeanContext> invocation = new EJBContainerInvocation<AOPBasedSingletonContainer, LegacySingletonBeanContext>(
             aopInvocationContext.getMethodInfo());
       invocation.setAdvisor(methodInfo.getAdvisor());
@@ -134,14 +139,15 @@
    public void invokePostConstruct(BeanContext targetBeanContext) throws Exception
    {
       // fallback on legacy AOP based lifecycle impl
-      this.legacySingletonBeanContext = new LegacySingletonBeanContext(this.aopBasedSingletonContainer, targetBeanContext);
+      this.legacySingletonBeanContext = new LegacySingletonBeanContext(this.aopBasedSingletonContainer,
+            targetBeanContext);
       // TODO: This passes the bean context through a series of injectors
       // which are responsible for carrying out the injection on the bean context (ex: field based
       // injection like for @PersistenceContext).
       // THIS HAS TO BE IN THE EJBLifecycleHandler SO THAT THE INJECTIONS
       // CAN HAPPEN ON LIFECYCLE EVENTS (LIKE BEAN INSTANTIATION)
-      this.aopBasedSingletonContainer.injectBeanContext(legacySingletonBeanContext);
-      
+      //this.aopBasedSingletonContainer.injectBeanContext(legacySingletonBeanContext);
+
       // Note: The method name initialiseInterceptorInstances() gives a 
       // wrong impression. This method not just instantiates a interceptor instance,
       // but it also injects (through the help of InjectionHanlder(s)) the interceptor
@@ -149,7 +155,7 @@
       // TODO: Ideally, this should be split up into separate instantiation and injection
       // calls.
       legacySingletonBeanContext.initialiseInterceptorInstances();
-      
+
       // invoke post construct lifecycle on the bean/interceptor instances
       this.aopBasedSingletonContainer.invokePostConstruct(legacySingletonBeanContext);
 
@@ -192,4 +198,23 @@
       return this.aopBasedSingletonContainer.getBeanContainer().getInterceptorRegistry().getInterceptorClasses();
    }
 
+   /**
+    * @see org.jboss.ejb3.container.spi.InterceptorRegistry#getInterceptorInjectors()
+    */
+   @Override
+   public List<InstanceInjector> getInterceptorInjectors()
+   {
+      return this.interceptorInjectors;
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.InterceptorRegistry#setInterceptorInjectors(java.util.List)
+    */
+   @Override
+   public void setInterceptorInjectors(List<InstanceInjector> interceptorInjectors)
+   {
+      this.interceptorInjectors = interceptorInjectors;
+
+   }
+
 }

Modified: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedSingletonContainer.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedSingletonContainer.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/AOPBasedSingletonContainer.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -24,10 +24,14 @@
 import java.io.Serializable;
 import java.lang.reflect.Method;
 import java.util.Hashtable;
+import java.util.List;
 import java.util.Map;
 
 import javax.ejb.Handle;
 import javax.ejb.TimerService;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
 
 import org.jboss.aop.Advisor;
 import org.jboss.aop.Domain;
@@ -38,7 +42,7 @@
 import org.jboss.aop.util.MethodHashing;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
 import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.Ejb3Deployment;
+import org.jboss.ejb3.Ejb3Module;
 import org.jboss.ejb3.aop.BeanContainer;
 import org.jboss.ejb3.common.lang.SerializableMethod;
 import org.jboss.ejb3.container.spi.ContainerInvocation;
@@ -46,6 +50,8 @@
 import org.jboss.ejb3.container.spi.EJBDeploymentInfo;
 import org.jboss.ejb3.container.spi.EJBInstanceManager;
 import org.jboss.ejb3.container.spi.InterceptorRegistry;
+import org.jboss.ejb3.container.spi.injection.EJBContainerENCInjector;
+import org.jboss.ejb3.container.spi.injection.InstanceInjector;
 import org.jboss.ejb3.proxy.impl.jndiregistrar.JndiSessionRegistrarBase;
 import org.jboss.ejb3.proxy.impl.remoting.SessionSpecRemotingMetadata;
 import org.jboss.ejb3.session.SessionSpecContainer;
@@ -79,8 +85,10 @@
     * This is the container to which the {@link AOPBasedSingletonContainer} will
     * delegate the calls to
     */
-   private SingletonContainer simpleSingletonContainer;
+   private SingletonContainer delegate;
 
+   private DeploymentUnit deploymentUnit;
+
    /**
     * Returns the AOP domain name which this container uses
     * for AOP based processing
@@ -102,15 +110,22 @@
     * @throws ClassNotFoundException
     */
    public AOPBasedSingletonContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
-         Hashtable ctxProperties, Ejb3Deployment deployment, JBossSessionBean31MetaData beanMetaData)
+         Hashtable ctxProperties, JBossSessionBean31MetaData beanMetaData, DeploymentUnit du)
          throws ClassNotFoundException
    {
-      super(cl, beanClassName, ejbName, domain, ctxProperties, deployment, beanMetaData);
+      this(cl, beanClassName, ejbName, domain, ctxProperties, beanMetaData);
+      this.deploymentUnit = du;
 
+   }
+
+   public AOPBasedSingletonContainer(ClassLoader cl, String beanClassName, String ejbName, Domain domain,
+         Hashtable ctxProperties, JBossSessionBean31MetaData beanMetaData) throws ClassNotFoundException
+   {
+      super(cl, beanClassName, ejbName, domain, ctxProperties, null, beanMetaData);
       // create a AOP based interceptor registry which will be used by the container
       InterceptorRegistry interceptorRegistry = new AOPBasedInterceptorRegistry(this);
       // create the new jboss-ejb3-container-spi based singleton container
-      this.simpleSingletonContainer = new SingletonContainer(this.getBeanClass(), beanMetaData, interceptorRegistry);
+      this.delegate = new SingletonContainer(this.getBeanClass(), beanMetaData, interceptorRegistry);
 
    }
 
@@ -121,7 +136,7 @@
    public void create() throws Exception
    {
       super.create();
-      this.simpleSingletonContainer.create();
+      this.delegate.create();
    }
 
    /**
@@ -133,7 +148,7 @@
       super.lockedStart();
 
       // pass on the control to our simple singleton container
-      this.simpleSingletonContainer.start();
+      this.delegate.start();
    }
 
    /**
@@ -152,7 +167,7 @@
    protected void lockedStop() throws Exception
    {
       super.lockedStop();
-      this.simpleSingletonContainer.stop();
+      this.delegate.stop();
    }
 
    /**
@@ -161,7 +176,7 @@
    @Override
    public void destroy() throws Exception
    {
-      this.simpleSingletonContainer.destroy();
+      this.delegate.destroy();
       // let the super do the rest
       super.destroy();
    }
@@ -222,7 +237,7 @@
          SessionSpecContainer.invokedMethod.push(invokedMethod);
 
          // pass the control to the simple singleton container
-         Object result = this.simpleSingletonContainer.invoke(containerInvocation);
+         Object result = this.delegate.invoke(containerInvocation);
 
          // create an InvocationResponse out of the result 
          Map<Object, Object> responseContextInfo = containerInvocation.getResponseContextInfo();
@@ -267,7 +282,7 @@
          // TODO: Legacy push/pop copied from StatelessContainer/SessionSpecContainer
          SessionSpecContainer.invokedMethod.push(serializableMethod);
          // pass the control to the simple singleton container
-         return this.simpleSingletonContainer.invoke(containerInvocation);
+         return this.delegate.invoke(containerInvocation);
 
       }
       finally
@@ -390,7 +405,7 @@
    @Override
    public EJBInstanceManager getBeanInstanceManager()
    {
-      return this.simpleSingletonContainer.getBeanInstanceManager();
+      return this.delegate.getBeanInstanceManager();
    }
 
    /**
@@ -399,7 +414,7 @@
    @Override
    public EJBDeploymentInfo getDeploymentInfo()
    {
-      return this.simpleSingletonContainer.getDeploymentInfo();
+      return this.delegate.getDeploymentInfo();
    }
 
    /**
@@ -425,7 +440,7 @@
    @Override
    public InterceptorRegistry getInterceptorRegistry()
    {
-      return this.simpleSingletonContainer.getInterceptorRegistry();
+      return this.delegate.getInterceptorRegistry();
    }
 
    /**
@@ -437,5 +452,95 @@
       return super.getBeanContainer();
    }
 
-   
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#getClassLoader()
+    */
+   @Override
+   public ClassLoader getClassLoader()
+   {
+      return this.classloader;
+   }
+
+   /**
+    * @see org.jboss.ejb3.EJBContainer#createObjectName(java.lang.String)
+    */
+   @Override
+   public String createObjectName(String ejbName)
+   {
+      StringBuilder sb = new StringBuilder(Ejb3Module.BASE_EJB3_JMX_NAME + ",");
+      DeploymentUnit ear = this.deploymentUnit == null ? null : this.deploymentUnit.getParent();
+      if (ear != null)
+      {
+         sb.append("ear=");
+         sb.append(ear.getSimpleName());
+         sb.append(",");
+      }
+      String unitName = this.deploymentUnit == null ? null : this.deploymentUnit.getSimpleName();
+      if (unitName == null)
+      {
+         sb.append("*");
+      }
+      else
+      {
+         sb.append("jar=");
+         sb.append(unitName);
+      }
+      sb.append(",name=");
+      sb.append(ejbName);
+      try
+      {
+         ObjectName on = new ObjectName(sb.toString());
+         return on.getCanonicalName();
+      }
+      catch (MalformedObjectNameException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#setEJBInjectors(java.util.List)
+    */
+   @Override
+   public void setEJBInjectors(List<InstanceInjector> injectors)
+   {
+      this.delegate.setEJBInjectors(injectors);
+
+   }
+
+   /**
+    * @see org.jboss.ejb3.EJBContainer#getInjectors()
+    */
+   public List<InstanceInjector> getEJBInjectors()
+   {
+      return this.delegate.getEJBInjectors();
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#getENC()
+    */
+   @Override
+   public Context getENC()
+   {
+      return this.delegate.getENC();
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#getENCInjectors()
+    */
+   @Override
+   public List<EJBContainerENCInjector> getENCInjectors()
+   {
+      return this.delegate.getENCInjectors();
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#setENCInjectors(java.util.List)
+    */
+   @Override
+   public void setENCInjectors(List<EJBContainerENCInjector> encInjectors)
+   {
+      this.delegate.setENCInjectors(encInjectors);
+
+   }
 }

Deleted: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/deployment/LegacyEJB3DeploymentAdapter.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/deployment/LegacyEJB3DeploymentAdapter.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/deployment/LegacyEJB3DeploymentAdapter.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -1,168 +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.singleton.aop.impl.deployment;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.security.jacc.PolicyConfiguration;
-
-import org.jboss.beans.metadata.api.annotations.Inject;
-import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.DeploymentScope;
-import org.jboss.ejb3.DeploymentUnit;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.container.spi.EJBContainer;
-import org.jboss.ejb3.container.spi.deployment.EJB3Deployment;
-import org.jboss.ejb3.deployers.JBoss5DependencyPolicy;
-import org.jboss.ejb3.javaee.JavaEEComponent;
-import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
-import org.jboss.metadata.ejb.jboss.JBossMetaData;
-
-/**
- * LegacyEJB3DeploymentAdapter
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class LegacyEJB3DeploymentAdapter extends Ejb3Deployment implements EJB3Deployment
-{
-
-   
-   private PersistenceUnitDependencyResolver persistenceUnitResolver;
-   
-   private org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit;
-   
-   /**
-    * @param deploymentUnit
-    * @param unit
-    * @param deploymentScope
-    * @param metaData
-    */
-   public LegacyEJB3DeploymentAdapter(org.jboss.deployers.structure.spi.DeploymentUnit deploymentUnit,
-         DeploymentUnit unit, DeploymentScope deploymentScope, JBossMetaData metaData)
-   {
-      super(deploymentUnit, unit, deploymentScope, metaData);
-      this.deploymentUnit = deploymentUnit;
-   }
-
-   /**
-    * EJB name --> EJB container map
-    */
-   private Map<String, EJBContainer> containers = new HashMap<String, EJBContainer>();
-   
-   /**
-    * @see org.jboss.ejb3.Ejb3Deployment#createDependencyPolicy(org.jboss.ejb3.javaee.JavaEEComponent)
-    */
-   @Override
-   public DependencyPolicy createDependencyPolicy(JavaEEComponent component)
-   {
-      return new JBoss5DependencyPolicy(component);
-   }
-
-   /**
-    * @see org.jboss.ejb3.Ejb3Deployment#createPolicyConfiguration()
-    */
-   @Override
-   protected PolicyConfiguration createPolicyConfiguration() throws Exception
-   {
-      throw new UnsupportedOperationException("NYI - createPolicyConfiguration");
-   }
-
-   /**
-    * @see org.jboss.ejb3.Ejb3Deployment#putJaccInService(javax.security.jacc.PolicyConfiguration, org.jboss.ejb3.DeploymentUnit)
-    */
-   @Override
-   protected void putJaccInService(PolicyConfiguration pc, DeploymentUnit unit)
-   {
-      throw new UnsupportedOperationException("NYI - putJaccInService");
-      
-   }
-
-   /**
-    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#addContainer(org.jboss.ejb3.container.spi.EJBContainer)
-    */
-   @Override
-   public void addContainer(EJBContainer ejbContainer) throws IllegalArgumentException
-   {
-      String ejbName = ejbContainer.getEJBName();
-      if (this.containers.containsKey(ejbName))
-      {
-         throw new IllegalArgumentException("Container for ejb named " + ejbName + " is already registered");
-      }
-      this.containers.put(ejbName, ejbContainer);
-   }
-
-   /**
-    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#getEJBContainer(java.lang.String)
-    */
-   @Override
-   public EJBContainer getEJBContainer(String ejbName)
-   {
-      return this.containers.get(ejbName);
-   }
-
-   /**
-    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#getEJBContainers()
-    */
-   @Override
-   public Collection<EJBContainer> getEJBContainers()
-   {
-      return Collections.unmodifiableCollection(this.containers.values());
-   }
-
-   /**
-    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#removeEJBContainer(org.jboss.ejb3.container.spi.EJBContainer)
-    */
-   @Override
-   public void removeEJBContainer(EJBContainer ejbContainer) throws IllegalArgumentException
-   {
-      String ejbName = ejbContainer.getEJBName();
-      if (!this.containers.containsKey(ejbName))
-      {
-         throw new IllegalArgumentException("EJB container for ejb name " + ejbName + " is not registered");
-      }
-      this.containers.remove(ejbName);
-   }
-   
-   @Inject
-   public void setPersistenceUnitResolver(PersistenceUnitDependencyResolver puResolver)
-   {
-      this.persistenceUnitResolver = puResolver;
-   }
-   
-   /**
-    * @see org.jboss.ejb3.Ejb3Deployment#resolvePersistenceUnitSupplier(java.lang.String)
-    */
-   @Override
-   protected String resolvePersistenceUnitSupplier(String persistenceUnitName)
-   {
-      if (this.persistenceUnitResolver == null)
-      {
-         return null;
-      }
-      return this.persistenceUnitResolver.resolvePersistenceUnitSupplier(this.deploymentUnit, persistenceUnitName);
-   }
-
-}

Deleted: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/deployment/MCBasedEJB3DeploymentUnit.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/deployment/MCBasedEJB3DeploymentUnit.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/deployment/MCBasedEJB3DeploymentUnit.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -1,275 +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.singleton.aop.impl.deployment;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Collections;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
-import org.jboss.ejb3.DeploymentUnit;
-import org.jboss.ejb3.interceptor.InterceptorInfoRepository;
-import org.jboss.ejb3.vfs.impl.vfs2.VirtualFileWrapper;
-import org.jboss.ejb3.vfs.spi.VirtualFile;
-import org.jboss.ejb3.vfs.spi.VirtualFileFilter;
-
-/**
- * MCBasedEJB3DeploymentUnit
- *
- * @author Jaikiran Pai
- * @version $Revision: $
- */
-public class MCBasedEJB3DeploymentUnit implements DeploymentUnit
-{
-
-   private VFSDeploymentUnit vfsDeploymentUnit;
-
-   public MCBasedEJB3DeploymentUnit(VFSDeploymentUnit vfsDeploymentUnit)
-   {
-      this.vfsDeploymentUnit = vfsDeploymentUnit;
-   }
-
-   /**
-    * @see org.jboss.ejb3.DeploymentUnit#addAttachment(java.lang.String, java.lang.Object)
-    */
-   @Override
-   public Object addAttachment(String name, Object attachment)
-   {
-      return this.vfsDeploymentUnit.addAttachment(name, attachment);
-   }
-
-   /**
-    * @see org.jboss.ejb3.DeploymentUnit#getAttachment(java.lang.String)
-    */
-   @Override
-   public Object getAttachment(String name)
-   {
-      return this.vfsDeploymentUnit.getAttachment(name);
-   }
-
-   /**
-    * @see org.jboss.ejb3.DeploymentUnit#getClassLoader()
-    */
-   @Override
-   public ClassLoader getClassLoader()
-   {
-      return this.vfsDeploymentUnit.getClassLoader();
-   }
-
-   /**
-    * @see org.jboss.ejb3.DeploymentUnit#getClasses()
-    */
-   @Override
-   public List<Class> getClasses()
-   {
-      return Collections.EMPTY_LIST;
-   }
-
-   /**
-    * @see org.jboss.ejb3.DeploymentUnit#getDefaultEntityManagerName()
-    */
-   @Override
-   public String getDefaultEntityManagerName()
-   {
-      throw new UnsupportedOperationException("NYI - getDefaultEntityManagerName");
-   }
-
-   /**
-    * @see org.jboss.ejb3.DeploymentUnit#getDefaultPersistenceProperties()
-    */
-   @Override
-   public Map getDefaultPersistenceProperties()
-   {
-      throw new UnsupportedOperationException("NYI - getDefaultPersistenceProperties");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getEjbJarXml()
-    */
-   @Override
-   public URL getEjbJarXml()
-   {
-      return this.extractDescriptorUrl("ejb-jar.xml");
-   }
-
-   /**
-    * @see org.jboss.ejb3.DeploymentUnit#getInterceptorInfoRepository()
-    */
-   @Override
-   public InterceptorInfoRepository getInterceptorInfoRepository()
-   {
-      // TODO Auto-generated method stub
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getJbossXml()
-    */
-   @Override
-   public URL getJbossXml()
-   {
-      return this.extractDescriptorUrl("jboss.xml");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getJndiProperties()
-    */
-   @Override
-   public Hashtable getJndiProperties()
-   {
-      return null;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getMetaDataFile(java.lang.String)
-    */
-   @Override
-   public VirtualFile getMetaDataFile(String filename)
-   {
-      // TODO: revisit this
-      org.jboss.virtual.VirtualFile virtualFile =  this.vfsDeploymentUnit.getMetaDataFile(filename);
-      VirtualFileWrapper virtualFileWrapper = new VirtualFileWrapper(virtualFile);
-      return virtualFileWrapper;
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getPersistenceXml()
-    */
-   @Override
-   public URL getPersistenceXml()
-   {
-      return this.extractDescriptorUrl("persistence.xml");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getRelativePath()
-    */
-   @Override
-   public String getRelativePath()
-   {
-      return this.vfsDeploymentUnit.getRelativePath();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getRelativeURL(java.lang.String)
-    */
-   @Override
-   public URL getRelativeURL(String path)
-   {
-      try
-      {
-         return new URL(path);
-      }
-      catch (MalformedURLException e)
-      {
-         try
-         {
-            if (getUrl() == null)
-               throw new RuntimeException("relative <jar-file> not allowed when standalone deployment unit is used");
-            return new URL(getUrl(), path);
-         }
-         catch (Exception e1)
-         {
-            throw new RuntimeException("could not find relative path: " + path, e1);
-         }
-      }
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getResourceLoader()
-    */
-   @Override
-   public ClassLoader getResourceLoader()
-   {
-      return this.getClassLoader();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getResources(org.jboss.virtual.VirtualFileFilter)
-    */
-   @Override
-   public List<VirtualFile> getResources(VirtualFileFilter filter)
-   {
-      throw new UnsupportedOperationException("NYI");
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getRootFile()
-    */
-   @Override
-   public VirtualFile getRootFile()
-   {
-      org.jboss.virtual.VirtualFile virtualFile = this.vfsDeploymentUnit.getFile("");
-      return new VirtualFileWrapper(virtualFile);
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getShortName()
-    */
-   @Override
-   public String getShortName()
-   {
-      return this.vfsDeploymentUnit.getFile("").getName();
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#getUrl()
-    */
-   @Override
-   public URL getUrl()
-   {
-      try
-      {
-         return this.vfsDeploymentUnit.getFile("").toURL();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   /* (non-Javadoc)
-    * @see org.jboss.ejb3.DeploymentUnit#removeAttachment(java.lang.String)
-    */
-   @Override
-   public Object removeAttachment(String name)
-   {
-      return this.vfsDeploymentUnit.removeAttachment(name);
-   }
-
-   private URL extractDescriptorUrl(String resource)
-   {
-      try
-      {
-         org.jboss.virtual.VirtualFile vf = this.vfsDeploymentUnit.getMetaDataFile(resource);
-         if (vf == null) return null;
-         return vf.toURL();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-}

Added: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/ENCFieldInjector.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/ENCFieldInjector.java	                        (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/ENCFieldInjector.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -0,0 +1,86 @@
+/*
+* 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.singleton.aop.impl.injection;
+
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.container.spi.BeanContext;
+import org.jboss.ejb3.container.spi.injection.InstanceInjector;
+
+/**
+ * ENCMemberInjector
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ENCFieldInjector implements InstanceInjector
+{
+
+   private Field field;
+   
+   private String jndiName;
+   
+   private List<String> dependencies = new ArrayList<String>();
+   
+   public ENCFieldInjector(Field field, String jndiName)
+   {
+      this.field = field;
+      this.jndiName = jndiName;
+   }
+   
+   public void inject(BeanContext beanContext, Object instanceToBeInjected)
+   {
+      Context beanENC = beanContext.getEJBContainer().getENC();
+      try
+      {
+         Object obj = beanENC.lookup(this.jndiName);
+         field.set(instanceToBeInjected, obj);
+      }
+      catch (NamingException ne)
+      {
+         throw new RuntimeException(ne);
+      }
+      catch (IllegalArgumentException iae)
+      {
+         throw new RuntimeException(iae);
+      }
+      catch (IllegalAccessException iae)
+      {
+         throw new RuntimeException(iae);
+      }
+   }
+
+   public void addDependency(String dep)
+   {
+      this.dependencies.add(dep);
+   }
+   
+   public List<String> getDependencies()
+   {
+      return this.dependencies;
+   }
+}

Added: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/ENCMethodInjector.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/ENCMethodInjector.java	                        (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/ENCMethodInjector.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -0,0 +1,92 @@
+/*
+* 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.singleton.aop.impl.injection;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+
+import org.jboss.ejb3.container.spi.BeanContext;
+import org.jboss.ejb3.container.spi.injection.InstanceInjector;
+
+/**
+ * ENCMethodInjector
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class ENCMethodInjector implements InstanceInjector
+{
+
+   private Method method;
+
+   private String jndiName;
+   
+   private List<String> dependencies = new ArrayList<String>();
+
+   public ENCMethodInjector(Method method, String jndiName)
+   {
+      this.method = method;
+      this.jndiName = jndiName;
+   }
+
+   public void inject(BeanContext beanContext, Object instanceToBeInjected)
+   {
+      Context beanENC = beanContext.getEJBContainer().getENC();
+      try
+      {
+         Object obj = beanENC.lookup(this.jndiName);
+         method.invoke(instanceToBeInjected, obj);
+      }
+      catch (NamingException ne)
+      {
+         throw new RuntimeException(ne);
+      }
+      catch (IllegalArgumentException iae)
+      {
+         throw new RuntimeException(iae);
+      }
+      catch (IllegalAccessException iae)
+      {
+         throw new RuntimeException(iae);
+      }
+      catch (InvocationTargetException ite)
+      {
+         throw new RuntimeException(ite);
+      }
+
+   }
+   
+   public void addDependency(String dep)
+   {
+      this.dependencies.add(dep);
+   }
+   
+   public List<String> getDependencies()
+   {
+      return this.dependencies;
+   }
+}

Added: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/PersistenceContextEncInjector.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/PersistenceContextEncInjector.java	                        (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/PersistenceContextEncInjector.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -0,0 +1,104 @@
+/*
+* 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.singleton.aop.impl.injection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.NamingException;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContextType;
+
+import org.jboss.ejb3.container.spi.EJBContainer;
+import org.jboss.ejb3.container.spi.injection.EJBContainerENCInjector;
+import org.jboss.jpa.deployment.ManagedEntityManagerFactory;
+import org.jboss.jpa.spi.PersistenceUnitRegistry;
+import org.jboss.jpa.tx.TransactionScopedEntityManager;
+import org.jboss.util.naming.Util;
+
+/**
+ * PersistenceContextInjector
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PersistenceContextEncInjector implements EJBContainerENCInjector
+{
+
+   private String puSupplierName;
+
+   private String encName;
+
+   private PersistenceContextType type = PersistenceContextType.TRANSACTION;
+   
+   private List<String> dependencies = new ArrayList<String>();
+
+   public PersistenceContextEncInjector(String jndiname, String unitSupplierName, PersistenceContextType pcType)
+   {
+      this.encName = jndiname;
+      this.puSupplierName = unitSupplierName;
+      this.type = pcType;
+   }
+
+   public PersistenceContextEncInjector(String jndiname, String unitSupplierName)
+   {
+      this.encName = jndiname;
+      this.puSupplierName = unitSupplierName;
+
+   }
+
+   @Override
+   public void inject(EJBContainer container)
+   {
+
+      ManagedEntityManagerFactory memf = ((org.jboss.jpa.deployment.PersistenceUnitDeployment) PersistenceUnitRegistry
+            .getPersistenceUnit(this.puSupplierName)).getManagedFactory();
+      if (this.type == PersistenceContextType.EXTENDED)
+      {
+         // TODO
+         throw new RuntimeException("Injection of PersistenceContextType.EXTENDED not yet implemented");
+      }
+      else
+      {
+         EntityManager entityManager = new TransactionScopedEntityManager(memf);
+         try
+         {
+
+            Util.rebind(container.getENC(), encName, entityManager);
+         }
+         catch (NamingException ne)
+         {
+            throw new RuntimeException(ne);
+         }
+      }
+   }
+   
+   public void addDependency(String dep)
+   {
+      this.dependencies.add(dep);
+   }
+   
+   public List<String> getDependencies()
+   {
+      return this.dependencies;
+   }
+}

Added: projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/PersistenceContextInjectorFactory.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/PersistenceContextInjectorFactory.java	                        (rev 0)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/main/java/org/jboss/ejb3/singleton/aop/impl/injection/PersistenceContextInjectorFactory.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -0,0 +1,134 @@
+/*
+* 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.singleton.aop.impl.injection;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
+
+import javax.persistence.PersistenceContext;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.container.spi.injection.EJBContainerENCInjector;
+import org.jboss.ejb3.container.spi.injection.InjectorFactory;
+import org.jboss.ejb3.container.spi.injection.InstanceInjector;
+import org.jboss.injection.InjectionUtil;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
+import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
+
+/**
+ * PersistenceContextInjector
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class PersistenceContextInjectorFactory implements InjectorFactory
+{
+
+   private DeploymentUnit deploymentUnit;
+
+   private PersistenceUnitDependencyResolver persistenceUnitResolver;
+
+   public PersistenceContextInjectorFactory(DeploymentUnit du, PersistenceUnitDependencyResolver puResolver)
+   {
+      this.deploymentUnit = du;
+      this.persistenceUnitResolver = puResolver;
+   }
+
+   public List<InstanceInjector> createBeanInstanceInjectors(JBossEnterpriseBeanMetaData enterpriseBeanMetaData)
+   {
+      //      PersistenceContextReferencesMetaData pcRefs = enterpriseBeanMetaData.getPersistenceContextRefs();
+      //      if (pcRefs == null || pcRefs.isEmpty())
+      //      {
+      //         return Collections.EMPTY_LIST;
+      //      }
+      //      List<EJBInjector> injectors = new ArrayList<EJBInjector>();
+      //      for (PersistenceContextReferenceMetaData pcRef : pcRefs)
+      //      {
+      //         String unitName = pcRef.getPersistenceUnitName();
+      //         String puSupplier = this.persistenceUnitResolver.resolvePersistenceUnitSupplier(this.deploymentUnit, unitName);
+      //         injectors.add(new PersistenceContextEncInjector("env/" + pcRef.getPersistenceContextRefName(), puSupplier,
+      //               pcRef.getPersistenceContextType()));
+      //      }
+      //      return injectors;
+      return Collections.EMPTY_LIST;
+   }
+
+   @Override
+   public InstanceInjector createInstanceInjector(Method method)
+   {
+      PersistenceContext pc = method.getAnnotation(PersistenceContext.class);
+      if (pc == null)
+      {
+         return null;
+      }
+      String encName = pc.name();
+      if (encName == null || encName.equals(""))
+      {
+         encName = InjectionUtil.getEncName(method);
+      }
+      else
+      {
+         encName = "env/" + pc.name();
+      }
+      return new ENCMethodInjector(method, encName);
+
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.injection.InjectorFactory#createENCInjectors(org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData)
+    */
+   @Override
+   public List<EJBContainerENCInjector> createENCInjectors(JBossEnterpriseBeanMetaData enterpriseBeanMetaData)
+   {
+      // todo
+      return Collections.EMPTY_LIST;
+   }
+
+   
+
+   /**
+    * @see org.jboss.ejb3.container.spi.injection.InjectorFactory#createENCInjectors(java.lang.reflect.Method)
+    */
+   @Override
+   public EJBContainerENCInjector createENCInjector(Method method)
+   {
+      PersistenceContext pc = method.getAnnotation(PersistenceContext.class);
+      if (pc == null)
+      {
+         return null;
+      }
+      String unitName = pc.unitName();
+      String puSupplier = this.persistenceUnitResolver.resolvePersistenceUnitSupplier(this.deploymentUnit, unitName);
+      String encName = pc.name();
+      if (encName == null || encName.equals(""))
+      {
+         encName = InjectionUtil.getEncName(method);
+      }
+      else
+      {
+         encName = "env/" + pc.name();
+      }
+      return new PersistenceContextEncInjector(encName, puSupplier, pc.type());
+   }
+
+}

Modified: projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/AOPBasedSingletonContainerTestCase.java
===================================================================
--- projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/AOPBasedSingletonContainerTestCase.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/aop-impl/src/test/java/org/jboss/ejb3/singleton/aop/impl/test/container/unit/AOPBasedSingletonContainerTestCase.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -113,7 +113,7 @@
       String beanName = SimpleSingletonBean.class.getSimpleName();
       Hashtable props = new Hashtable();
       AOPBasedSingletonContainer singletonContainer = new AOPBasedSingletonContainer(cl, beanClassName, beanName,
-            this.singletonAOPDomain, props, new MockEJB3Deployment(), sessionBeanMetaData);
+            this.singletonAOPDomain, props, sessionBeanMetaData);
 
       Method getCountMethod = SimpleSingletonBean.class.getDeclaredMethod("getCount", new Class<?>[]
       {});

Modified: projects/ejb3/components/singleton/trunk/deployer/src/main/java/org/jboss/ejb3/singleton/deployer/EJB3DeploymentDeployer.java
===================================================================
--- projects/ejb3/components/singleton/trunk/deployer/src/main/java/org/jboss/ejb3/singleton/deployer/EJB3DeploymentDeployer.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/deployer/src/main/java/org/jboss/ejb3/singleton/deployer/EJB3DeploymentDeployer.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -21,7 +21,6 @@
 */
 package org.jboss.ejb3.singleton.deployer;
 
-import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.dependency.spi.Controller;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
@@ -31,10 +30,7 @@
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
 import org.jboss.ejb3.container.spi.deployment.EJB3Deployment;
-import org.jboss.ejb3.singleton.aop.impl.deployment.LegacyEJB3DeploymentAdapter;
-import org.jboss.ejb3.singleton.aop.impl.deployment.MCBasedEJB3DeploymentUnit;
-import org.jboss.kernel.plugins.dependency.AbstractKernelControllerContext;
-import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.ejb3.singleton.impl.deployment.EJB3DeploymentImpl;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
 
@@ -53,7 +49,7 @@
    private static Logger logger = Logger.getLogger(EJB3DeploymentDeployer.class);
 
    private Controller kernelController;
-   
+
    /**
     * Constructs a {@link SingletonContainerDeployer} for
     * processing singleton beans
@@ -70,9 +66,7 @@
       this.addOutput(Ejb3Deployment.class);
       // also add the new SPI based EJB3Deployment as output
       this.addOutput(EJB3Deployment.class);
-      
-      
-      
+
    }
 
    /**
@@ -87,44 +81,20 @@
       {
          return;
       }
-      VFSDeploymentUnit vfsDeploymentUnit = (VFSDeploymentUnit) unit;
+      
       // get metadata
-      JBossMetaData metadata = unit.getAttachment(AttachmentNames.PROCESSED_METADATA,JBossMetaData.class);
+      JBossMetaData metadata = unit.getAttachment(AttachmentNames.PROCESSED_METADATA, JBossMetaData.class);
       // we only process EJB3.x
       if (!metadata.isEJB3x())
       {
          return;
       }
-      
-      Ejb3Deployment ejb3Deployment = new LegacyEJB3DeploymentAdapter(unit,new MCBasedEJB3DeploymentUnit(vfsDeploymentUnit),null,metadata);
-      String deploymentMCBeanName = ejb3Deployment + "-" + "EJB3Deployment";
-      
-      // add as a attachment
-      unit.addAttachment(Ejb3Deployment.class, ejb3Deployment);
-      unit.addAttachment(EJB3Deployment.class, (EJB3Deployment) ejb3Deployment);
-      
-      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(deploymentMCBeanName, ejb3Deployment.getClass().getName());
-      builder.setConstructorValue(ejb3Deployment);
-      
-      KernelControllerContext context = new AbstractKernelControllerContext(null, builder.getBeanMetaData(), null);
-      
-      try
-      {
-         // install the EJB3Deployment as a MC bean
-         // don't rely on BeanMetaDataDeployer since we need EJB3Deployment to 
-         // go through the MC deployment cycle immidiately before other deployers
-         // come into picture
-         kernelController.install(context);
-      }
-      catch (Throwable t)
-      {
-         throw DeploymentException.rethrowAsDeploymentException("Error deploying EJB3Deployment for : " + unit.getName(), t);
-      }
-      
-   }
 
-   public void setKernelController(Controller kernelController)
-   {
-      this.kernelController = kernelController;
+      EJB3Deployment ejb3Deployment = new EJB3DeploymentImpl(unit.getSimpleName(), unit, metadata);
+
+      // add as an attachment
+      unit.addAttachment(EJB3Deployment.class, ejb3Deployment);
+
    }
+
 }

Modified: projects/ejb3/components/singleton/trunk/deployer/src/main/java/org/jboss/ejb3/singleton/deployer/SingletonContainerDeployer.java
===================================================================
--- projects/ejb3/components/singleton/trunk/deployer/src/main/java/org/jboss/ejb3/singleton/deployer/SingletonContainerDeployer.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/deployer/src/main/java/org/jboss/ejb3/singleton/deployer/SingletonContainerDeployer.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -21,7 +21,14 @@
 */
 package org.jboss.ejb3.singleton.deployer;
 
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
 import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
 
 import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
@@ -30,23 +37,24 @@
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.Domain;
 import org.jboss.aop.DomainDefinition;
+import org.jboss.beans.metadata.api.annotations.Inject;
 import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.DemandMetaData;
-import org.jboss.beans.metadata.spi.DependencyMetaData;
-import org.jboss.beans.metadata.spi.SupplyMetaData;
 import org.jboss.beans.metadata.spi.builder.BeanMetaDataBuilder;
 import org.jboss.deployers.spi.DeploymentException;
 import org.jboss.deployers.spi.deployer.DeploymentStages;
 import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
 import org.jboss.deployers.structure.spi.DeploymentUnit;
-import org.jboss.ejb3.DependencyPolicy;
-import org.jboss.ejb3.Ejb3Deployment;
-import org.jboss.ejb3.MCDependencyPolicy;
 import org.jboss.ejb3.common.deployers.spi.AttachmentNames;
 import org.jboss.ejb3.container.spi.EJBContainer;
 import org.jboss.ejb3.container.spi.deployment.EJB3Deployment;
+import org.jboss.ejb3.container.spi.injection.DependencyBasedInjector;
+import org.jboss.ejb3.container.spi.injection.EJBContainerENCInjector;
+import org.jboss.ejb3.container.spi.injection.InjectorFactory;
+import org.jboss.ejb3.container.spi.injection.InstanceInjector;
 import org.jboss.ejb3.singleton.aop.impl.AOPBasedSingletonContainer;
+import org.jboss.ejb3.singleton.aop.impl.injection.PersistenceContextInjectorFactory;
 import org.jboss.ejb3.singleton.proxy.impl.SingletonBeanRemoteJNDIBinder;
+import org.jboss.jpa.resolvers.PersistenceUnitDependencyResolver;
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ear.jboss.JBossAppMetaData;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
@@ -54,6 +62,8 @@
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
 import org.jboss.metadata.ejb.jboss.JBossSessionBean31MetaData;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
+import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
 
 /**
  * A MC based deployer for deploying a {@link EJBContainer} as a MC bean
@@ -81,6 +91,8 @@
     */
    private static Logger logger = Logger.getLogger(SingletonContainerDeployer.class);
 
+   private PersistenceUnitDependencyResolver persistenceUnitResolver;
+
    /**
     * Constructs a {@link SingletonContainerDeployer} for
     * processing singleton beans
@@ -94,7 +106,9 @@
       addOutput(BeanMetaData.class);
 
       // ordering
-      addInput(Ejb3Deployment.class);
+     // addInput(Ejb3Deployment.class);
+      // new SPI based EJB3Deployment
+      addInput(EJB3Deployment.class);
       addInput(AttachmentNames.PROCESSED_METADATA);
    }
 
@@ -179,18 +193,17 @@
                + beanMetaData.getEjbName() + " in unit " + unit);
       }
       Hashtable<String, String> ctxProperties = new Hashtable<String, String>();
-      Ejb3Deployment ejb3Deployment = unit.getAttachment(Ejb3Deployment.class);
-      if (ejb3Deployment == null)
-      {
-         throw new DeploymentException("Could not find " + Ejb3Deployment.class
-               + " for creating singleton container for bean " + sessionBean.getEjbName() + " in unit " + unit);
-      }
+//      Ejb3Deployment ejb3Deployment = unit.getAttachment(Ejb3Deployment.class);
+//      if (ejb3Deployment == null)
+//      {
+//         throw new DeploymentException("Could not find " + Ejb3Deployment.class
+//               + " for creating singleton container for bean " + sessionBean.getEjbName() + " in unit " + unit);
+//      }
       AOPBasedSingletonContainer singletonContainer = null;
       try
       {
          singletonContainer = new AOPBasedSingletonContainer(classLoader, sessionBean.getEjbClass(), sessionBean
-               .getEjbName(), (Domain) singletonContainerAOPDomain.getManager(), ctxProperties, ejb3Deployment,
-               sessionBean);
+               .getEjbName(), (Domain) singletonContainerAOPDomain.getManager(), ctxProperties, sessionBean, unit);
       }
       catch (ClassNotFoundException cnfe)
       {
@@ -198,12 +211,9 @@
                + sessionBean.getEjbName() + " in unit " + unit, cnfe);
       }
 
-      // Register the newly created container with the new SPI based Ejb3Deployment
-      if (ejb3Deployment instanceof EJB3Deployment)
-      {
-         ((EJB3Deployment) ejb3Deployment).addContainer(singletonContainer);
-      }
-
+      // Register the newly created container with the new SPI based EJB3Deployment
+      this.registerWithEJB3Deployment(unit, singletonContainer);
+      
       String singletonContainerMCBeanName;
       try
       {
@@ -223,17 +233,31 @@
       // Here we let the injection handlers to setup appropriate dependencies
       // on the container and also create injectors for the container
       singletonContainer.instantiated();
-      singletonContainer.processMetadata();
+     // singletonContainer.processMetadata();
 
-      DependencyPolicy dependencyPolicy = singletonContainer.getDependencyPolicy();
-      if (dependencyPolicy instanceof MCDependencyPolicy)
+      List<InjectorFactory> injectorFactories = new ArrayList<InjectorFactory>();
+      PersistenceContextInjectorFactory pcInjectorFactory = new PersistenceContextInjectorFactory(unit,this.persistenceUnitResolver);
+      injectorFactories.add(pcInjectorFactory);
+      List<EJBContainerENCInjector> encInjectors = pcInjectorFactory.createENCInjectors(sessionBean);
+      singletonContainer.setENCInjectors(encInjectors);
+      
+
+      try
       {
-         // deploy the container as MC bean (by attaching to DU)
-         BeanMetaData containerBMD = this.createContainerWithDependencies(unit, singletonContainerMCBeanName,
-               singletonContainer, (MCDependencyPolicy) dependencyPolicy);
-         unit.addAttachment(BeanMetaData.class + ":" + containerBMD.getName(), containerBMD);
+         Class<?> beanClass = unit.getClassLoader().loadClass(sessionBean.getEjbClass());
+         singletonContainer.setEJBInjectors(this.processMethodAnnotations(beanClass, new HashSet<Method>(),injectorFactories));
       }
+      catch (ClassNotFoundException e)
+      {
+         throw new RuntimeException(e);
+      }
+      List<DependencyBasedInjector> allInjectors = new ArrayList<DependencyBasedInjector>();
+      allInjectors.addAll(singletonContainer.getEJBInjectors());
+      allInjectors.addAll(singletonContainer.getENCInjectors());
+      this.installContainer(unit, singletonContainerMCBeanName, singletonContainer, allInjectors);
 
+      
+      
       // TODO: This shouldn't be here
       SingletonBeanRemoteJNDIBinder jndiBinder = new SingletonBeanRemoteJNDIBinder(singletonContainer);
       try
@@ -244,7 +268,7 @@
       {
          throw new DeploymentException(e);
       }
-
+      
    }
 
    /**
@@ -329,53 +353,101 @@
       return unit.getSimpleName().endsWith(".ear") || unit.getAttachment(JBossAppMetaData.class) != null;
    }
 
-   /**
-    * Creates a {@link BeanMetaData} for the passed <code>container</code> and sets appropriate dependencies,
-    * specified through <code>mcDependencyPolicy</code> on the {@link BeanMetaData}
-    * 
-    * @param unit Deployment unit
-    * @param mcBeanName The name to be assigned to the MC bean for the <code>container</code>
-    * @param container The container for which the {@link BeanMetaData} has to be created 
-    * @param mcDependencyPolicy The dependencies that are to be assigned on the {@link BeanMetaData} of the <code>container</code>
-    * @return Returns the {@link BeanMetaData} for the <code>container</code> with appropriate dependencies set
-    */
-   private BeanMetaData createContainerWithDependencies(DeploymentUnit unit, String mcBeanName, EJBContainer container,
-         MCDependencyPolicy mcDependencyPolicy)
+   private void registerWithEJB3Deployment(DeploymentUnit unit, EJBContainer container)
    {
+      EJB3Deployment ejb3Deployment = unit.getAttachment(EJB3Deployment.class);
+      if (ejb3Deployment != null)
+      {
+         ejb3Deployment.addContainer(container);
+      }
+      return;
+   }
 
-      BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(mcBeanName, container.getClass().getName());
-      builder.setConstructorValue(container);
+   @Inject
+   public void setPersistenceUnitResolver(PersistenceUnitDependencyResolver puResolver)
+   {
+      this.persistenceUnitResolver = puResolver;
+   }
 
-      logger.info("creating bean: " + mcBeanName);
-      logger.info("  with dependencies:");
-      if (mcDependencyPolicy.getDependencies() != null)
+   private List<InstanceInjector> processMethodAnnotations(Class<?> clazz, Set<Method> visitedMethods,
+         List<InjectorFactory> injectorFactories)
+   {
+      if (clazz == null || clazz.equals(Object.class))
       {
-         for (DependencyMetaData dependency : mcDependencyPolicy.getDependencies())
+         return Collections.EMPTY_LIST;
+      }
+      Method[] methods = clazz.getDeclaredMethods();
+      List<InstanceInjector> injectors = new ArrayList<InstanceInjector>();
+      for (Method method : methods)
+      {
+         if (method.getParameterTypes().length != 1)
+            continue;
+
+         if (!Modifier.isPrivate(method.getModifiers()))
          {
-            builder.addDependency(dependency.getDependency());
-            logger.info("\t" + dependency.getDependency());
+            if (visitedMethods.contains(method.getName()))
+            {
+               continue;
+            }
+            visitedMethods.add(method);
          }
+
+         if (injectorFactories != null)
+         {
+            for (InjectorFactory injectorFactory : injectorFactories)
+            {
+               injectors.add(injectorFactory.createInstanceInjector(method));
+            }
+         }
       }
-      logger.info("  and demands:");
-      if (mcDependencyPolicy.getDemands() != null)
+      // recursion needs to come last as the method could be overriden and we don't want the overriding method to be ignored
+      processMethodAnnotations(clazz.getSuperclass(), visitedMethods, injectorFactories);
+      
+      return injectors;
+   }
+   
+   
+   private void installContainer(DeploymentUnit unit, String containerMCBeanName, EJBContainer container, List<DependencyBasedInjector> injectors)
+   {
+      BeanMetaDataBuilder containerBMDBuilder = BeanMetaDataBuilder.createBuilder(containerMCBeanName, container.getClass().getName());
+      containerBMDBuilder.setConstructorValue(container);
+      
+      // TODO: Hack! (for quick testing)
+      JBossSessionBean31MetaData sessionbean = (JBossSessionBean31MetaData) container.getMetaData();
+      String localhome = sessionbean.getLocalHome();
+      containerBMDBuilder.addSupply("Class:"+localhome);
+      String remoteHome = sessionbean.getHome();
+      containerBMDBuilder.addSupply("Class:"+remoteHome);
+      BusinessLocalsMetaData businessLocals = sessionbean.getBusinessLocals();
+      if (businessLocals != null)
       {
-         for (DemandMetaData demand : mcDependencyPolicy.getDemands())
+         for (String businessLocal : businessLocals)
          {
-            builder.addDemand(demand.getDemand());
-            logger.info("\t" + demand.getDemand());
+            containerBMDBuilder.addSupply("Class:"+businessLocal);
          }
       }
-
-      logger.info("  and supplies:");
-      if (mcDependencyPolicy.getSupplies() != null)
+      BusinessRemotesMetaData businessRemotes = sessionbean.getBusinessRemotes();
+      if (businessRemotes != null)
       {
-         for (SupplyMetaData supply : mcDependencyPolicy.getSupplies())
+         for (String businessRemote : businessRemotes)
          {
-            builder.addSupply(supply.getSupply());
-            logger.info("\t" + supply.getSupply());
+            containerBMDBuilder.addSupply("Class:"+businessRemote);
          }
       }
-
-      return builder.getBeanMetaData();
+      
+      for (DependencyBasedInjector injector : injectors)
+      {
+         BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder(injector.toString(), injector.getClass().getName());
+         builder.setConstructorValue(injector);
+         for (String dep : injector.getDependencies())
+         {
+            builder.addDependency(dep);
+         }
+         unit.addAttachment(BeanMetaData.class + ":" + injector.toString(), builder.getBeanMetaData());
+         
+         containerBMDBuilder.addDependency(injector.toString());
+      }
+      
+      unit.addAttachment(BeanMetaData.class + ":" + containerMCBeanName, containerBMDBuilder.getBeanMetaData());
    }
 }

Modified: projects/ejb3/components/singleton/trunk/deployer/src/main/resources/META-INF/jboss-ejb3-singleton-deployer-jboss-beans.xml
===================================================================
--- projects/ejb3/components/singleton/trunk/deployer/src/main/resources/META-INF/jboss-ejb3-singleton-deployer-jboss-beans.xml	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/deployer/src/main/resources/META-INF/jboss-ejb3-singleton-deployer-jboss-beans.xml	2010-03-05 11:50:16 UTC (rev 101946)
@@ -6,9 +6,9 @@
     <bean name="SingletonContainerDeployer" class="org.jboss.ejb3.singleton.deployer.SingletonContainerDeployer"/>
     
     <!-- deploys a EJB3Deployment (TODO: needs to move out to a different component, since this isn't specific to singleton) -->
-    <bean name="EJB3DeploymentDeployer" class="org.jboss.ejb3.singleton.deployer.EJB3DeploymentDeployer">
-        <property name="kernelController"><inject bean="jboss.kernel:service=KernelController"/></property> 
-    </bean>
+    <bean name="EJB3DeploymentDeployer" class="org.jboss.ejb3.singleton.deployer.EJB3DeploymentDeployer"/>
+         
     
     
+    
 </deployment>
\ No newline at end of file

Modified: projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonContainer.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonContainer.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/container/SingletonContainer.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -21,12 +21,21 @@
 */
 package org.jboss.ejb3.singleton.impl.container;
 
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
 import org.jboss.ejb3.container.spi.BeanContext;
 import org.jboss.ejb3.container.spi.ContainerInvocation;
 import org.jboss.ejb3.container.spi.EJBContainer;
 import org.jboss.ejb3.container.spi.EJBDeploymentInfo;
 import org.jboss.ejb3.container.spi.EJBInstanceManager;
 import org.jboss.ejb3.container.spi.InterceptorRegistry;
+import org.jboss.ejb3.container.spi.injection.EJBContainerENCInjector;
+import org.jboss.ejb3.container.spi.injection.InstanceInjector;
 import org.jboss.ejb3.container.spi.lifecycle.EJBLifecycleHandler;
 import org.jboss.ejb3.singleton.spi.SingletonEJBInstanceManager;
 import org.jboss.logging.Logger;
@@ -69,6 +78,10 @@
     * The interceptor registry for this container
     */
    private InterceptorRegistry interceptorRegistry;
+   
+   private List<EJBContainerENCInjector> encInjectors = new ArrayList<EJBContainerENCInjector>();
+   
+   private List<InstanceInjector> ejbInstanceInjectors = new ArrayList<InstanceInjector>();
 
    /**
     * Creates a {@link SingletonContainer} for the EJB class <code>beanClass</code>
@@ -134,6 +147,11 @@
    {
       // TODO: If @Startup, then create a singleton bean context here
       
+      // Use ENCInjectors to setup ENC
+      for (EJBContainerENCInjector encInjector : this.encInjectors)
+      {
+         encInjector.inject(this);
+      }
    }
    
    /**
@@ -230,8 +248,12 @@
    @Override
    public void postConstruct(BeanContext beanContext) throws Exception
    {
+      List<InstanceInjector> injectors = this.getEJBInjectors();
+      for (InstanceInjector injector : injectors)
+      {
+         injector.inject(beanContext, beanContext.getBeanInstance());
+      }
       // pass the bean context to the interceptor registry to do its job.
-      // we don't have anything specific/additional to do here.
       this.interceptorRegistry.invokePostConstruct(beanContext);
       
    }
@@ -247,5 +269,63 @@
       this.interceptorRegistry.invokePreDestroy(beanContext);
    }
 
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#getClassLoader()
+    */
+   @Override
+   public ClassLoader getClassLoader()
+   {
+      return this.beanClass.getClassLoader();
+   }
    
+   public Context getENC()
+   {
+      // TODO: Hack!
+      try
+      {
+         return new InitialContext();
+      }
+      catch (NamingException e)
+      {
+         throw new RuntimeException(e);
+      }
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#getEJBInjectors()
+    */
+   @Override
+   public List<InstanceInjector> getEJBInjectors()
+   {
+      return this.ejbInstanceInjectors;
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#setEJBInjectors(java.util.List)
+    */
+   @Override
+   public void setEJBInjectors(List<InstanceInjector> injectors)
+   {
+      this.ejbInstanceInjectors = injectors;
+      
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#getENCInjectors()
+    */
+   @Override
+   public List<EJBContainerENCInjector> getENCInjectors()
+   {
+      return this.encInjectors;
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.EJBContainer#setENCInjectors(java.util.List)
+    */
+   @Override
+   public void setENCInjectors(List<EJBContainerENCInjector> encInjectors)
+   {
+      this.encInjectors = encInjectors;
+      
+   }
 }

Added: projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/deployment/EJB3DeploymentImpl.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/deployment/EJB3DeploymentImpl.java	                        (rev 0)
+++ projects/ejb3/components/singleton/trunk/impl/src/main/java/org/jboss/ejb3/singleton/impl/deployment/EJB3DeploymentImpl.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -0,0 +1,122 @@
+/*
+* 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.singleton.impl.deployment;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.deployers.structure.spi.DeploymentUnit;
+import org.jboss.ejb3.container.spi.EJBContainer;
+import org.jboss.ejb3.container.spi.deployment.EJB3Deployment;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+
+/**
+ * EJB3DeploymentImpl
+ *
+ * @author Jaikiran Pai
+ * @version $Revision: $
+ */
+public class EJB3DeploymentImpl implements EJB3Deployment
+{
+
+   private String name;
+   
+   private DeploymentUnit deploymentUnit;
+
+   private JBossMetaData jbossMetaData;
+
+   /**
+    * @param deploymentUnit
+    * @param unit
+    * @param deploymentScope
+    * @param metaData
+    */
+   public EJB3DeploymentImpl(String name, DeploymentUnit deploymentUnit, JBossMetaData jbossMetaData)
+   {
+      this.name = name;
+      this.deploymentUnit = deploymentUnit;
+      this.jbossMetaData = jbossMetaData;
+   }
+
+   /**
+    * EJB name --> EJB container map
+    */
+   private Map<String, EJBContainer> containers = new HashMap<String, EJBContainer>();
+
+   /**
+    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#addContainer(org.jboss.ejb3.container.spi.EJBContainer)
+    */
+   @Override
+   public void addContainer(EJBContainer ejbContainer) throws IllegalArgumentException
+   {
+      String ejbName = ejbContainer.getEJBName();
+      if (this.containers.containsKey(ejbName))
+      {
+         throw new IllegalArgumentException("Container for ejb named " + ejbName + " is already registered");
+      }
+      this.containers.put(ejbName, ejbContainer);
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#getEJBContainer(java.lang.String)
+    */
+   @Override
+   public EJBContainer getEJBContainer(String ejbName)
+   {
+      return this.containers.get(ejbName);
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#getEJBContainers()
+    */
+   @Override
+   public Collection<EJBContainer> getEJBContainers()
+   {
+      return Collections.unmodifiableCollection(this.containers.values());
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#removeEJBContainer(org.jboss.ejb3.container.spi.EJBContainer)
+    */
+   @Override
+   public void removeEJBContainer(EJBContainer ejbContainer) throws IllegalArgumentException
+   {
+      String ejbName = ejbContainer.getEJBName();
+      if (!this.containers.containsKey(ejbName))
+      {
+         throw new IllegalArgumentException("EJB container for ejb name " + ejbName + " is not registered");
+      }
+      this.containers.remove(ejbName);
+   }
+
+   /**
+    * @see org.jboss.ejb3.container.spi.deployment.EJB3Deployment#getName()
+    */
+   @Override
+   public String getName()
+   {
+      return this.name;
+   }
+
+}

Modified: projects/ejb3/components/singleton/trunk/impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit/SimpleSingletonContainerTest.java
===================================================================
--- projects/ejb3/components/singleton/trunk/impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit/SimpleSingletonContainerTest.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/impl/src/test/java/org/jboss/ejb3/singleton/impl/test/simple/unit/SimpleSingletonContainerTest.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -33,6 +33,7 @@
 import org.jboss.ejb3.container.spi.ContainerInvocation;
 import org.jboss.ejb3.container.spi.EJBContainer;
 import org.jboss.ejb3.container.spi.InterceptorRegistry;
+import org.jboss.ejb3.container.spi.injection.InstanceInjector;
 import org.jboss.ejb3.singleton.impl.container.InVMContainerInvocationImpl;
 import org.jboss.ejb3.singleton.impl.container.SingletonContainer;
 import org.jboss.ejb3.singleton.impl.test.simple.SimpleSingletonBean;
@@ -253,5 +254,25 @@
          return Collections.EMPTY_LIST;
       }
 
+      /* (non-Javadoc)
+       * @see org.jboss.ejb3.container.spi.InterceptorRegistry#getInterceptorInjectors()
+       */
+      @Override
+      public List<InstanceInjector> getInterceptorInjectors()
+      {
+         // TODO Auto-generated method stub
+         return null;
+      }
+
+      /* (non-Javadoc)
+       * @see org.jboss.ejb3.container.spi.InterceptorRegistry#setInterceptorInjectors(java.util.List)
+       */
+      @Override
+      public void setInterceptorInjectors(List<InstanceInjector> interceptorInjectors)
+      {
+         // TODO Auto-generated method stub
+         
+      }
+
    }
 }

Modified: projects/ejb3/components/singleton/trunk/testsuite/pom.xml
===================================================================
--- projects/ejb3/components/singleton/trunk/testsuite/pom.xml	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/testsuite/pom.xml	2010-03-05 11:50:16 UTC (rev 101946)
@@ -231,6 +231,7 @@
                                 <jvmArg>-Dsun.rmi.dgc.server.gcInterval=3600000</jvmArg>
                                 <!-- Temporary, till AS boots without this property JBAS-6744 -->
                                 <jvmArg>-Dxb.builder.useUnorderedSequence=true</jvmArg>
+                                <jvmArg>-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n</jvmArg>
                             </jvmArgs>
                             <jboss.test.run>true</jboss.test.run>
                         </configuration>

Modified: projects/ejb3/components/singleton/trunk/testsuite/src/test/java/org/jboss/ejb3/singleton/integration/test/tx/TxAwareSingletonBean.java
===================================================================
--- projects/ejb3/components/singleton/trunk/testsuite/src/test/java/org/jboss/ejb3/singleton/integration/test/tx/TxAwareSingletonBean.java	2010-03-05 11:38:27 UTC (rev 101945)
+++ projects/ejb3/components/singleton/trunk/testsuite/src/test/java/org/jboss/ejb3/singleton/integration/test/tx/TxAwareSingletonBean.java	2010-03-05 11:50:16 UTC (rev 101946)
@@ -42,7 +42,7 @@
 
    public static final String JNDI_NAME = "Tx-UserManagerBean";
    
-   @PersistenceContext
+   
    private EntityManager em;
 
    /* (non-Javadoc)
@@ -66,4 +66,9 @@
       return this.em.find(User.class, id);
    }
    
+   @PersistenceContext
+   public void setEntityManager(EntityManager em)
+   {
+      this.em = em;
+   }
 }




More information about the jboss-cvs-commits mailing list