[jboss-cvs] JBossAS SVN: r109294 - in projects/ejb3/trunk/core: src/main/java/org/jboss/ejb3 and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 12 06:20:39 EST 2010


Author: wolfc
Date: 2010-11-12 06:20:36 -0500 (Fri, 12 Nov 2010)
New Revision: 109294

Modified:
   projects/ejb3/trunk/core/pom.xml
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
Log:
EJBTHREE-2046: make BeanInstantiator injectable with a fallback


Modified: projects/ejb3/trunk/core/pom.xml
===================================================================
--- projects/ejb3/trunk/core/pom.xml	2010-11-12 09:19:42 UTC (rev 109293)
+++ projects/ejb3/trunk/core/pom.xml	2010-11-12 11:20:36 UTC (rev 109294)
@@ -544,7 +544,6 @@
       <groupId>org.jboss.ejb3.instantiator</groupId>
       <artifactId>jboss-ejb3-instantiator-impl</artifactId>
       <version>${version.org.jboss.ejb3.instantiator}</version>
-      <scope>test</scope>
     </dependency>
 
     <dependency>

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java	2010-11-12 09:19:42 UTC (rev 109293)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java	2010-11-12 11:20:36 UTC (rev 109294)
@@ -46,6 +46,7 @@
 import org.jboss.ejb3.effigy.common.JBossBeanEffigyInfo;
 import org.jboss.ejb3.effigy.spi.BeanEffigyFactory;
 import org.jboss.ejb3.injection.InjectionInvocation;
+import org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator;
 import org.jboss.ejb3.instantiator.spi.BeanInstantiationException;
 import org.jboss.ejb3.instantiator.spi.BeanInstantiator;
 import org.jboss.ejb3.instantiator.spi.BeanInstantiatorRegistration;
@@ -215,7 +216,7 @@
    /**
     * Used to construct bean instances
     */
-   protected BeanInstantiator beanInstantiator;
+   private BeanInstantiator beanInstantiator;
 
    private DependencyPolicy dependencyPolicy;
 
@@ -314,20 +315,6 @@
          this.dependencyPolicy = deployment.createDependencyPolicy(this);
       }
       
-      // Get the Bean Instantiator
-      final String appName = deployment.getAppName();
-      final String moduleName = deployment.getDeploymentUnit().getShortName();
-      final String beanInstantiatorAttachmentName = BeanInstantiatorRegistration.getInstantiatorRegistrationName(
-            appName, moduleName, ejbName);
-      final BeanInstantiator beanInstantiator = Ejb3RegistrarLocator.locateRegistrar().lookup(
-            beanInstantiatorAttachmentName, BeanInstantiator.class);
-      if (beanInstantiator == null)
-      {
-         throw new IllegalStateException(deployment + " must contain an attachment of name "
-               + beanInstantiatorAttachmentName);
-      }
-      this.beanInstantiator = beanInstantiator;
-
       Advisor advisor = getAdvisor();
       AdviceStack stack = advisor.getManager().getAdviceStack("InjectionCallbackStack");
       if(stack == null)
@@ -1039,12 +1026,6 @@
 
    public void create() throws Exception
    {
-      if (this.beanInstantiator == null)
-      {
-         throw new IllegalStateException("Bean instantiator hasn't been configured in container, for EJB named: "
-               + this.getEjbName());
-      }
-      
       // Blocking invocations until start()
       this.blockInvocations();
 
@@ -1127,6 +1108,13 @@
       
       // If we're clustered, find our partition name
       findPartitionName();
+
+      if(this.beanInstantiator == null)
+      {
+         log.warn("EJBTHREE-2046: beanInstantior not set, using default on " + this);
+         // TODO: should not introduce an EJB 3.1 dependency
+         this.beanInstantiator = new Ejb31SpecBeanInstantiator();
+      }
       
       log.info("STARTED EJB: " + beanClass.getName() + " ejbName: " + ejbName);
    }
@@ -2089,4 +2077,9 @@
    {
       return this.beanInstantiator;
    }
+
+   public void setBeanInstantiator(BeanInstantiator beanInstantiator)
+   {
+      this.beanInstantiator = beanInstantiator;
+   }
 }

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java	2010-11-12 09:19:42 UTC (rev 109293)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java	2010-11-12 11:20:36 UTC (rev 109294)
@@ -60,6 +60,7 @@
 import org.jboss.ejb3.annotation.RemoteBinding;
 import org.jboss.ejb3.annotation.Service;
 import org.jboss.ejb3.common.lang.SerializableMethod;
+import org.jboss.ejb3.instantiator.impl.Ejb31SpecBeanInstantiator;
 import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
 import org.jboss.ejb3.proxy.impl.objectstore.ObjectStoreBindings;
 import org.jboss.ejb3.proxy.spi.container.InvokableContext;
@@ -192,6 +193,14 @@
    {
       super.create();
 
+      // EJBTHREE-2046: a hack, because we want to construct before startup
+      if(getBeanInstantiator() == null)
+      {
+         log.warn("EJBTHREE-2046: beanInstantior not set, using default on " + this);
+         // TODO: should not introduce an EJB 3.1 dependency
+         setBeanInstantiator(new Ejb31SpecBeanInstantiator());
+      }
+            
       // EJBTHREE-655: fire up an instance for use as MBean delegate
       singleton = super.construct();
 



More information about the jboss-cvs-commits mailing list