[jboss-cvs] JBossAS SVN: r61173 - in branches/Branch_4_2/ejb3/src: main/org/jboss/ejb3/service and 5 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Mar 6 22:32:38 EST 2007


Author: bdecoste
Date: 2007-03-06 22:32:38 -0500 (Tue, 06 Mar 2007)
New Revision: 61173

Added:
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulLocal.java
Modified:
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/BaseContext.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/session/BaseSessionRemoteProxy.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
   branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateful.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulRemote.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateless.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessBean.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessLocal.java
   branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java
Log:
[EJBTHREE-905] corrected SessionContext.getEJBObject() and SessionContext.getEJBLocalObject(). 

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/BaseContext.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/BaseContext.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/BaseContext.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -54,6 +54,11 @@
    public BaseContext()
    {
    }
+   
+   public Object getId()
+   {
+      return null;
+   }
 
    public Object getInstance()
    {

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -319,9 +319,11 @@
    {
       try
       {
-         return (EJBLocalObject)container.getInitialContext().lookup(ProxyFactoryHelper.getLocalJndiName(container, false));
+         Object id = baseContext.getId();
+         EJBLocalObject proxy =  (EJBLocalObject)((SessionContainer)container).createLocalProxy(id);
+         return proxy;
       }
-      catch (NamingException e)
+      catch (Exception e)
       {
          throw new IllegalStateException(e);
       }
@@ -331,9 +333,11 @@
    {
       try
       {
-         return (EJBObject)container.getInitialContext().lookup(ProxyFactoryHelper.getRemoteJndiName(container, false));
+         Object id = baseContext.getId();
+         EJBObject proxy =  (EJBObject)((SessionContainer)container).createRemoteProxy(id);
+         return proxy;
       }
-      catch (NamingException e)
+      catch (Exception e)
       {
          throw new IllegalStateException(e);
       }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -413,7 +413,14 @@
       Advisor advisor = (Advisor) container;
       RemoteBinding binding = (RemoteBinding) advisor
               .resolveAnnotation(RemoteBinding.class);
-
+      
+      if (binding == null)
+      {
+         RemoteBindings bindings = (RemoteBindings) advisor.resolveAnnotation(RemoteBindings.class);
+         if (bindings != null)
+            binding = bindings.value()[0];
+      }
+      
       return getRemoteJndiName(container, binding);
    }
 

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -69,6 +69,10 @@
       public boolean isLocalInterface;
       public Method method;
    }
+   
+   public abstract Object createLocalProxy(Object id) throws Exception;
+   
+   public abstract Object createRemoteProxy(Object id) throws Exception;
 
    protected ThreadLocalStack<InvokedMethod> invokedMethod = new ThreadLocalStack<InvokedMethod>();
 

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/StrictMaxPool.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -44,6 +44,7 @@
     * instance will block until an instance is freed.
     */
    private FIFOSemaphore strictMaxSize;
+   private int inUse = 0;
    /**
     * The time in milliseconds to wait for the strictMaxSize semaphore.
     */
@@ -85,7 +86,7 @@
    
    public int getAvailableCount()
    {
-	   return maxSize - pool.size();
+	   return maxSize - inUse;
    }
    
    public int getMaxSize()
@@ -129,12 +130,16 @@
       {
          if (!pool.isEmpty())
          {
-            return (BeanContext) pool.removeFirst();
+            BeanContext bean = (BeanContext) pool.removeFirst();
+            ++inUse;
+            return bean;
          }
       }
 
       // Pool is empty, create an instance
+      ++inUse;
       return create();
+      
    }
 
    public BeanContext get(Class[] initTypes, Object[] initValues)
@@ -142,7 +147,7 @@
       boolean trace = log.isTraceEnabled();
       if (trace)
          log.trace("Get instance " + this + "#" + pool.size() + "#" + container.getBeanClass());
-
+  
       // Block until an instance is available
       try
       {
@@ -161,11 +166,14 @@
       {
          if (!pool.isEmpty())
          {
-            return (BeanContext) pool.removeFirst();
+            BeanContext bean = (BeanContext) pool.removeFirst();
+            ++inUse;
+            return bean;
          }
       }
 
       // Pool is empty, create an instance
+      ++inUse;
       return create(initTypes, initValues);
    }
 
