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

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 16 15:03:34 EDT 2010


Author: wolfc
Date: 2010-03-16 15:03:31 -0400 (Tue, 16 Mar 2010)
New Revision: 102482

Added:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/CurrentInvocationContextInterceptor.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocation.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/InvocationContextAdapter.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/SessionInvocationContextAdapter.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionHelper.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInjectionInvocation.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessageContainerInvocation.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainerInvocation.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInjectionInvocation.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextInterceptor.java
Removed:
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocationContextInterceptor.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/LifecycleInterceptorHandler.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/LifecycleInvocationContextImpl.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInvocationContextImpl.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceInvocationContextImpl.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInvocationContextImpl.java
Modified:
   projects/ejb3/trunk/core/pom.xml
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/BeanContext.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainerInvocation.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainerInvocationWrapper.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionInvocation.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBContext.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/pool/AbstractPool.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceBeanContext.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceSessionContextImpl.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContextDelegateBase.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/SessionSynchronizationInterceptor.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainerInvocation.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
   projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessSessionContextImpl.java
   projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1358/MockBeanContext.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextBean.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java
   projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/threadlocal/MockBeanContext.java
   projects/ejb3/trunk/core/src/test/resources/container-beans.xml
Log:
EJBTHREE-2020: third integration pass

Modified: projects/ejb3/trunk/core/pom.xml
===================================================================
--- projects/ejb3/trunk/core/pom.xml	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/pom.xml	2010-03-16 19:03:31 UTC (rev 102482)
@@ -17,7 +17,7 @@
   <!-- Artifact Information -->
   <artifactId>jboss-ejb3-core</artifactId>
   <packaging>jar</packaging>
-  <version>1.2.4-SNAPSHOT</version>
+  <version>1.3.0-SNAPSHOT</version>
   <name>JBoss EJB 3.0 Core</name>
   <url>http://labs.jboss.com/jbossejb3</url>
   <description>JBoss EJB 3.0 Core</description>
@@ -41,6 +41,7 @@
   <!-- Properties -->
 
   <properties>
+    <version.org.jboss.ejb3.context>0.1.1-SNAPSHOT</version.org.jboss.ejb3.context>
     <version.org.jboss.jboss-as>5.0.0.CR2</version.org.jboss.jboss-as>
     <version.org.jboss.security>2.0.3.SP1</version.org.jboss.security>
     <version.sun-jaxws>2.1.1</version.sun-jaxws>
@@ -457,10 +458,17 @@
     <dependency>
       <groupId>org.jboss.ejb3.context</groupId>
       <artifactId>jboss-ejb3-context-base</artifactId>
-      <version>0.1.0</version>
+      <version>${version.org.jboss.ejb3.context}</version>
     </dependency>
 
     <dependency>
+      <groupId>org.jboss.ejb3.context</groupId>
+      <artifactId>jboss-ejb3-context-naming</artifactId>
+      <version>${version.org.jboss.ejb3.context}</version>
+      <scope>runtime</scope>
+    </dependency>
+
+    <dependency>
       <groupId>org.jboss.ejb3.timeout</groupId>
       <artifactId>jboss-ejb3-timeout-spi</artifactId>
       <version>0.1.1</version>

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/BeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/BeanContext.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/BeanContext.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -25,6 +25,7 @@
 import org.jboss.ejb3.context.spi.EJBContext;
 import org.jboss.ejb3.context.spi.InvocationContext;
 import org.jboss.ejb3.interceptor.InterceptorInfo;
