[jboss-cvs] JBossAS SVN: r63118 - in branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3: entity and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu May 17 14:06:04 EDT 2007


Author: bdecoste
Date: 2007-05-17 14:06:04 -0400 (Thu, 17 May 2007)
New Revision: 63118

Modified:
   branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/BaseContext.java
   branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
   branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
   branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/entity/TreeCacheProviderHook.java
   branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
   branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
   branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
Log:
[EJBTHREE-905] fixed SessionContext.getEJBObject() and getEJBLocalObject()

Modified: branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/BaseContext.java
===================================================================
--- branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/BaseContext.java	2007-05-17 17:08:53 UTC (rev 63117)
+++ branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/BaseContext.java	2007-05-17 18:06:04 UTC (rev 63118)
@@ -54,6 +54,11 @@
    public BaseContext()
    {
    }
+   
+   public Object getId()
+   {
+      return null;
+   }
 
    public Object getInstance()
    {

Modified: branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java
===================================================================
--- branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2007-05-17 17:08:53 UTC (rev 63117)
+++ branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/BaseSessionContext.java	2007-05-17 18:06:04 UTC (rev 63118)
@@ -300,9 +300,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);
       }
@@ -312,9 +314,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/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/SessionContainer.java
===================================================================
--- branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2007-05-17 17:08:53 UTC (rev 63117)
+++ branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/SessionContainer.java	2007-05-17 18:06:04 UTC (rev 63118)
@@ -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/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/entity/TreeCacheProviderHook.java
===================================================================
--- branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/entity/TreeCacheProviderHook.java	2007-05-17 17:08:53 UTC (rev 63117)
+++ branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/entity/TreeCacheProviderHook.java	2007-05-17 18:06:04 UTC (rev 63118)
@@ -28,6 +28,7 @@
 import org.hibernate.cache.Cache;
 import org.hibernate.cache.CacheException;
 import org.hibernate.cache.CacheProvider;
+import org.jboss.cache.TreeCache;
 import org.jboss.cache.TreeCacheMBean;
 import org.jboss.ejb3.tx.TxUtil;
 import org.jboss.logging.Logger;
@@ -47,7 +48,9 @@
  * @author Gavin King
  * @author Brian Stansberry
  */
-public class TreeCacheProviderHook implements CacheProvider
+public class TreeCacheProviderHook 
+   extends org.hibernate.cache.TreeCacheProvider
+   implements CacheProvider
 {
    /**
     * Name of the Hibernate configuration property used to provide
@@ -144,4 +147,9 @@
       return optimistic;
    }
 
+   public TreeCache getUnderlyingCache()
+   {
+      return cache;
+   }
+
 }

Modified: branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java
===================================================================
--- branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2007-05-17 17:08:53 UTC (rev 63117)
+++ branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/service/ServiceContainer.java	2007-05-17 18:06:04 UTC (rev 63118)
@@ -386,7 +386,22 @@
       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/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java
===================================================================
--- branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2007-05-17 17:08:53 UTC (rev 63117)
+++ branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulContainer.java	2007-05-17 18:06:04 UTC (rev 63118)
@@ -604,7 +604,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
    {

Modified: branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2007-05-17 17:08:53 UTC (rev 63117)
+++ branches/EJB3_RC9_Patch_1_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessContainer.java	2007-05-17 18:06:04 UTC (rev 63118)
@@ -345,7 +345,36 @@
          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();




More information about the jboss-cvs-commits mailing list