@@ -205,10 +213,12 @@
          if (removeIt) remove(ctx);
          // If we block when maxSize instances are in use, invoke release on strictMaxSize
          strictMaxSize.release();
+         --inUse;
       }
       catch (Exception ignored)
       {
       }
+      
    }
 
    public void discard(BeanContext ctx)
@@ -222,6 +232,7 @@
 
       // If we block when maxSize instances are in use, invoke release on strictMaxSize
       strictMaxSize.release();
+      --inUse;
 
       // Throw away, unsetContext()
       super.discard(ctx);
@@ -251,6 +262,8 @@
          discard(bc);
       }
       pool.clear();
+      inUse = 0;
+      
    }
 
    // Inner classes -------------------------------------------------

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -467,8 +467,24 @@
    {
       return delegate.getMBeanInfo();
    }
+   
+   public Object createLocalProxy(Object id) throws Exception
+   {
+      ServiceLocalProxyFactory factory = new ServiceLocalProxyFactory();
+      factory.setContainer(this);
 
+      return factory.createProxy(id);
+   }
+   
+   public Object createRemoteProxy(Object id) throws Exception
+   {
+      ServiceRemoteProxyFactory factory = new ServiceRemoteProxyFactory();
+      factory.setContainer(this);
 
+      return factory.createProxy(id);
+   }
+
+
    private void registerManagementInterface()
    {
       try

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/session/BaseSessionRemoteProxy.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/session/BaseSessionRemoteProxy.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/session/BaseSessionRemoteProxy.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -64,4 +64,14 @@
    {
       this.ejbMetaData = ejbMetaData;
    }
+   
+   public Object getId()
+   {
+      return id;
+   }
+   
+   public void setId(Object id)
+   {
+      this.id = id;
+   }
 }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulBeanContext.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -25,6 +25,7 @@
 import org.jboss.ejb3.BaseContext;
 import org.jboss.ejb3.Container;
 import org.jboss.ejb3.Ejb3Registry;
+import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.ThreadLocalStack;
 import org.jboss.ejb3.cache.StatefulCache;
 import org.jboss.ejb3.interceptor.InterceptorInfo;
@@ -32,6 +33,8 @@
 import org.jboss.serial.io.MarshalledObject;
 import org.jboss.tm.TxUtils;
 
+import javax.ejb.EJBLocalObject;
+import javax.naming.NamingException;
 import javax.persistence.EntityManager;
 import javax.transaction.Synchronization;
 import javax.transaction.Transaction;
@@ -93,7 +96,7 @@
 
    public StatefulBeanContext()
    {
-
+    
    }
 
    public List<StatefulBeanContext> getContains()
@@ -871,4 +874,17 @@
    {
       return this.getId();
    }
+   
+   public EJBLocalObject getEJBLocalObject() throws IllegalStateException
+   { 
+      try
+      {
+         Object proxy = ((StatefulContainer)container).createLocalProxy(getId());
+         return (EJBLocalObject)proxy;
+      }
+      catch (Exception e)
+      {
+         throw new IllegalStateException(e);
+      }
+   }
 }

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -604,7 +604,6 @@
          }
 
          LocalBinding binding = (LocalBinding) resolveAnnotation(LocalBinding.class);
-         ;
 
          StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory();
          factory.setContainer(this);
@@ -628,7 +627,36 @@
          return null;
       }
    }