+import org.jboss.injection.Injector;
 
 /**
  * An instance of an enterprise bean linked to its container.
@@ -36,16 +37,18 @@
  */
 public interface BeanContext<T extends Container> extends org.jboss.ejb3.interceptors.container.BeanContext<Object>
 {
-   InvocationContext createLifecycleInvocation(javax.interceptor.InvocationContext delegate);
+   // TODO: injectors are associated with the container
+   InvocationContext createInjectionInvocation(Iterable<Injector> injectors);
 
-   InvocationContext createMethodInvocation(javax.interceptor.InvocationContext delegate);
-   
+   // TODO: LifecycleMethodInterceptorsInvocation cannot be cast to EJBInvocation, see CurrentInvocationContextInterceptor
+   InvocationContext createLifecycleInvocation();
+
    Object getInstance();
 
    T getContainer();
 
    void initialiseInterceptorInstances();
-   
+
    void remove();
 
    SimpleMetaData getMetaData();

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-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainer.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -24,11 +24,11 @@
 import org.jboss.aop.Advisor;
 import org.jboss.aop.Domain;
 import org.jboss.aop.MethodInfo;
+import org.jboss.aop.advice.AdviceStack;
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.annotation.AnnotationRepository;
 import org.jboss.aop.microcontainer.annotations.DisableAOP;
 import org.jboss.aop.util.MethodHashing;
-import org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor;
 import org.jboss.beans.metadata.api.annotations.Inject;
 import org.jboss.ejb.AllowedOperationsAssociation;
 import org.jboss.ejb3.annotation.Clustered;
@@ -117,9 +117,9 @@
 
    private static TimeoutMethodCallbackRequirements timeoutMethodCallbackRequirements = Service.loadService(TimeoutMethodCallbackRequirements.class);
 
-   private String name;
+   private final String name;
    
-   private BeanContainer beanContainer;
+   private final BeanContainer beanContainer;
    
    private DirectContainer<EJBContainer> directContainer;
    
@@ -131,21 +131,17 @@
    
    protected ObjectName objectName;
 
-   protected int defaultConstructorIndex;
-
-   protected String beanClassName;
+   protected final String beanClassName;
    
-   private Class<?> beanClass;
+   private final Class<?> beanClass;
 
-   protected ClassLoader classloader;
+   protected final ClassLoader classloader;
 
    // for performance there is an array.
    protected List<Injector> injectors = new ArrayList<Injector>();
 
    protected Context enc;
 
-//   protected LifecycleInterceptorHandler callbackHandler;
-
    protected Hashtable initialContextProperties;
 
    protected Map<String, EncInjector> encInjectors = new HashMap<String, EncInjector>();
@@ -188,12 +184,12 @@
    private final Semaphore semaphore = new Semaphore(TOTAL_PERMITS, true);
    private final Lock invocationLock = new SemaphoreLock(this.semaphore);
    
-   private static final Interceptor[] currentInvocationStack = new Interceptor[] { new CurrentInvocationInterceptor() };
+   private final Interceptor[] injectionCallbackStack;
    
    private ComponentStack cachedConnectionManager;
    
    private boolean resurrectMetaData = false;
-   
+
    /**
     * @param name                  Advisor name
     * @param manager               Domain to get interceptor bindings from
@@ -211,23 +207,22 @@
                        Ejb3Deployment deployment, JBossEnterpriseBeanMetaData beanMetaData) throws ClassNotFoundException
    {
       assert name != null : "name is null";
-      assert deployment != null : "deployment is null";
-      
+
       this.name = name;
       this.deployment = deployment;
       this.beanClassName = beanClassName;
       this.classloader = cl;
       this.xml = beanMetaData;
-         
+
       this.beanClass = classloader.loadClass(beanClassName);
-      
+
       // We can't type cast the direct container, because we just loaded the beanClass
       // so assuming we have an object is a safe bet.
       this.beanContainer = new BeanContainer(this);
-      
+
       this.ejbName = ejbName;
-      
-      String on = createObjectName(ejbName);     
+
+      String on = createObjectName(ejbName);
       try
       {
          objectName = new ObjectName(on);
@@ -236,9 +231,9 @@
       {
          throw new RuntimeException("failed to create object name for: " + on, e);
       }
-      
+
       // Because interceptors will query back the EJBContainer for annotations
-      // we must have set beanContainer first and then do the advisor. 
+      // we must have set beanContainer first and then do the advisor.
       try
       {
          beanContainer.initialize(ejbName, domain, beanClass, beanMetaData, cl);
@@ -247,9 +242,9 @@
       {
          throw new RuntimeException("failed to initialize bean container ",e);
       }
-      
+
       //annotations = new AnnotationRepositoryToMetaData(this);
-      
+
       initialContextProperties = ctxProperties;
       try
       {
@@ -261,8 +256,15 @@
       }
       bindORB();
       bindEJBContext();
-      
-      this.dependencyPolicy = deployment.createDependencyPolicy(this);
+
+      if(deployment != null)
+         this.dependencyPolicy = deployment.createDependencyPolicy(this);
+
+      Advisor advisor = getAdvisor();
+      AdviceStack stack = advisor.getManager().getAdviceStack("InjectionCallbackStack");
+      if(stack == null)
+         throw new IllegalStateException("EJBTHREE-2020: No InjectionCallbackStack defined for domain " + domain + " of " + this);
+      injectionCallbackStack = stack.createInterceptors(advisor, null);
    }
    
    /**
@@ -281,66 +283,19 @@
                        String beanClassName, String ejbName, Hashtable ctxProperties,
                        JBossEnterpriseBeanMetaData beanMetaData) throws ClassNotFoundException
    {
-      assert name != null : "name is null";
-      
-      this.name = name;
-      this.beanClassName = beanClassName;
-      this.classloader = cl;
-      this.xml = beanMetaData;
-         
-      this.beanClass = classloader.loadClass(beanClassName);
-      
-      // We can't type cast the direct container, because we just loaded the beanClass
-      // so assuming we have an object is a safe bet.
-      this.beanContainer = new BeanContainer(this);
-      
-      this.ejbName = ejbName;
-      
-      String on = createObjectName(ejbName);     
-      try
-      {
-         objectName = new ObjectName(on);
-      }
-      catch (MalformedObjectNameException e)
-      {
-         throw new RuntimeException("failed to create object name for: " + on, e);
-      }
-      
-      // Because interceptors will query back the EJBContainer for annotations
-      // we must have set beanContainer first and then do the advisor. 
-      try
-      {
-         beanContainer.initialize(ejbName, domain, beanClass, beanMetaData, cl);
-      }
-      catch(Exception e)
-      {
-         throw new RuntimeException("failed to initialize bean container ",e);
-      }
-      
-      //annotations = new AnnotationRepositoryToMetaData(this);
-      
-      initialContextProperties = ctxProperties;
-      try
-      {
-         Util.createSubcontext(getEnc(), "env");
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-      bindORB();
-      bindEJBContext();
-      
+      this(name, domain, cl, beanClassName, ejbName, ctxProperties, null, beanMetaData);
    }
 
    private void bindEJBContext()
    {
-      try 
+      try
       {
-         Reference ref = new Reference(EJBContext.class.getName(), EJBContextFactory.class.getName(), null);
-         ref.add(new StringRefAddr("containerGuid", Ejb3Registry.guid(this)));
-         ref.add(new StringRefAddr("containerClusterUid", Ejb3Registry.clusterUid(this)));
-         ref.add(new StringRefAddr("isClustered", Boolean.toString(isClustered())));
+//         Reference ref = new Reference(EJBContext.class.getName(), EJBContextFactory.class.getName(), null);
+//         ref.add(new StringRefAddr("containerGuid", Ejb3Registry.guid(this)));
+//         ref.add(new StringRefAddr("containerClusterUid", Ejb3Registry.clusterUid(this)));
+//         ref.add(new StringRefAddr("isClustered", Boolean.toString(isClustered())));
+         // TODO: a temporary measure until jboss-injection is in place
+         LinkRef ref = new LinkRef("java:internal/EJBContext");
          Util.rebind(getEnc(), "EJBContext", ref);
       }
       catch (NamingException e)
@@ -1170,13 +1125,10 @@
          if(injectors == null)
             return;
          Advisor advisor = getAdvisor();
-         for (Injector injector : injectors)
-         {
-            InjectionInvocation invocation = new InjectionInvocation(beanContext, injector, currentInvocationStack);
-            invocation.setAdvisor(advisor);
-            invocation.setTargetObject(beanContext.getInstance());
-            invocation.invokeNext();
-         }
+         InjectionInvocation invocation = new InjectionInvocation(beanContext, injectors, injectionCallbackStack);
+         invocation.setAdvisor(advisor);
+         invocation.setTargetObject(beanContext.getInstance());
+         invocation.invokeNext();
       }
       catch(Throwable t)
       {
@@ -1285,22 +1237,6 @@
       }
    }
 
-   /*
-   protected void createCallbackHandler()
-   {
-      try
-      {
-         callbackHandler = new LifecycleInterceptorHandler(this,
-                 getHandledCallbacks());
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException("Error creating callback handler for bean "
-                 + beanClassName, e);
-      }
-   }
-   */
-
    protected Class[] getHandledCallbacks()
    {
       return new Class[]

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainerInvocation.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainerInvocation.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainerInvocation.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -21,21 +21,21 @@
  */
 package org.jboss.ejb3;
 
-import java.lang.reflect.Method;
-
 import org.jboss.aop.Advisor;
 import org.jboss.aop.MethodInfo;
 import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
 import org.jboss.ejb3.interceptors.container.ContainerMethodInvocation;
 
+import java.lang.reflect.Method;
+
 /**
  * Representation of an EJB invocation on the serverside
  *
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
-public class EJBContainerInvocation<A extends EJBContainer, T extends BeanContext<?>> extends ContainerMethodInvocation
+public abstract class EJBContainerInvocation<A extends EJBContainer, T extends BeanContext<?>> extends ContainerMethodInvocation
+   implements org.jboss.ejb3.core.context.EJBInvocation
 {
    private static final long serialVersionUID = 4941832732679380382L;
    
@@ -81,23 +81,6 @@
       }
    }
    
-   public Invocation getWrapper(Interceptor[] newchain)
-   {
-      return new EJBContainerInvocationWrapper<A, T>(this, newchain);
-   }
-
-   public Invocation copy()
-   {
-      EJBContainerInvocation<A, T> wrapper = new EJBContainerInvocation<A, T>(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor);
-      wrapper.metadata = this.metadata;
-      wrapper.currentInterceptor = this.currentInterceptor;
-      //wrapper.setTargetObject(this.getTargetObject());
-      wrapper.setArguments(this.getArguments());
-      wrapper.setBeanContext(getBeanContext());
-      wrapper.callback = this.callback;
-      return wrapper;
-   }
-   
    public void setContextCallback(BeanContextLifecycleCallback<T> callback)
    {
       this.callback = callback;

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainerInvocationWrapper.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainerInvocationWrapper.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/EJBContainerInvocationWrapper.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -36,7 +36,7 @@
  * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
  * @version $Revision$
  */
-public class EJBContainerInvocationWrapper<A extends EJBContainer, T extends BeanContext<?>> extends EJBContainerInvocation<A, T>
+public abstract class EJBContainerInvocationWrapper<A extends EJBContainer, T extends BeanContext<?>> extends EJBContainerInvocation<A, T>
 {
    private static final long serialVersionUID = 5402917625526438235L;
 

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/CurrentInvocationContextInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/CurrentInvocationContextInterceptor.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/CurrentInvocationContextInterceptor.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.core.context;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.context.CurrentInvocationContext;
+import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.ejb3.interceptors.container.LifecycleMethodInterceptorsInvocation;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class CurrentInvocationContextInterceptor implements Interceptor
+{
+   public String getName()
+   {
+      return getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      InvocationContext ctx = getInvocationContext(invocation);
+      CurrentInvocationContext.push(ctx);
+      try
+      {
+         return invocation.invokeNext();
+      }
+      finally
+      {
+         CurrentInvocationContext.pop();
+      }
+   }
+
+   private InvocationContext getInvocationContext(Invocation invocation)
+   {
+      if(invocation instanceof LifecycleMethodInterceptorsInvocation)
+         return getInvocationContext((LifecycleMethodInterceptorsInvocation) invocation);
+      return ((EJBInvocation) invocation).getInvocationContext();
+   }
+
+   // TODO: LifecycleMethodInterceptorsInvocation can not be cast to EJBInvocation
+   private InvocationContext getInvocationContext(LifecycleMethodInterceptorsInvocation invocation)
+   {
+      BeanContext<?> beanContext = (BeanContext<?>) invocation.getBeanContext();
+      InvocationContext invocationContext = beanContext.createLifecycleInvocation();
+      invocationContext.setEJBContext(beanContext.getEJBContext());
+      return invocationContext;
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/CurrentInvocationContextInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocation.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocation.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocation.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.core.context;
+
+import org.jboss.ejb3.context.spi.InvocationContext;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public interface EJBInvocation
+{
+   InvocationContext getInvocationContext();
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocation.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocationContextInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocationContextInterceptor.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/EJBInvocationContextInterceptor.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -1,72 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, 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.core.context;
-
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.EJBContainerInvocation;
-import org.jboss.ejb3.aop.LifeCycleInvocation;
-import org.jboss.ejb3.context.CurrentInvocationContext;
-import org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor;
-import org.jboss.ejb3.interceptors.container.LifecycleMethodInterceptorsInvocation;
-
-import javax.interceptor.InvocationContext;
-
-/**
- * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
- */
-public class EJBInvocationContextInterceptor
-{
-   public Object lifecycleInvocation(Invocation invocation) throws Throwable
-   {
-      // the legacy invocation context
-      final InvocationContext invocationContext = InvocationContextInterceptor.getInvocationContext(invocation);
-      BeanContext<?> beanContext = (BeanContext<?>) ((LifecycleMethodInterceptorsInvocation) invocation).getBeanContext();
-      org.jboss.ejb3.context.spi.InvocationContext currentInvocation = beanContext.createLifecycleInvocation(invocationContext);
-      CurrentInvocationContext.push(currentInvocation);
-      try
-      {
-         return invocation.invokeNext();
-      }
-      finally
-      {
-         CurrentInvocationContext.pop();
-      }
-   }
-   
-   public Object methodInvocation(Invocation invocation) throws Throwable
-   {
-      // the legacy invocation context
-      final InvocationContext invocationContext = InvocationContextInterceptor.getInvocationContext(invocation);
-      BeanContext<?> beanContext = ((EJBContainerInvocation) invocation).getBeanContext();
-      org.jboss.ejb3.context.spi.InvocationContext currentInvocation = beanContext.createMethodInvocation(invocationContext);
-      CurrentInvocationContext.push(currentInvocation);
-      try
-      {
-         return invocation.invokeNext();
-      }
-      finally
-      {
-         CurrentInvocationContext.pop();
-      }
-   }
-}

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/InvocationContextAdapter.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/InvocationContextAdapter.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/InvocationContextAdapter.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.core.context;
+
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.ejb3.context.base.BaseInvocationContext;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class InvocationContextAdapter extends BaseInvocationContext
+{
+   private MethodInvocation delegate;
+   
+   public InvocationContextAdapter(MethodInvocation delegate)
+   {
+      super(delegate.getMethod(), delegate.getArguments());
+      this.delegate = delegate;
+   }
+
+   @Override
+   public Object proceed() throws Exception
+   {
+      try
+      {
+         return delegate.invokeNext();
+      }
+      catch(Exception e)
+      {
+         throw e;
+      }
+      catch(Error e)
+      {
+         throw (Error) e;
+      }
+      catch(Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+
+   @Override
+   public void setParameters(Object[] params) throws IllegalArgumentException, IllegalStateException
+   {
+      super.setParameters(params);
+      delegate.setArguments(params);
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/InvocationContextAdapter.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/SessionInvocationContextAdapter.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/SessionInvocationContextAdapter.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/SessionInvocationContextAdapter.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.core.context;
+
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.ejb3.context.base.BaseSessionInvocationContext;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class SessionInvocationContextAdapter extends BaseSessionInvocationContext
+{
+   private MethodInvocation delegate;
+
+   public SessionInvocationContextAdapter(Class<?> invokedBusinessInterface, MethodInvocation delegate)
+   {
+      super(invokedBusinessInterface, delegate.getMethod(), delegate.getArguments());
+      this.delegate = delegate;
+   }
+
+   @Override
+   public Object proceed() throws Exception
+   {
+      try
+      {
+         return delegate.invokeNext();
+      }
+      catch(Exception e)
+      {
+         throw e;
+      }
+      catch(Error e)
+      {
+         throw (Error) e;
+      }
+      catch(Throwable t)
+      {
+         throw new RuntimeException(t);
+      }
+   }
+
+   @Override
+   public void setParameters(Object[] params) throws IllegalArgumentException, IllegalStateException
+   {
+      super.setParameters(params);
+      delegate.setArguments(params);
+   }   
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/core/context/SessionInvocationContextAdapter.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionHelper.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionHelper.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionHelper.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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;
+import org.jboss.injection.Injector;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class InjectionHelper
+{
+   private BeanContext<?> ctx;
+   private Iterable<Injector> injectors;
+
+   public InjectionHelper(BeanContext<?> ctx, Iterable<Injector> injectors)
+   {
+      this.ctx = ctx;
+      this.injectors = injectors;
+   }
+
+   public void inject()
+   {
+      inject(ctx, injectors);
+   }
+
+   public static void inject(BeanContext<?> ctx, Iterable<Injector> injectors)
+   {
+      // inject bean
+      for(Injector injector : injectors)
+      {
+         injector.inject(ctx);
+      }
+      // inject interceptors
+      // TODO: it would be better to create the instances during createBeanContext
+      ctx.initialiseInterceptorInstances();
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionHelper.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionInvocation.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionInvocation.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/injection/InjectionInvocation.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -25,6 +25,8 @@
 import org.jboss.aop.joinpoint.Invocation;
 import org.jboss.aop.joinpoint.InvocationBase;
 import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.ejb3.core.context.EJBInvocation;
 import org.jboss.injection.Injector;
 
 /**
@@ -36,22 +38,23 @@
  * @version $Revision: $
  */
 public class InjectionInvocation extends InvocationBase 
-   implements org.jboss.ejb3.interceptors.container.InjectionInvocation
+   implements EJBInvocation, org.jboss.ejb3.interceptors.container.InjectionInvocation
 {
    private static final long serialVersionUID = 1L;
 
    private BeanContext<?> ctx;
-   private Injector injector;
+   private InvocationContext invocationContext;
    
-   public InjectionInvocation(BeanContext<?> ctx, Injector injector, Interceptor interceptors[])
+   public InjectionInvocation(BeanContext<?> ctx, Iterable<Injector> injectors, Interceptor interceptors[])
    {
       super(interceptors);
       
       assert ctx != null : "ctx is null";
-      assert injector != null : "injector is null";
+      assert injectors != null : "injector is null";
       
       this.ctx = ctx;
-      this.injector = injector;
+      this.invocationContext = ctx.createInjectionInvocation(injectors);
+      invocationContext.setEJBContext(ctx.getEJBContext());
    }
    
    public Invocation copy()
@@ -59,6 +62,11 @@
       throw new RuntimeException("NYI");
    }
 
+   public InvocationContext getInvocationContext()
+   {
+      return invocationContext;
+   }
+
    public Invocation getWrapper(Interceptor[] newchain)
    {
       throw new RuntimeException("NYI");
@@ -82,11 +90,10 @@
 
       return invokeTarget();
    }
-   
+
    @Override
    public Object invokeTarget() throws Throwable
    {
-      injector.inject(ctx);
-      return null;
+      return invocationContext.proceed();
    }
 }

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/LifecycleInterceptorHandler.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/LifecycleInterceptorHandler.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/LifecycleInterceptorHandler.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -1,221 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.interceptor;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import javax.interceptor.InvocationContext;
-import javax.ejb.PostActivate;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.ejb.PrePassivate;
-import javax.ejb.Timeout;
-import javax.ejb.Timer;
-
-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;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- * @deprecated EJBTHREE-1174
- */
- at Deprecated
-public class LifecycleInterceptorHandler
-{
-   private static final Logger log = Logger.getLogger(LifecycleInterceptorHandler.class);
-
-   private EJBContainer container;
-   private InterceptorInfo[] postConstructs;
-   private InterceptorInfo[] postActivates;
-   private InterceptorInfo[] prePassivates;
-   private InterceptorInfo[] preDestroys;
-   private Method[] beanPostConstructs;
-   private Method[] beanPostActivates;
-   private Method[] beanPrePassivates;
-   private Method[] beanPreDestroys;
-   private Method timeoutCallbackMethod;
-   private long timeoutCalllbackHash;
-
-   public LifecycleInterceptorHandler(EJBContainer container, Class[] handledCallbacks)
-   {
-      /*
-      this.container = container;
-      InterceptorInfoRepository repostitory = container.getInterceptorRepository();
-      for (Class clazz : handledCallbacks)
-      {
-         if (clazz == PostConstruct.class)
-         {
-            postConstructs = repostitory.getPostConstructInterceptors(container);
-            beanPostConstructs = repostitory.getBeanClassPostConstructs(container);
-         }
-         else if (clazz == PostActivate.class)
-         {
-            postActivates = repostitory.getPostActivateInterceptors(container);
-            beanPostActivates = repostitory.getBeanClassPostActivates(container);
-         }
-         else if (clazz == PrePassivate.class)
-         {
-            prePassivates = repostitory.getPrePassivateInterceptors(container);
-            beanPrePassivates = repostitory.getBeanClassPrePassivates(container);
-         }
-         else if (clazz == PreDestroy.class)
-         {
-            preDestroys = repostitory.getPreDestroyInterceptors(container);
-            beanPreDestroys = repostitory.getBeanClassPreDestroys(container);
-         }
-         else if (clazz == Timeout.class)
-         {
-            resolveTimeoutCallback();
-         }
-      }
-      */
-      throw new RuntimeException("no longer supported (EJBTHREE-1174)");
-   }
-
-   public long getTimeoutCalllbackHash()
-   {
-      return timeoutCalllbackHash;
-   }
-
-   public void postConstruct(BeanContext ctx, Object[] params)
-   {
-      try
-      {
-         InvocationContext ic = LifecycleInvocationContextImpl.getLifecycleInvocationContext(PostConstruct.class, ctx, postConstructs, beanPostConstructs);
-         ic.setParameters(params);
-         ic.proceed();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public void preDestroy(BeanContext ctx)
-   {
-      Object id = null;
-      if (ctx instanceof StatefulBeanContext)
-      {
-         id = ((StatefulBeanContext)ctx).getId();
-      }
-      try
-      {
-         InvocationContext ic = LifecycleInvocationContextImpl.getLifecycleInvocationContext(
-               PreDestroy.class,
-               ctx,
-               preDestroys,
-               beanPreDestroys);
-         ic.proceed();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public void postActivate(BeanContext ctx)
-   {
-      try
-      {
-         InvocationContext ic = LifecycleInvocationContextImpl.getLifecycleInvocationContext(
-               PostActivate.class,
-               ctx,
-               postActivates,
-               beanPostActivates);
-         ic.proceed();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public void prePassivate(BeanContext ctx)
-   {
-      try
-      {
-         InvocationContext ic = LifecycleInvocationContextImpl.getLifecycleInvocationContext(
-               PrePassivate.class,
-               ctx,
-               prePassivates,
-               beanPrePassivates);
-         ic.proceed();
-      }
-      catch (Exception e)
-      {
-         throw new RuntimeException(e);
-      }
-   }
-
-   public Method getTimeoutCallback()
-   {
-      return timeoutCallbackMethod;
-   }
-
-
-   private void resolveTimeoutCallback()
-   {
-      for (Method method : container.getBeanClass().getMethods())
-      {
-         if (container.resolveAnnotation(method, Timeout.class) != null)
-         {
-            if (Modifier.isPublic(method.getModifiers()) &&
-                  method.getReturnType().equals(Void.TYPE) &&
-                  method.getParameterTypes().length == 1 &&
-                  method.getParameterTypes()[0].equals(Timer.class))
-            {
-               timeoutCallbackMethod = method;
-            }
-            else
-            {
-               throw new RuntimeException("@Timeout methods must have the signature: public void <METHOD>(javax.ejb.Timer timer) - " + method);
-            }
-         }
-      }
-
-      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)
-      {
-         log.error("Exception encoutered in " + LifecycleInterceptorHandler.class.getName()
-               + ".resolveTimeoutCallback()", e);
-      }
-
-      if (timeoutCallbackMethod != null)
-      {
-         timeoutCalllbackHash = MethodHashing.calculateHash(timeoutCallbackMethod);
-      }
-   }
-
-}

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/LifecycleInvocationContextImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/LifecycleInvocationContextImpl.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/interceptor/LifecycleInvocationContextImpl.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -1,223 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.interceptor;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-
-import javax.interceptor.InvocationContext;
-import javax.ejb.PostActivate;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.ejb.PrePassivate;
-
-import org.jboss.ejb3.BeanContext;
-import org.jboss.logging.Logger;
-
-/**
- * 
- * @author <a href="kabir.khan at jboss.com">Kabir Khan</a>
- * @version $Revision$
- */
-public abstract class LifecycleInvocationContextImpl implements InvocationContext
-{
-   private static final Logger log = Logger.getLogger(LifecycleInvocationContextImpl.class);
-   
-   private int currentInterceptor;
-   private int currentMethod;
-   BeanContext beanContext;
-   InterceptorInfo[] interceptorInfos;
-   Object[] instances;
-   private Method[] beanMethods;
-   private HashMap metadata;
-   private Object[] parameters;
-
-   protected LifecycleInvocationContextImpl()
-   {
-   }
-   
-   public static InvocationContext getLifecycleInvocationContext(Class type, BeanContext beanContext, InterceptorInfo[] interceptorInfos, Method[] beanMethods)
-   {
-      LifecycleInvocationContextImpl ic = null;
-      if (type == PostConstruct.class) ic = new PostConstructICtxImpl();
-      else if (type == PostActivate.class) ic = new PostActivateICtxImpl();
-      else if (type == PrePassivate.class) ic = new PrePassivateICtxImpl();
-      else if (type == PreDestroy.class) ic = new PreDestroyICtxImpl();
-      else throw new RuntimeException("Unsupported lifecycle event: " + type);
-      
-      ic.instances = beanContext.getInterceptorInstances(interceptorInfos);
-      if (interceptorInfos.length != ic.instances.length)
-      {
-         throw new RuntimeException("interceptorInfos and instances have different length");
-      }
-      
-      ic.beanContext = beanContext;
-      ic.beanMethods = beanMethods;
-      ic.interceptorInfos = interceptorInfos;
-      
-      return ic;
-   }
-
-   public Object getTarget()
-   {
-      return beanContext.getInstance();
-   }
-
-   public Method getMethod()
-   {
-      return null;
-   }
-
-   public Object[] getParameters()
-   {
-      if (parameters == null)
-         parameters = new Object[0];
-      
-      return parameters;
-   }
-
-   public void setParameters(Object[] params)
-   {
-      this.parameters = params;
-   }
-
-
-   public java.util.Map getContextData()
-   {
-      if (metadata == null) {
-         metadata = new HashMap();
-      }
-      return metadata;
-   }
-
-   public Object proceed() throws Exception
-   {
-      if (currentInterceptor < interceptorInfos.length)
-      {
-         int oldInterceptor = currentInterceptor;
-         int oldMethod = currentMethod;
-         try
-         {
-            int curr = currentInterceptor;
-            int currMethod = currentMethod++;
-            InterceptorInfo info = interceptorInfos[curr];
-            if (currMethod == getLifecycleMethods(info).length)
-            {
-               curr = ++currentInterceptor;
-               currentMethod = 0;
-               currMethod = currentMethod++;
-               info = (curr < interceptorInfos.length) ? interceptorInfos[curr] : null;
-            }
-            
-            if (info != null)
-            {
-               try
-               {
-                  Method[] methods = getLifecycleMethods(info);
-                  return methods[currMethod].invoke(instances[curr], this);
-               }
-               catch (InvocationTargetException e)
-               {
-                  if (e.getTargetException() instanceof Exception)
-                  {
-                     throw ((Exception) e.getCause());
-                  }
-                  else
-                  {
-                     throw new RuntimeException(e.getCause());
-                  }
-               }
-            }
-         }
-         finally
-         {
-            // so that interceptors like clustering can reinvoke down the chain
-            currentInterceptor = oldInterceptor;
-            currentMethod = oldMethod;
-         }
-      }
-      if (beanMethods != null)
-      {
-         try
-         {
-            for (Method beanMethod : beanMethods)
-            {
-               if (beanMethod.getParameterAnnotations().length == getParameters().length)
-                  beanMethod.invoke(getTarget(), getParameters());
-               else
-                  log.error ("Skip attempt of invalid lifecycle method invocation: " + beanMethod);
-            }
-         }
-         catch (InvocationTargetException e)
-         {
-            if (e.getTargetException() instanceof Exception)
-            {
-               throw ((Exception) e.getCause());
-            }
-            else
-            {
-               throw new RuntimeException(e.getCause());
-            }
-         }
-         finally
-         {
-         }
-      }
-      
-      return null;
-   }
-   
-   abstract Method[] getLifecycleMethods(InterceptorInfo info);
-   
-   public static class PostConstructICtxImpl extends LifecycleInvocationContextImpl
-   {
-      Method[] getLifecycleMethods(InterceptorInfo info)
-      {
-         return info.getPostConstructs();
-      }
-   }
-
-   public static class PostActivateICtxImpl extends LifecycleInvocationContextImpl
-   {
-      Method[] getLifecycleMethods(InterceptorInfo info)
-      {
-         return info.getPostActivates();
-      }
-   }
-
-   public static class PrePassivateICtxImpl extends LifecycleInvocationContextImpl
-   {
-      Method[] getLifecycleMethods(InterceptorInfo info)
-      {
-         return info.getPrePassivates();
-      }
-   }
-
-   public static class PreDestroyICtxImpl extends LifecycleInvocationContextImpl
-   {
-      Method[] getLifecycleMethods(InterceptorInfo info)
-      {
-         return info.getPreDestroys();
-      }
-   }
-}

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/ConsumerContainer.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -105,7 +105,7 @@
             throw new RuntimeException("Could not resolve beanClass method from proxy call");
          }
        
-         newSi = new EJBContainerInvocation(info);
+         newSi = new MessageContainerInvocation(info);
          newSi.setArguments(si.getArguments());
          newSi.setMetaData(si.getMetaData());
          newSi.setAdvisor(getAdvisor());

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBContext.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBContext.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -22,8 +22,10 @@
 package org.jboss.ejb3.mdb;
 
 import org.jboss.ejb3.BaseContext;
+import org.jboss.ejb3.context.base.BaseInvocationContext;
 import org.jboss.ejb3.context.spi.EJBContext;
 import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.injection.Injector;
 
 /**
  * Comment
@@ -40,14 +42,20 @@
       super(container, bean);
    }
 
-   public InvocationContext createLifecycleInvocation(javax.interceptor.InvocationContext delegate)
+   public InvocationContext createInjectionInvocation(Iterable<Injector> injectors)
    {
-      return new MDBInvocationContextImpl(this, delegate);
+      return new MDBInjectionInvocation(this, injectors);
    }
 
-   public InvocationContext createMethodInvocation(javax.interceptor.InvocationContext delegate)
+   public InvocationContext createLifecycleInvocation()
    {
-      return new MDBInvocationContextImpl(this, delegate);
+      return new BaseInvocationContext(null, null) {
+         @Override
+         public Object proceed() throws Exception
+         {
+            throw new RuntimeException("NYI");
+         }
+      };
    }
 
    public void remove()

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInjectionInvocation.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInjectionInvocation.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInjectionInvocation.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.mdb;
+
+import org.jboss.ejb3.context.base.BaseInvocationContext;
+import org.jboss.ejb3.injection.InjectionHelper;
+import org.jboss.injection.Injector;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class MDBInjectionInvocation extends BaseInvocationContext
+{
+   private InjectionHelper helper;
+
+   public MDBInjectionInvocation(MDBContext context, Iterable<Injector> injectors)
+   {
+      // injection does not have a method or parameters
+      super(null, null);
+      this.helper = new InjectionHelper(context, injectors);
+   }
+
+   @Override
+   public Object proceed() throws Exception
+   {
+      helper.inject();
+      return null;
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInjectionInvocation.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInvocationContextImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInvocationContextImpl.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MDBInvocationContextImpl.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, 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.mdb;
-
-import org.jboss.ejb3.context.base.BaseInvocationContext;
-import org.jboss.ejb3.context.spi.SessionContext;
-
-import javax.interceptor.InvocationContext;
-import java.security.Principal;
-
-/**
- * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
- */
-public class MDBInvocationContextImpl extends BaseInvocationContext
-{
-   private MDBContext ctx;
-   private InvocationContext delegate;
-   
-   public MDBInvocationContextImpl(MDBContext ctx, InvocationContext delegate)
-   {
-      super(delegate.getMethod(), delegate.getMethod() != null ? delegate.getParameters() : null);
-
-      this.ctx = ctx;
-      this.delegate = delegate;
-   }
-
-   // legacy
-   @Override
-   public Principal getCallerPrincipal()
-   {
-      return getEJBContext().getCallerPrincipal();
-   }
-
-   @Override
-   public SessionContext getEJBContext()
-   {
-      return (SessionContext) ctx.getEJBContext();
-   }
-   
-   @Override
-   public Object proceed() throws Exception
-   {
-      return delegate.proceed();
-   }
-}

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessageContainerInvocation.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessageContainerInvocation.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessageContainerInvocation.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.mdb;
+
+import org.jboss.aop.MethodInfo;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.ejb3.core.context.InvocationContextAdapter;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class MessageContainerInvocation<A extends MessagingContainer, T extends BeanContext<A>> extends EJBContainerInvocation<A, T>
+{
+   private InvocationContextAdapter invocationContext;
+
+   public MessageContainerInvocation(MethodInfo info)
+   {
+      super(info);
+      this.invocationContext = new InvocationContextAdapter(this);
+   }
+
+   public InvocationContext getInvocationContext()
+   {
+      return invocationContext;
+   }
+   
+   @Override
+   public void setBeanContext(org.jboss.ejb3.interceptors.container.BeanContext<?> beanCtx)
+   {
+      super.setBeanContext(beanCtx);
+      if(beanCtx == null)
+         invocationContext.setEJBContext(null);
+      else
+         invocationContext.setEJBContext(((org.jboss.ejb3.BeanContext<?>) beanCtx).getEJBContext());
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessageContainerInvocation.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -271,7 +271,7 @@
       pushEnc();
       try
       {
-         EJBContainerInvocation nextInvocation = new EJBContainerInvocation(info);
+         EJBContainerInvocation nextInvocation = new MessageContainerInvocation(info);
          nextInvocation.setAdvisor(getAdvisor());
          nextInvocation.setArguments(args);
          return nextInvocation.invokeNext();

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/pool/AbstractPool.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/pool/AbstractPool.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/pool/AbstractPool.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -81,9 +81,6 @@
       try
       {
          container.injectBeanContext(ctx);
-
-         ctx.initialiseInterceptorInstances();
-
       }
       finally
       {

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceBeanContext.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceBeanContext.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -21,9 +21,13 @@
  */
 package org.jboss.ejb3.service;
 
+import org.jboss.ejb3.context.base.BaseSessionInvocationContext;
 import org.jboss.ejb3.context.spi.EJBContext;
 import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.ejb3.context.spi.SessionInvocationContext;
 import org.jboss.ejb3.session.SessionBeanContext;
+import org.jboss.ejb3.session.SessionInjectionInvocation;
+import org.jboss.injection.Injector;
 
 /**
  * @author <a href="mailto:kabir.khan at jboss.org">Kabir Khan</a>
@@ -36,14 +40,20 @@
       super(container, bean);
    }
 
-   public InvocationContext createLifecycleInvocation(javax.interceptor.InvocationContext delegate)
+   public InvocationContext createInjectionInvocation(Iterable<Injector> injectors)
    {
-      return new ServiceInvocationContextImpl(this, delegate);
+      return new SessionInjectionInvocation<ServiceContainer>(this, injectors);
    }
 
-   public InvocationContext createMethodInvocation(javax.interceptor.InvocationContext delegate)
+   public SessionInvocationContext createLifecycleInvocation()
    {
-      return new ServiceInvocationContextImpl(this, delegate);
+      return new BaseSessionInvocationContext(null, null, null) {
+         @Override
+         public Object proceed() throws Exception
+         {
+            throw new RuntimeException("NYI");
+         }
+      };
    }
 
    public void remove()

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-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceContainer.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -473,7 +473,7 @@
          {
             throw new RuntimeException("Could not resolve beanClass method from proxy call: " + method.toString());
          }
-         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, null);
+         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, null, null);
          nextInvocation.setAdvisor(getAdvisor());
          nextInvocation.setArguments(args);
 
@@ -516,7 +516,7 @@
          {
             throw new RuntimeException("Could not resolve beanClass method from proxy call");
          }
-         newSi = new StatefulContainerInvocation(info, null);
+         newSi = new StatefulContainerInvocation(info, null, null);
          newSi.setArguments(si.getArguments());
          newSi.setMetaData(si.getMetaData());
          newSi.setAdvisor(getAdvisor());
@@ -561,15 +561,6 @@
             if (beanContext == null)
             {
                beanContext = createBeanContext();
-               pushEnc();
-               try
-               {
-                  beanContext.initialiseInterceptorInstances();
-               }
-               finally
-               {
-                  popEnc();
-               }
             }
          }
       }
@@ -591,13 +582,10 @@
    {
       if (injectors != null)
       {
+         pushEnc();
          try
          {
-            pushEnc();
-            for (Injector injector : injectors)
-            {
-               injector.inject(ctx);
-            }
+            injectBeanContext(ctx);
          }
          finally
          {

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceInvocationContextImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceInvocationContextImpl.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceInvocationContextImpl.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, 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.service;
-
-import org.jboss.ejb3.context.base.BaseInvocationContext;
-import org.jboss.ejb3.context.spi.SessionContext;
-
-import javax.interceptor.InvocationContext;
-import java.security.Principal;
-
-/**
- * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
- */
-public class ServiceInvocationContextImpl extends BaseInvocationContext
-{
-   private ServiceBeanContext ctx;
-   private InvocationContext delegate;
-
-   public ServiceInvocationContextImpl(ServiceBeanContext ctx, InvocationContext delegate)
-   {
-      super(delegate.getMethod(), delegate.getMethod() != null ? delegate.getParameters() : null);
-
-      this.ctx = ctx;
-      this.delegate = delegate;
-   }
-
-   // legacy
-   @Override
-   public Principal getCallerPrincipal()
-   {
-      return getEJBContext().getCallerPrincipal();
-   }
-
-   @Override
-   public SessionContext getEJBContext()
-   {
-      return (SessionContext) ctx.getEJBContext();
-   }
-
-   @Override
-   public Object proceed() throws Exception
-   {
-      return delegate.proceed();
-   }
-}

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceSessionContextImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceSessionContextImpl.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/service/ServiceSessionContextImpl.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -21,13 +21,14 @@
  */
 package org.jboss.ejb3.service;
 
+import org.jboss.ejb3.EJBContextImpl;
+import org.jboss.ejb3.context.spi.SessionBeanManager;
+import org.jboss.ejb3.context.spi.SessionContext;
+
 import javax.ejb.EJBLocalObject;
 import javax.ejb.EJBObject;
-import javax.ejb.SessionContext;
 import javax.xml.rpc.handler.MessageContext;
 
-import org.jboss.ejb3.EJBContextImpl;
-
 /**
  * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
  * @version $Revision: $
@@ -63,8 +64,19 @@
       throw new RuntimeException("NYI");
    }
 
+   @Override
+   public SessionBeanManager getManager()
+   {
+      return (SessionBeanManager) super.getManager();
+   }
+
    public MessageContext getMessageContext() throws IllegalStateException
    {
       throw new RuntimeException("NYI");
    }
+
+   public boolean wasCancelCalled() throws IllegalStateException
+   {
+      throw new RuntimeException("NYI");
+   }
 }

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainer.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -652,7 +652,7 @@
 //         }
 
          // FIXME: Ahem, stateful container invocation works on all.... (violating contract though)
-         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
+         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id, null);
          //StatefulSessionContainerMethodInvocation nextInvocation = new StatefulSessionContainerMethodInvocation(info,null);
          //EJBContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
          nextInvocation.setAdvisor(getAdvisor());

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainerInvocation.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainerInvocation.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainerInvocation.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.session;
+
+import org.jboss.aop.MethodInfo;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.context.spi.SessionInvocationContext;
+import org.jboss.ejb3.core.context.SessionInvocationContextAdapter;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class SessionContainerInvocation<A extends SessionContainer, T extends BeanContext<A>> extends EJBContainerInvocation<A, T>
+{
+   private SessionInvocationContext invocationContext;
+
+   public SessionContainerInvocation(Class<?> invokedBusinessInterface, MethodInfo info)
+   {
+      super(info);
+      this.invocationContext = new SessionInvocationContextAdapter(invokedBusinessInterface, this);
+   }
+
+   public SessionInvocationContext getInvocationContext()
+   {
+      return invocationContext;
+   }
+
+   @Override
+   public void setBeanContext(org.jboss.ejb3.interceptors.container.BeanContext<?> beanCtx)
+   {
+      super.setBeanContext(beanCtx);
+      if(beanCtx == null)
+         invocationContext.setEJBContext(null);
+      else
+         invocationContext.setEJBContext(((org.jboss.ejb3.BeanContext<?>) beanCtx).getEJBContext());
+   }   
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContainerInvocation.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContextDelegateBase.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContextDelegateBase.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionContextDelegateBase.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -22,9 +22,10 @@
 package org.jboss.ejb3.session;
 
 import org.jboss.ejb3.EJBContextImpl;
-import org.jboss.ejb3.context.spi.BeanManager;
+import org.jboss.ejb3.context.CurrentInvocationContext;
 import org.jboss.ejb3.context.spi.SessionBeanManager;
 import org.jboss.ejb3.context.spi.SessionContext;
+import org.jboss.ejb3.context.spi.SessionInvocationContext;
 import org.jboss.ejb3.stateless.StatelessBeanContext;
 import org.jboss.logging.Logger;
 
@@ -71,7 +72,7 @@
    
    public Class<?> getInvokedBusinessInterface() throws IllegalStateException
    {
-      return container.getInvokedBusinessInterface();
+      return CurrentInvocationContext.get(SessionInvocationContext.class).getInvokedBusinessInterface();
    }
 
    @Override

Added: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInjectionInvocation.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInjectionInvocation.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInjectionInvocation.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.session;
+
+import org.jboss.ejb3.context.base.BaseSessionInvocationContext;
+import org.jboss.ejb3.injection.InjectionHelper;
+import org.jboss.injection.Injector;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class SessionInjectionInvocation<T extends SessionContainer> extends BaseSessionInvocationContext
+{
+   private InjectionHelper helper;
+
+   public SessionInjectionInvocation(SessionBeanContext<T> ctx, Iterable<Injector> injectors)
+   {
+      // injection does not have an invoked business interface, method or parameters
+      super(null, null, null);
+      this.helper = new InjectionHelper(ctx, injectors);
+   }
+
+   @Override
+   public Object proceed() throws Exception
+   {
+      helper.inject();
+      return null;
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInjectionInvocation.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Deleted: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInvocationContextImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInvocationContextImpl.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionInvocationContextImpl.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright (c) 2010, 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.session;
-
-import org.jboss.ejb3.context.base.BaseSessionInvocationContext;
-import org.jboss.ejb3.context.spi.SessionContext;
-
-import javax.interceptor.InvocationContext;
-import javax.xml.rpc.handler.MessageContext;
-import java.security.Principal;
-
-/**
- * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
- */
-public class SessionInvocationContextImpl<C extends SessionSpecContainer> extends BaseSessionInvocationContext
-{
-   private SessionSpecBeanContext<C> ctx;
-   private InvocationContext delegate;
-   
-   public SessionInvocationContextImpl(SessionSpecBeanContext<C> ctx, InvocationContext delegate)
-   {
-      // we override getInvokedBusinessInterface, because we can't verify here whether it's an EJB 3 view invocation
-      super(null, delegate.getMethod(), delegate.getMethod() != null ? delegate.getParameters() : null);
-
-      this.ctx = ctx;
-      this.delegate = delegate;
-   }
-
-   @Override
-   public Class<?> getInvokedBusinessInterface() throws IllegalStateException
-   {
-      return ctx.getContainer().getInvokedBusinessInterface();
-   }
-
-   // legacy
-   @Override
-   public Principal getCallerPrincipal()
-   {
-      return getEJBContext().getCallerPrincipal();
-   }
-
-   @Override
-   public SessionContext getEJBContext()
-   {
-      return (SessionContext) ctx.getEJBContext();
-   }
-
-   // legacy
-   @Override
-   public MessageContext getMessageContext() throws IllegalStateException
-   {
-      return getEJBContext().getMessageContext();
-   }
-
-   @Override
-   public Object proceed() throws Exception
-   {
-      return delegate.proceed();
-   }
-}

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecBeanContext.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -21,7 +21,10 @@
  */
 package org.jboss.ejb3.session;
 
+import org.jboss.ejb3.context.base.BaseSessionInvocationContext;
 import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.ejb3.context.spi.SessionInvocationContext;
+import org.jboss.injection.Injector;
 
 /**
  * Context for Session Beans adhering to EJB3 Specification (SFSB, SLSB)
@@ -54,13 +57,19 @@
       
    }
 
-   public InvocationContext createLifecycleInvocation(javax.interceptor.InvocationContext delegate)
+   public InvocationContext createInjectionInvocation(Iterable<Injector> injectors)
    {
-      return new SessionInvocationContextImpl(this, delegate);
+      return new SessionInjectionInvocation<T>(this, injectors);
    }
 
-   public InvocationContext createMethodInvocation(javax.interceptor.InvocationContext delegate)
+   public SessionInvocationContext createLifecycleInvocation()
    {
-      return new SessionInvocationContextImpl(this, delegate);
+      return new BaseSessionInvocationContext(null, null, null) {
+         @Override
+         public Object proceed() throws Exception
+         {
+            throw new RuntimeException("NYI");
+         }
+      };
    }
 }

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/session/SessionSpecContainer.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -53,13 +53,6 @@
 
    private static final Logger log = Logger.getLogger(SessionSpecContainer.class);
 
-   /**
-    * The method invoked upon by the client
-    */
-   //TODO: Remove when CurrentInvocation is completely sorted out
-   @Deprecated
-   protected static ThreadLocalStack<SerializableMethod> invokedMethod = new ThreadLocalStack<SerializableMethod>();
-
    // ------------------------------------------------------------------------------||
    // Constructor ------------------------------------------------------------------||
    // ------------------------------------------------------------------------------||
@@ -152,8 +145,7 @@
 
       try
       {
-
-         invokedMethod.push(method);
+         Class<?> invokedBusinessInterface = Class.forName(method.getActualClassName(), false, getClassloader());
          
          // Increment invocation statistics
          invokeStats.callIn();
@@ -176,7 +168,7 @@
           * Build an invocation
           */
 
-         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, session);
+         StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, session, invokedBusinessInterface);
          nextInvocation.getMetaData().addMetaData(SessionSpecRemotingMetadata.TAG_SESSION_INVOCATION,
                SessionSpecRemotingMetadata.KEY_INVOKED_METHOD, method);
          nextInvocation.setArguments(args);
@@ -208,7 +200,6 @@
          // Complete call to increment statistics
          invokeStats.callOut();
          
-         invokedMethod.pop();
          SecurityActions.setContextClassLoader(oldLoader);
       }
    }
@@ -247,117 +238,6 @@
    }
 
    /**
-    * Fulfills javax.ejb.SessionContext.getInvokedBusinessInterface()
-    * 
-    * Returns the name of the invoking EJB3 Business Interface
-    * 
-    * @see EJB 3.0 Core Specification 4.5.2 for allowable context in 
-    * which this may be invoked
-    * @return
-    */
-   public Class<?> getInvokedBusinessInterface()
-   {
-      //TODO Should be getting from current invocation
-      SerializableMethod invokedMethod = SessionSpecContainer.invokedMethod.get();
-      assert invokedMethod != null : "Invoked Method has not been set";
-
-      // Obtain the name of the invoking interface
-      String interfaceName = null;
-      if (invokedMethod != null)
-      {
-         interfaceName = invokedMethod.getActualClassName();
-      }
-
-      // Test for no invoked business interface
-      if (interfaceName == null)
-      {
-         throw new IllegalStateException("Call to " + SessionContext.class.getName()
-               + ".getInvokedBusinessInterface() was made from outside an EJB3 Business Interface "
-               + "(possibly an EJB2.x Remote/Local?). " + "EJB 3.0 Specification 4.5.2.");
-      }
-
-      /*
-       * Determine if the specified class is not a valid business
-       * interface
-       */
-
-      // Initialize a check flag
-      boolean isValidBusinessInterface = false;
-
-      // Get Metadata
-      JBossSessionBeanMetaData smd = this.getMetaData();
-
-      // Check in business remotes
-      BusinessRemotesMetaData businessRemotes = smd.getBusinessRemotes();
-      if (businessRemotes != null)
-      {
-         for (String businessRemote : businessRemotes)
-         {
-            if (businessRemote.equals(interfaceName))
-            {
-               isValidBusinessInterface = true;
-               break;
-            }
-         }
-      }
-
-      // Check in business locals
-      BusinessLocalsMetaData businessLocals = smd.getBusinessLocals();
-      if (businessLocals != null)
-      {
-         for (String businessLocal : businessLocals)
-         {
-            if (businessLocal.equals(interfaceName))
-            {
-               isValidBusinessInterface = true;
-               break;
-            }
-         }
-      }
-
-      // If not found as a business interface, we haven't invoked through EJB3 View
-      if (!isValidBusinessInterface)
-      {
-         throw new IllegalStateException("Cannot invoke " + SessionContext.class.getName()
-               + ".getInvokedBusinessInterface() from outside of an EJB3 Business View - "
-               + "EJB 3.0 Core Specification 4.5.2; Used: " + interfaceName);
-      }
-
-      /*
-       * Get Invoked Interface
-       */
-
-      // Attempt to load the invoked interface
-      Class<?> invokedInterface = null;
-      try
-      {
-         invokedInterface = Class.forName(interfaceName, false, this.getClassloader());
-      }
-      catch (ClassNotFoundException e)
-      {
-         throw new RuntimeException("Invoked Business Interface on Proxy was set to " + interfaceName
-               + ", but this could not be loaded by the " + ClassLoader.class.getSimpleName() + " for " + this);
-      }
-      //      if (method == null) throw new IllegalStateException("getInvokedBusinessInterface() being invoked outside of a business invocation");
-      //      if (method.getName() == null || method.getName().equals("")) throw new IllegalStateException("getInvokedBusinessInterface() being invoked outside of a business invocation");
-
-      //      String invokedBusinessInterfaceClassName = method.getActualClassName();
-      //      Class<?> invokedBusinessInterface = null;
-      //      try
-      //      {
-      //         invokedBusinessInterface = this.getClassloader().loadClass(invokedBusinessInterfaceClassName);
-      //      }
-      //      catch (ClassNotFoundException e)
-      //      {
-      //         throw new RuntimeException("Invoked Business Interface on Proxy was set to "
-      //               + invokedBusinessInterfaceClassName + ", but this could not be loaded by the "
-      //               + ClassLoader.class.getSimpleName() + " for " + this);
-      //      }
-
-      return invokedInterface;
-   }
-
-   /**
     * Provides implementation for this bean's EJB 2.1 Home.create() method 
     * 
     * @param factory

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/SessionSynchronizationInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/SessionSynchronizationInterceptor.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/SessionSynchronizationInterceptor.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -21,7 +21,16 @@
  */
 package org.jboss.ejb3.stateful;
 
-import java.rmi.RemoteException;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb.AllowedOperationsAssociation;
+import org.jboss.ejb3.BeanContext;
+import org.jboss.ejb3.context.CurrentInvocationContext;
+import org.jboss.ejb3.context.base.BaseSessionInvocationContext;
+import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.ejb3.context.spi.SessionInvocationContext;
+import org.jboss.ejb3.tx.TxUtil;
+import org.jboss.logging.Logger;
 
 import javax.ejb.EJBException;
 import javax.ejb.SessionSynchronization;
@@ -31,14 +40,8 @@
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
 import javax.transaction.TransactionManager;
+import java.rmi.RemoteException;
 
-import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.ejb.AllowedOperationsAssociation;
-import org.jboss.ejb3.BeanContext;
-import org.jboss.ejb3.tx.TxUtil;
-import org.jboss.logging.Logger;
-
 /**
  * Comment
  *
@@ -72,7 +75,7 @@
 
       public void beforeCompletion()
       {
-         SessionSynchronization bean = (SessionSynchronization) ctx.getInstance();
+         final SessionSynchronization bean = (SessionSynchronization) ctx.getInstance();
          // The bean might be lost in action if an exception is thrown in afterBegin
          if(bean == null)
             return;
@@ -82,10 +85,32 @@
             // FIXME: This is a dirty hack to notify AS EJBTimerService about what's going on
             AllowedOperationsAssociation.pushInMethodFlag(AllowedOperationsAssociation.IN_BEFORE_COMPLETION);
             
-            bean.beforeCompletion();
+            // TODO: use interceptors to setup a context
+            SessionInvocationContext invocation = new BaseSessionInvocationContext(null, null, null) {
+               @Override
+               public Object proceed() throws Exception
+               {
+                  bean.beforeCompletion();
+                  return null;
+               }
+            };
+            invocation.setEJBContext(ctx.getEJBContext());
+            CurrentInvocationContext.push(invocation);
+            try
+            {
+               invocation.proceed();
+            }
+            finally
+            {
+               CurrentInvocationContext.pop();
+            }            
          }
-         catch (RemoteException e)
+         catch(RuntimeException e)
          {
+            throw e;
+         }
+         catch(Exception e)
+         {
             throw new RuntimeException(e);
          }
          finally
@@ -95,28 +120,50 @@
          }
       }
 
-      public void afterCompletion(int status)
+      public void afterCompletion(final int status)
       {
          ctx.setTxSynchronized(false);
-         SessionSynchronization bean = (SessionSynchronization) ctx.getInstance();
+         final SessionSynchronization bean = (SessionSynchronization) ctx.getInstance();
          // The bean might be lost in action if an exception is thrown in afterBegin
          if(bean == null)
             return;
          pushEnc();
          try
          {
-            if (status == Status.STATUS_COMMITTED)
+            // TODO: use interceptors to setup a context
+            SessionInvocationContext invocation = new BaseSessionInvocationContext(null, null, null) {
+               @Override
+               public Object proceed() throws Exception
+               {
+                  if (status == Status.STATUS_COMMITTED)
+                  {
+                     bean.afterCompletion(true);
+                  }
+                  else
+                  {
+                     bean.afterCompletion(false);
+                  }
+                  return null;
+               }
+            };
+            invocation.setEJBContext(ctx.getEJBContext());
+            CurrentInvocationContext.push(invocation);
+            try
             {
-               bean.afterCompletion(true);
+               invocation.proceed();
             }
-            else
+            finally
             {
-               bean.afterCompletion(false);
+               CurrentInvocationContext.pop();
             }
          }
-         catch (RemoteException ignore)
+         catch(RuntimeException e)
          {
+            throw e;
          }
+         catch (Exception ignore)
+         {
+         }
          finally
          {
             popEnc();

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainer.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -128,9 +128,6 @@
       try
       {
          injectBeanContext(sfctx);
-
-         sfctx.initialiseInterceptorInstances();
-
       }
       finally
       {
@@ -346,7 +343,7 @@
 
             SerializableMethod invoked = new SerializableMethod(method, method.getClass());
 
-            StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id);
+            StatefulContainerInvocation nextInvocation = new StatefulContainerInvocation(info, id, null);
             //StatefulSessionContainerMethodInvocation nextInvocation = new StatefulSessionContainerMethodInvocation(info);
             //nextInvocation.setSessionId(id);
             nextInvocation.setAdvisor(getAdvisor());
@@ -476,12 +473,7 @@
                + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
          SerializableMethod invokedMethod = (SerializableMethod) objInvokedMethod;
 
-         /*
-          * Set the invoked method
-          */
-         //TODO Remove when CurrentInvocation is ironed out
-         // Set onto stack
-         SessionSpecContainer.invokedMethod.push(invokedMethod);
+         Class<?> invokedBusinessInterface = Class.forName(invokedMethod.getActualClassName(), false, this.getClassloader());
 
          try
          {
@@ -533,7 +525,7 @@
                 */
 
                // Construct the invocation
-               newSi = new StatefulContainerInvocation(info, sessionId);
+               newSi = new StatefulContainerInvocation(info, sessionId, invokedBusinessInterface);
                //newSi = new StatefulContainerInvocation(info.getInterceptors(), long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor, Object id);
                newSi.setArguments(si.getArguments());
                newSi.setMetaData(si.getMetaData());
@@ -617,11 +609,6 @@
       }
       finally
       {
-
-         // Pop invoked method off the stack
-         //TODO Remove when CurrentInvocation handles this
-         SessionSpecContainer.invokedMethod.pop();
-
          // Reset the TCL to original
          Thread.currentThread().setContextClassLoader(originalLoader);;
       }
@@ -724,7 +711,7 @@
          interceptors = stack.createInterceptors(getAdvisor(), null);
       }
 
-      StatefulContainerInvocation invocation = new StatefulContainerInvocation(interceptors, 0L, initMethod, initMethod, getAdvisor(), sessionId);
+      StatefulContainerInvocation invocation = new StatefulContainerInvocation(interceptors, 0L, initMethod, initMethod, getAdvisor(), sessionId, null);
       invocation.setArguments(initParameterValues);
       if(metaData != null)
          invocation.setMetaData(metaData);
@@ -1204,11 +1191,11 @@
       {
          StatefulBeanContext ctx = getCache().create(null, null);
          newId = ctx.getId();
-         newStatefulInvocation = new StatefulContainerInvocation(info, newId);
+         newStatefulInvocation = new StatefulContainerInvocation(info, newId, null);
       }
       else
       {
-         newStatefulInvocation = new StatefulContainerInvocation(info, statefulInvocation.getId());
+         newStatefulInvocation = new StatefulContainerInvocation(info, statefulInvocation.getId(), null);
       }
 
       newStatefulInvocation.setArguments(statefulInvocation.getArguments());

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainerInvocation.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainerInvocation.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateful/StatefulContainerInvocation.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -21,14 +21,20 @@
  */
 package org.jboss.ejb3.stateful;
 
-import java.lang.reflect.Method;
-
 import org.jboss.aop.Advisor;
 import org.jboss.aop.MethodInfo;
 import org.jboss.aop.advice.Interceptor;
 import org.jboss.aop.joinpoint.Invocation;
 import org.jboss.ejb3.EJBContainerInvocation;
+import org.jboss.ejb3.context.base.BaseSessionInvocationContext;
+import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.ejb3.context.spi.SessionInvocationContext;
+import org.jboss.ejb3.core.context.EJBInvocation;
+import org.jboss.ejb3.core.context.SessionInvocationContextAdapter;
+import org.jboss.ejb3.interceptors.container.BeanContext;
 
+import java.lang.reflect.Method;
+
 /**
  * Comment
  *
@@ -36,21 +42,25 @@
  * @version $Revision$
  */
 public class StatefulContainerInvocation extends EJBContainerInvocation<StatefulContainer, StatefulBeanContext>
+   implements EJBInvocation
 {
    private static final long serialVersionUID = -7636489066612082373L;
    
    private Object id;
+   private SessionInvocationContext invocationContext;
 
-   public StatefulContainerInvocation(Interceptor[] interceptors, long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor, Object id)
+   public StatefulContainerInvocation(Interceptor[] interceptors, long methodHash, Method advisedMethod, Method unadvisedMethod, Advisor advisor, Object id, Class<?> invokedBusinessInterface)
    {
       super(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor);
       this.id = id;
+      this.invocationContext = new SessionInvocationContextAdapter(invokedBusinessInterface, this);
    }
 
-   public StatefulContainerInvocation(MethodInfo info, Object id)
+   public StatefulContainerInvocation(MethodInfo info, Object id, Class<?> invokedBusinessInterface)
    {
       super(info);
       this.id = id;
+      this.invocationContext = new SessionInvocationContextAdapter(invokedBusinessInterface, this);
    }
 
    public StatefulContainerInvocation()
@@ -64,7 +74,7 @@
 
    public Invocation copy()
    {
-      StatefulContainerInvocation wrapper = new StatefulContainerInvocation(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor, id);
+      StatefulContainerInvocation wrapper = new StatefulContainerInvocation(interceptors, methodHash, advisedMethod, unadvisedMethod, advisor, id, invocationContext.getInvokedBusinessInterface());
       wrapper.metadata = this.metadata;
       wrapper.currentInterceptor = this.currentInterceptor;
       //wrapper.setTargetObject(this.getTargetObject());
@@ -73,4 +83,18 @@
       return wrapper;
    }
 
+   public InvocationContext getInvocationContext()
+   {
+      return invocationContext;
+   }
+
+   @Override
+   public void setBeanContext(BeanContext<?> beanCtx)
+   {
+      super.setBeanContext(beanCtx);
+      if(beanCtx == null)
+         invocationContext.setEJBContext(null);
+      else
+         invocationContext.setEJBContext(((org.jboss.ejb3.BeanContext<?>) beanCtx).getEJBContext());
+   }
 }

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -22,23 +22,6 @@
 package org.jboss.ejb3.stateless;
 
 
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ejb.EJBContext;
-import javax.ejb.EJBException;
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
-import javax.ejb.Handle;
-import javax.ejb.RemoteHome;
-import javax.ejb.Timer;
-import javax.ejb.TimerService;
-import javax.naming.NamingException;
-
 import org.jboss.aop.Advisor;
 import org.jboss.aop.Domain;
 import org.jboss.aop.MethodInfo;
@@ -70,6 +53,7 @@
 import org.jboss.ejb3.proxy.impl.remoting.SessionSpecRemotingMetadata;
 import org.jboss.ejb3.proxy.spi.container.InvokableContext;
 import org.jboss.ejb3.session.SessionContainer;
+import org.jboss.ejb3.session.SessionContainerInvocation;
 import org.jboss.ejb3.session.SessionSpecContainer;
 import org.jboss.ejb3.timerservice.spi.TimedObjectInvoker;
 import org.jboss.ejb3.timerservice.spi.TimerServiceFactory;
@@ -90,7 +74,23 @@
 import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
 import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
 
+import javax.ejb.EJBContext;
+import javax.ejb.EJBException;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.Handle;
+import javax.ejb.RemoteHome;
+import javax.ejb.Timer;
+import javax.ejb.TimerService;
+import javax.naming.NamingException;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Set;
 
+
 /**
  * Comment
  *
@@ -262,7 +262,7 @@
          try
          {
             MethodInfo info = super.getMethodInfo(timeout);
-            EJBContainerInvocation nextInvocation = new EJBContainerInvocation(info);
+            EJBContainerInvocation nextInvocation = new SessionContainerInvocation(null, info);
             nextInvocation.setAdvisor(getAdvisor());
             nextInvocation.setArguments(args);
             nextInvocation.invokeNext();
@@ -317,7 +317,7 @@
                return localHomeInvoke(unadvisedMethod, args);
             }
 
-            EJBContainerInvocation<StatelessContainer, StatelessBeanContext> nextInvocation = new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
+            EJBContainerInvocation<StatelessContainer, StatelessBeanContext> nextInvocation = new SessionContainerInvocation<StatelessContainer, StatelessBeanContext>(null, info);
             nextInvocation.setAdvisor(getAdvisor());
             nextInvocation.setArguments(args);
             nextInvocation.setContextCallback(callback);
@@ -413,10 +413,8 @@
             assert objInvokedMethod instanceof SerializableMethod : "Invoked Method set on invocation metadata is not of type " + SerializableMethod.class.getName() + ", instead: " + objInvokedMethod;
             SerializableMethod invokedMethod = (SerializableMethod)objInvokedMethod;
             
-            // Set onto stack
-            SessionSpecContainer.invokedMethod.push(invokedMethod);
+            Class<?> invokedBusinessInterface = Class.forName(invokedMethod.getActualClassName(), false, this.getClassloader());
 
-            //invokedMethod.push(new SerializableMethod(unadvisedMethod, unadvisedMethod.getClass()));
             Map responseContext = null;
             Object rtn = null;
             if (unadvisedMethod != null && isHomeMethod(unadvisedMethodSerializable))
@@ -430,7 +428,7 @@
             else
             {
 
-               newSi = new EJBContainerInvocation<StatelessContainer, StatelessBeanContext>(info);
+               newSi = new SessionContainerInvocation<StatelessContainer, StatelessBeanContext>(invokedBusinessInterface, info);
                newSi.setArguments(si.getArguments());
                newSi.setMetaData(si.getMetaData());
                //newSi.setAdvisor(getAdvisor());               
@@ -445,10 +443,6 @@
                   responseContext = newSi.getResponseContextInfo();
                   return marshallException(invocation, throwable, responseContext);
                }
-               finally
-               {
-                  SessionSpecContainer.invokedMethod.pop();
-               }
             }
 
             response = marshallResponse(invocation, rtn, responseContext);

Modified: projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessSessionContextImpl.java
===================================================================
--- projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessSessionContextImpl.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/stateless/StatelessSessionContextImpl.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -21,13 +21,12 @@
  */
 package org.jboss.ejb3.stateless;
 
-import javax.ejb.EJBLocalObject;
-import javax.ejb.EJBObject;
-import javax.ejb.SessionContext;
-
 import org.jboss.ejb3.session.SessionBeanContext;
 import org.jboss.ejb3.session.SessionContextDelegateBase;
 
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+
 /**
  * A session context that is serializable.
  * 
@@ -38,8 +37,6 @@
  * @version $Revision: 68144 $
  */
 public class StatelessSessionContextImpl extends SessionContextDelegateBase<StatelessContainer>
-      implements
-         SessionContext
 {
    public StatelessSessionContextImpl(SessionBeanContext<StatelessContainer> beanContext)
    {

Modified: projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml
===================================================================
--- projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/main/resources/ejb3-interceptors-aop.xml	2010-03-16 19:03:31 UTC (rev 102482)
@@ -78,7 +78,7 @@
    <!--  EJBTHREE-1841 No longer needed in core
    <aspect name="InterceptorsFactory" factory="org.jboss.ejb3.interceptors.aop.InterceptorsFactory" scope="PER_INSTANCE"/> -->
    <aspect name="InvocationContextInterceptor" class="org.jboss.ejb3.interceptors.aop.InvocationContextInterceptor" scope="PER_VM"/>
-   <aspect name="EJBInvocationContextInterceptor" class="org.jboss.ejb3.core.context.EJBInvocationContextInterceptor" scope="PER_VM"/>
+   <interceptor name="CurrentInvocationContextInterceptor" class="org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor" scope="PER_VM"/>
 
    <!-- TODO: this is actually the bootstrap container -->
    <domain name="Intercepted Bean">
@@ -126,20 +126,25 @@
 
          <advice name="setup" aspect="InvocationContextInterceptor"/>
          <advice name="fillMethod" aspect="InvocationContextInterceptor"/>
-         <advice name="methodInvocation" aspect="EJBInvocationContextInterceptor"/>
          <advice name="aroundInvoke" aspect="InjectInterceptorsFactory"/>
       </stack>
 
       <bind pointcut="execution(public * *->*(..))">
         <interceptor-ref name="org.jboss.ejb3.interceptor.EJB3TCCLInterceptor"/>
          <interceptor-ref name="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
+         <interceptor-ref name="CurrentInvocationContextInterceptor"/>
          <interceptor-ref name="org.jboss.ejb3.BlockContainerShutdownInterceptor"/>
       </bind>
 
+      <stack name="InjectionCallbackStack">
+         <interceptor-ref name="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
+         <interceptor-ref name="CurrentInvocationContextInterceptor"/>
+      </stack>
+      
       <stack name="LifecycleCallbackStack">
          <interceptor-ref name="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
          <advice name="setup" aspect="InvocationContextInterceptor"/>
-         <advice name="lifecycleInvocation" aspect="EJBInvocationContextInterceptor"/>
+         <interceptor-ref name="CurrentInvocationContextInterceptor"/>
       </stack>
    </domain>
 
@@ -237,6 +242,7 @@
          <interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
          <interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
       </bind>
+      <!-- EJBTHREE-2020: session synchronization callbacks must be called within a context -->
       <bind pointcut="execution(public * $instanceof{javax.ejb.SessionSynchronization}->*(..))">
          <interceptor-ref name="org.jboss.ejb3.stateful.SessionSynchronizationInterceptor"/>
       </bind>

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1358/MockBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1358/MockBeanContext.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree1358/MockBeanContext.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -24,6 +24,8 @@
 import org.jboss.ejb3.BaseContext;
 import org.jboss.ejb3.context.spi.EJBContext;
 import org.jboss.ejb3.context.spi.InvocationContext;
+import org.jboss.ejb3.context.spi.SessionInvocationContext;
+import org.jboss.injection.Injector;
 
 /**
  * @author <a href="mailto:cdewolf at redhat.com">Carlo de Wolf</a>
@@ -36,12 +38,12 @@
       super(container);
    }
    
-   public InvocationContext createLifecycleInvocation(javax.interceptor.InvocationContext delegate)
+   public InvocationContext createInjectionInvocation(Iterable<Injector> injectors)
    {
       throw new RuntimeException("NYI");
    }
 
-   public InvocationContext createMethodInvocation(javax.interceptor.InvocationContext delegate)
+   public SessionInvocationContext createLifecycleInvocation()
    {
       throw new RuntimeException("NYI");
    }

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextBean.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextBean.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextBean.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -26,11 +26,13 @@
 
 import javax.annotation.Resource;
 import javax.ejb.Stateless;
+import javax.interceptor.Interceptors;
 
 /**
  * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
  */
 @Stateless
+ at Interceptors(NewContextInterceptor.class)
 public class NewContextBean implements NewContextLocal
 {
    // the spi one

Added: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextInterceptor.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextInterceptor.java	                        (rev 0)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextInterceptor.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2010, 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.core.test.ejbthree2020;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.InvocationContext;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class NewContextInterceptor
+{
+   @Resource
+   private SessionContext sessionCtx;
+
+   @AroundInvoke
+   public Object aroundInvoke(InvocationContext ctx) throws Exception
+   {
+      if(sessionCtx.getInvokedBusinessInterface() != NewContextLocal.class)
+         throw new IllegalStateException("Expected " + NewContextLocal.class + " as invoked business interface");
+      return ctx.proceed();
+   }
+}


Property changes on: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/core/test/ejbthree2020/NewContextInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/cachepassivation/unit/CachePassivationUnitTestCase.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -21,16 +21,16 @@
  */
 package org.jboss.ejb3.test.cachepassivation.unit;
 
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Map;
-
-import javax.naming.InitialContext;
-
 import junit.framework.TestCase;
-
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.Domain;
+import org.jboss.aop.advice.AdviceFactory;
+import org.jboss.aop.advice.AdviceStack;
+import org.jboss.aop.advice.AspectDefinition;
+import org.jboss.aop.advice.GenericAspectFactory;
+import org.jboss.aop.advice.InterceptorFactory;
+import org.jboss.aop.advice.Scope;
+import org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor;
 import org.jboss.cache.transaction.DummyTransactionManager;
 import org.jboss.ejb3.Ejb3Deployment;
 import org.jboss.ejb3.Ejb3Registry;
@@ -38,6 +38,8 @@
 import org.jboss.ejb3.cache.persistence.PersistenceManagerFactoryRegistry;
 import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.context.naming.EJBContextBinder;
+import org.jboss.ejb3.core.context.CurrentInvocationContextInterceptor;
 import org.jboss.ejb3.core.test.common.MockEjb3Deployment;
 import org.jboss.ejb3.stateful.StatefulBeanContext;
 import org.jboss.ejb3.test.cachepassivation.MockBean;
@@ -48,6 +50,13 @@
 import org.jboss.naming.JavaCompInitializer;
 import org.jnp.server.SingletonNamingServer;
 
+import javax.naming.InitialContext;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
 /**
  * Comment
  *
@@ -67,6 +76,8 @@
       JavaCompInitializer initializer = new JavaCompInitializer();
       initializer.setInitialContextProperties(ctxProperties);
       initializer.start();
+
+      new EJBContextBinder().start();
       
       DummyTransactionManager tm = new DummyTransactionManager();
       InitialContext ic = new InitialContext(ctxProperties);
@@ -80,6 +91,18 @@
       String beanClassName = beanClass.getName();
       String ejbName = beanClass.getSimpleName();
       Domain domain = new Domain(new AspectManager(), "Test", false);
+
+      GenericAspectFactory aspectFactory = new GenericAspectFactory(CurrentInvocationInterceptor.class.getName(), null);
+      AspectDefinition def = new AspectDefinition("CurrentInvocationInterceptor", Scope.PER_VM, aspectFactory);
+      domain.addAspectDefinition(def);
+      AdviceFactory factory = new AdviceFactory(def, "invoke");
+      GenericAspectFactory aspectFactory2 = new GenericAspectFactory(CurrentInvocationContextInterceptor.class.getName(), null);
+      AspectDefinition def2 = new AspectDefinition("CurrentInvocationContextInterceptor", Scope.PER_VM, aspectFactory2);
+      domain.addAspectDefinition(def2);
+      AdviceFactory factory2 = new AdviceFactory(def2, "invoke");
+      AdviceStack stack = new AdviceStack("InjectionCallbackStack", new ArrayList<InterceptorFactory>(Arrays.asList(factory, factory2)));
+      domain.addAdviceStack(stack);
+      
       Map<String, Class<? extends PersistenceManagerFactory>> factories = new HashMap<String, Class<? extends PersistenceManagerFactory>>();
       factories.put("MyStatefulSessionFilePersistenceManager", MyStatefulSessionFilePersistenceManagerFactory.class);
       PersistenceManagerFactoryRegistry persistenceManagerFactoryRegistry = new PersistenceManagerFactoryRegistry();

Modified: projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/threadlocal/MockBeanContext.java
===================================================================
--- projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/threadlocal/MockBeanContext.java	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/test/java/org/jboss/ejb3/test/threadlocal/MockBeanContext.java	2010-03-16 19:03:31 UTC (rev 102482)
@@ -27,6 +27,7 @@
 import org.jboss.ejb3.context.spi.EJBContext;
 import org.jboss.ejb3.context.spi.InvocationContext;
 import org.jboss.ejb3.interceptor.InterceptorInfo;
+import org.jboss.injection.Injector;
 import org.jboss.logging.Logger;
 
 /**
@@ -48,12 +49,12 @@
       this.instance = instance;
    }
 
-   public InvocationContext createLifecycleInvocation(javax.interceptor.InvocationContext delegate)
+   public InvocationContext createInjectionInvocation(Iterable<Injector> injectors)
    {
       throw new RuntimeException("NYI");
    }
 
-   public InvocationContext createMethodInvocation(javax.interceptor.InvocationContext delegate)
+   public InvocationContext createLifecycleInvocation()
    {
       throw new RuntimeException("NYI");
    }

Modified: projects/ejb3/trunk/core/src/test/resources/container-beans.xml
===================================================================
--- projects/ejb3/trunk/core/src/test/resources/container-beans.xml	2010-03-16 18:47:49 UTC (rev 102481)
+++ projects/ejb3/trunk/core/src/test/resources/container-beans.xml	2010-03-16 19:03:31 UTC (rev 102482)
@@ -10,4 +10,6 @@
    </bean>
    
    <bean name="JNDIKernelRegistryPlugin" class="org.jboss.ejb3.kernel.JNDIKernelRegistryPlugin"/>
+
+   <bean name="EJBContextBinder" class="org.jboss.ejb3.context.naming.EJBContextBinder"/>
 </deployment>




More information about the jboss-cvs-commits mailing list