+   
+   public Object createLocalProxy(Object id) throws Exception
+   {
+      StatefulLocalProxyFactory factory = new StatefulLocalProxyFactory();
+      factory.setContainer(this);
+      factory.init();
 
+      return factory.createProxy(id);
+   }
+   
+   public Object createRemoteProxy(Object id) throws Exception
+   {
+      RemoteBinding binding = null;
+      RemoteBindings bindings = (RemoteBindings) resolveAnnotation(RemoteBindings.class);
+      if (bindings != null)
+         binding = bindings.value()[0];
+      else
+         binding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+      
+      StatefulRemoteProxyFactory factory = new StatefulRemoteProxyFactory();
+      factory.setContainer(this);
+      factory.setRemoteBinding(binding);
+      factory.init();
+
+      if (id != null)
+         return factory.createProxy(id);
+      else
+         return factory.createProxy();
+   }
+
    protected InvocationResponse invokeHomeMethod(MethodInfo info,
                                                  StatefulRemoteInvocation statefulInvocation) throws Throwable
    {
@@ -645,28 +673,12 @@
             initParameterValues = statefulInvocation.getArguments();
          }
 
-         RemoteBinding binding = null;
-         RemoteBindings bindings = (RemoteBindings) resolveAnnotation(RemoteBindings.class);
-         if (bindings != null)
-            binding = bindings.value()[0];
-         else
-            binding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
-
          StatefulContainerInvocation newStatefulInvocation = buildNewInvocation(
                  info, statefulInvocation, initParameterTypes,
                  initParameterValues);
 
-         StatefulRemoteProxyFactory factory = new StatefulRemoteProxyFactory();
-         factory.setContainer(this);
-         factory.setRemoteBinding(binding);
-         factory.init();
+         Object proxy = createRemoteProxy(newStatefulInvocation.getId());
 
-         Object proxy = null;
-         if (newStatefulInvocation.getId() != null)
-            proxy = factory.createProxy(newStatefulInvocation.getId());
-         else
-            proxy = factory.createProxy();
-
          InvocationResponse response = marshallResponse(statefulInvocation, proxy, newStatefulInvocation.getResponseContextInfo());
          if (newStatefulInvocation.getId() != null)
             response.addAttachment(StatefulConstants.NEW_ID,

Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -351,41 +351,49 @@
       Method unadvisedMethod = info.getUnadvisedMethod();
       if (unadvisedMethod.getName().equals("create"))
       {
-         LocalBinding binding = (LocalBinding) resolveAnnotation(LocalBinding.class);
-
-         StatelessLocalProxyFactory factory = new StatelessLocalProxyFactory();
-         factory.setContainer(this);
-         factory.init();
-
-         Object proxy = factory.createProxy();
-
-         return proxy;
+         return createLocalProxy(null);
       }
       else // remove
       {
          return null;
       }
    }
+   
+   public Object createLocalProxy(Object id) throws Exception
+   {
+      StatelessLocalProxyFactory factory = new StatelessLocalProxyFactory();
+      factory.setContainer(this);
+      factory.init();
 
+      Object proxy = factory.createProxy();
+
+      return proxy;
+   }
+   
+   public Object createRemoteProxy(Object id) throws Exception
+   {
+      RemoteBinding binding = null;
+
+      RemoteBindings bindings = (RemoteBindings) resolveAnnotation(RemoteBindings.class);
+      if (bindings != null)
+         binding = bindings.value()[0];
+      else
+         binding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
+
+      StatelessRemoteProxyFactory factory = new StatelessRemoteProxyFactory();
+      factory.setContainer(this);
+      factory.setRemoteBinding(binding);
+      factory.init();
+
+      return factory.createProxy();
+   }
+
    protected Object invokeHomeMethod(MethodInfo info, MethodInvocation invocation) throws Throwable
    {
       Method unadvisedMethod = info.getUnadvisedMethod();
       if (unadvisedMethod.getName().equals("create"))
       {
-         RemoteBinding binding = null;
-
-         RemoteBindings bindings = (RemoteBindings) resolveAnnotation(RemoteBindings.class);
-         if (bindings != null)
-            binding = bindings.value()[0];
-         else
-            binding = (RemoteBinding) resolveAnnotation(RemoteBinding.class);
-
-         StatelessRemoteProxyFactory factory = new StatelessRemoteProxyFactory();
-         factory.setContainer(this);
-         factory.setRemoteBinding(binding);
-         factory.init();
-
-         return factory.createProxy();
+         return createRemoteProxy(null);
       }
       else // remove
       {

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateful.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateful.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateful.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -21,7 +21,8 @@
  */
 package org.jboss.ejb3.test.ejbcontext;
 
-import javax.ejb.Remote;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
 
 
 /**
@@ -30,21 +31,23 @@
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  * @version $Revision$
  */
- at Remote
-public interface Stateful
+public interface Stateful extends EJBObject
 {
-   public void testEjbContext() throws Exception;
+   void testEjbContext() throws Exception;
 
-   public void test();
+   void test();
 
-   public Class testInvokedBusinessInterface() throws Exception;
+   Class testInvokedBusinessInterface() throws Exception;
 
-   public Class testLocalInvokedBusinessInterface() throws Exception;
+   Class testLocalInvokedBusinessInterface() throws Exception;
 
-   public Object getBusinessObject() throws Exception;
+   Object getBusinessObject() throws Exception;
 
-
    String getState();
 
    void setState(String state);
+   
+   EJBLocalObject getEJBLocalObject();
+   
+   EJBObject getEJBObject();
 }

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulBean.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulBean.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -21,15 +21,22 @@
  */
 package org.jboss.ejb3.test.ejbcontext;
 
+import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
 import javax.ejb.EJB;
 import javax.ejb.EJBContext;
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
+import javax.ejb.Local;
 import javax.ejb.Remote;
 import javax.ejb.SessionContext;
 import javax.ejb.Stateful;
 
 import javax.naming.InitialContext;
 
+import javax.ejb.Remote;
+
+import org.jboss.annotation.ejb.LocalBinding;
 import org.jboss.annotation.ejb.RemoteBinding;
 import org.jboss.annotation.ejb.RemoteBindings;
 import org.jboss.logging.Logger;
@@ -41,9 +48,12 @@
  * @version $Revision$
  */
 @Stateful(name="Stateful")
+ at Remote({org.jboss.ejb3.test.ejbcontext.Stateful.class, StatefulRemote.class})
+ at Local(StatefulLocal.class)
+ at LocalBinding(jndiBinding="StatefulLocal")
 @RemoteBindings({@RemoteBinding(jndiBinding = "Stateful"), @RemoteBinding(jndiBinding = "StatefulRemote")})
 public class StatefulBean
-   implements org.jboss.ejb3.test.ejbcontext.Stateful, StatefulRemote
+   implements StatefulRemote
 {
    private static final Logger log = Logger.getLogger(StatefulBean.class);
    
@@ -53,6 +63,8 @@
    @EJB(mappedName="StatefulRemote")
    StatefulRemote statefulRemote = null;
 
+   EJBLocalObject ejbLocalObject;
+   EJBObject ejbObject;
    String state = "";
    
    public void testEjbContext() throws Exception
@@ -66,6 +78,16 @@
    {
       
    }
+   
+   public EJBLocalObject getEJBLocalObject()
+   {
+      return ejbLocalObject;
+   }
+   
+   public EJBObject getEJBObject()
+   {
+      return ejbObject;
+   }
 
    public String getState()
    {
@@ -97,4 +119,11 @@
    {
       return statefulRemote.testInvokedBusinessInterface2();
    }
+   
+   @PostConstruct
+   public void postConstruct()
+   {
+      ejbLocalObject = sessionContext.getEJBLocalObject();
+      ejbObject = sessionContext.getEJBObject();
+   }
 }

Added: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulLocal.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulLocal.java	                        (rev 0)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulLocal.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -0,0 +1,35 @@
+/*
+ * 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.test.ejbcontext;
+
+import javax.ejb.EJBLocalObject;
+
+/**
+ *
+ * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
+ */
+public interface StatefulLocal extends EJBLocalObject
+{
+   String getState();
+   
+   void setState(String state);
+}

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulRemote.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulRemote.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatefulRemote.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -21,17 +21,14 @@
  */
 package org.jboss.ejb3.test.ejbcontext;
 
-import javax.ejb.Remote;
 
-
 /**
  * Comment
  *
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  * @version $Revision$
  */
- at Remote
 public interface StatefulRemote
 {
-   public Class testInvokedBusinessInterface2() throws Exception;
+   Class testInvokedBusinessInterface2() throws Exception;
 }

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateless.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateless.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/Stateless.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -31,15 +31,17 @@
  */
 public interface Stateless
 {
-   public void testEjbContextLookup() throws Exception;
+   void testEjbContextLookup() throws Exception;
    
-   public Class testInvokedBusinessInterface() throws Exception;
+   Class testInvokedBusinessInterface() throws Exception;
    
-   public Object testBusinessObject(Class businessInterface) throws Exception;
+   Object testBusinessObject(Class businessInterface) throws Exception;
    
-   public void testEjbObject() throws Exception;
+   void testEjbObject() throws Exception;
 
-   public void testEjbLocalObject() throws Exception;
+   void testEjbLocalObject() throws Exception;
 
-   public void noop();
+   void noop();
+   
+   void testSessionContext() throws Exception;
 }

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessBean.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessBean.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessBean.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -21,12 +21,18 @@
  */
 package org.jboss.ejb3.test.ejbcontext;
 
+import javax.annotation.PostConstruct;
 import javax.annotation.Resource;
+
+import javax.ejb.EJBLocalObject;
+import javax.ejb.EJBObject;
 import javax.ejb.Local;
 import javax.ejb.Remote;
 import javax.ejb.SessionContext;
 import javax.ejb.Stateless;
 
+import javax.naming.InitialContext;
+
 import org.jboss.annotation.ejb.LocalBinding;
 import org.jboss.annotation.ejb.RemoteBinding;
 import org.jboss.logging.Logger;
@@ -49,6 +55,9 @@
    
    @Resource
    SessionContext sessionContext;
+   
+   StatelessLocal ejbLocalObject;
+   org.jboss.ejb3.test.ejbcontext.Stateless ejbObject;
 
    public void noop()
    {
@@ -82,4 +91,31 @@
       javax.ejb.EJBLocalObject ejbObject = sessionContext.getEJBLocalObject();
       ejbObject.getClass();
    }
+   
+   public void testSessionContext() throws Exception
+   {
+      InitialContext jndiContext = new InitialContext();
+      Stateful stateful = (Stateful)jndiContext.lookup("Stateful");
+      stateful.setState("testSessionContext");
+      
+      EJBLocalObject ejbLocalObject = stateful.getEJBLocalObject();
+      
+      StatefulLocal sameLocalBean = (StatefulLocal)ejbLocalObject;
+      String state = sameLocalBean.getState();
+      if (!state.equals("testSessionContext"))
+         throw new Exception("EJBLocalObject does not match originating bean: " + state + " != " + "testSessionContext");
+      
+      EJBObject ejbObject = stateful.getEJBObject();
+      Stateful sameBean = (Stateful)ejbObject;
+      state = sameBean.getState();
+      if (!state.equals("testSessionContext"))
+         throw new Exception("EJBObject does not match originating bean: " + state + " != " + "testSessionContext");
+   }
+   
+   @PostConstruct
+   public void postConstruct()
+   {
+      ejbLocalObject = (StatelessLocal)sessionContext.getEJBLocalObject();
+      ejbObject = (org.jboss.ejb3.test.ejbcontext.Stateless)sessionContext.getEJBObject();
+   }
 }

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessLocal.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessLocal.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/StatelessLocal.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -21,8 +21,10 @@
  */
 package org.jboss.ejb3.test.ejbcontext;
 
+import javax.ejb.EJBLocalObject;
 
 
+
 /**
  * Comment
  *

Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java	2007-03-07 02:24:23 UTC (rev 61172)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/ejbcontext/unit/EjbContextUnitTestCase.java	2007-03-07 03:32:38 UTC (rev 61173)
@@ -56,6 +56,12 @@
      stateless.testEjbContextLookup();
    }
    
+   public void testSessionContext() throws Exception
+   {
+      Stateless stateless = (Stateless)getInitialContext().lookup("Stateless");
+      stateless.testSessionContext();
+   }
+   
    public void testStatelessInvokedBusinessInterface() throws Exception
    {
       Stateless stateless1 = (Stateless)getInitialContext().lookup("Stateless");




More information about the jboss-cvs-commits mailing list