[jboss-cvs] JBossAS SVN: r67787 - in branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3: stateless and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Dec 3 12:50:40 EST 2007


Author: bdecoste
Date: 2007-12-03 12:50:40 -0500 (Mon, 03 Dec 2007)
New Revision: 67787

Modified:
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
   branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
Log:
[JBPAPP-478] merged fix for [EJBTHREE-786]

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java	2007-12-03 17:43:04 UTC (rev 67786)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulLocalProxyFactory.java	2007-12-03 17:50:40 UTC (rev 67787)
@@ -26,13 +26,16 @@
 import java.io.ObjectOutput;
 import java.lang.reflect.InvocationTargetException;
 import java.rmi.dgc.VMID;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
-import javax.ejb.EJBException;
+import javax.ejb.EJBLocalObject;
 import javax.ejb.LocalHome;
 import javax.naming.NamingException;
+
 import org.jboss.annotation.ejb.LocalBinding;
 import org.jboss.aop.Advisor;
-import org.jboss.ejb3.Container;
 import org.jboss.ejb3.EJBContainer;
 import org.jboss.ejb3.Ejb3Registry;
 import org.jboss.ejb3.JBossProxy;
@@ -53,32 +56,32 @@
    
    private VMID vmid = Ejb3Registry.getVMID();
 
-   protected Class[] getInterfaces()
-   {
-      Class[] interfaces;
-      
+   protected Class<?>[] getInterfaces()
+   {      
       StatefulContainer statefulContainer = (StatefulContainer) getContainer();
       LocalHome localHome = (LocalHome) statefulContainer.resolveAnnotation(LocalHome.class);
-      
+
       boolean bindTogether = false;
-      
+
       if (localHome != null && bindHomeAndBusinessTogether(statefulContainer))
          bindTogether = true;
-      
-      Class[] localInterfaces = ProxyFactoryHelper.getLocalInterfaces(getContainer());
+
+      // Obtain all local interfaces      
+      List<Class<?>> localInterfaces = new ArrayList<Class<?>>();
+      localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalInterfaces(statefulContainer)));
+
+      // Add JBossProxy
+      localInterfaces.add(JBossProxy.class);
+
+      // If binding along w/ home, add home
       if (bindTogether)
-         interfaces = new Class[localInterfaces.length + 3];
-      else
-         interfaces = new Class[localInterfaces.length + 2];
-      
-      System.arraycopy(localInterfaces, 0, interfaces, 0, localInterfaces.length);
-      interfaces[localInterfaces.length] = JBossProxy.class;
-      interfaces[localInterfaces.length + 1] = javax.ejb.EJBLocalObject.class;
-      
-      if (bindTogether)
-         interfaces[localInterfaces.length + 2] = localHome.value();
-      
-      return interfaces;
+      {
+         localInterfaces.add(localHome.value());
+      }
+
+      // Return
+      return localInterfaces.toArray(new Class<?>[]
+      {});
    }
    
    protected boolean bindHomeAndBusinessTogether(StatefulContainer container)

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2007-12-03 17:43:04 UTC (rev 67786)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2007-12-03 17:50:40 UTC (rev 67787)
@@ -23,9 +23,14 @@
 
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 
+import javax.ejb.EJBObject;
+import javax.ejb.RemoteHome;
 import javax.naming.NamingException;
-import javax.ejb.RemoteHome;
+
 import org.jboss.annotation.ejb.RemoteBinding;
 import org.jboss.aop.Advisor;
 import org.jboss.aop.AspectManager;
@@ -65,31 +70,31 @@
       this.binding = binding;
    }
 
-   protected Class[] getInterfaces()
-   {
-      Class[] interfaces;
-      
+   protected Class<?>[] getInterfaces()
+   {     
       StatefulContainer statefulContainer = (StatefulContainer) getContainer();
       RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
-      
+
       boolean bindTogether = false;
-      
+
       if (remoteHome != null && bindHomeAndBusinessTogether(statefulContainer))
          bindTogether = true;
+
+      // Obtain all remote interfaces
+      List<Class<?>> remoteInterfaces = new ArrayList<Class<?>>();
+      remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteInterfaces(statefulContainer)));
+
+      // Add JBossProxy
+      remoteInterfaces.add(JBossProxy.class);
       
-      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(getContainer());
+      // If binding along w/ home, add home
       if (bindTogether)
-         interfaces = new Class[remoteInterfaces.length + 3];
-      else
-         interfaces = new Class[remoteInterfaces.length + 2];
+      {
+         remoteInterfaces.add(remoteHome.value());
+      }
 
-      System.arraycopy(remoteInterfaces, 0, interfaces, 0, remoteInterfaces.length);
-      interfaces[remoteInterfaces.length] = JBossProxy.class;
-      interfaces[remoteInterfaces.length + 1] = javax.ejb.EJBObject.class;
-      if (bindTogether)
-         interfaces[remoteInterfaces.length + 2] = remoteHome.value();
-         
-      return interfaces;
+      // Return
+      return remoteInterfaces.toArray(new Class<?>[]{});
    }
    
    protected boolean bindHomeAndBusinessTogether(StatefulContainer container)
@@ -182,7 +187,6 @@
    {
       try
       {
-         Object containerId = getContainer().getObjectName().getCanonicalName();
          String stackName = "StatefulSessionClientInterceptors";
          if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
          {
@@ -229,7 +233,6 @@
    {
       try
       {
-         Object containerId = getContainer().getObjectName().getCanonicalName();
          String stackName = "StatefulSessionClientInterceptors";
          if (binding.interceptorStack() != null && !binding.interceptorStack().equals(""))
          {

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java	2007-12-03 17:43:04 UTC (rev 67786)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessLocalProxyFactory.java	2007-12-03 17:50:40 UTC (rev 67787)
@@ -21,6 +21,10 @@
  */
 package org.jboss.ejb3.stateless;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 import javax.ejb.LocalHome;
 
 import org.jboss.annotation.ejb.LocalBinding;
@@ -43,32 +47,41 @@
 {
    private static final Logger log = Logger.getLogger(StatelessLocalProxyFactory.class);
 
-   protected Class[] getInterfaces()
+   protected Class<?>[] getInterfaces()
    {
-      Class[] interfaces;
-      
-      EJBContainer statelessContainer = (EJBContainer) getContainer();
-      LocalHome localHome = (LocalHome) statelessContainer.resolveAnnotation(LocalHome.class);
-      
+      EJBContainer statelessContainer = (EJBContainer)getContainer();
+      LocalHome localHome = (LocalHome)statelessContainer.resolveAnnotation(LocalHome.class);
+
       boolean bindTogether = false;
       
       if (localHome != null && bindHomeAndBusinessTogether(statelessContainer))
          bindTogether = true;
-      
-      Class[] localInterfaces = ProxyFactoryHelper.getLocalInterfaces(getContainer());
-      
-      if (bindTogether)
-         interfaces = new Class[localInterfaces.length + 3];
+
+      // Obtain all local interfaces
+      List<Class<?>> localInterfaces = new ArrayList<Class<?>>();
+      localInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getLocalInterfaces(statelessContainer)));
+
+      // Ensure remote interfaces defined
+      if (localInterfaces.size() > 0)
+      {
+         // Add JBossProxy
+         localInterfaces.add(JBossProxy.class);
+
+         // If binding along w/ home, add home
+         if (bindTogether)
+         {
+            localInterfaces.add(localHome.value());
+         }
+      }
       else
-         interfaces = new Class[localInterfaces.length + 2];
+      {
+         // No remote interfaces defined, log warning
+         log.warn("[EJBTHREE-933] NPE when deploying web service beans");
+      }
 
-      System.arraycopy(localInterfaces, 0, interfaces, 0, localInterfaces.length);
-      interfaces[localInterfaces.length] = JBossProxy.class;
-      interfaces[localInterfaces.length + 1] = javax.ejb.EJBLocalObject.class;
-      if (bindTogether)
-         interfaces[localInterfaces.length + 2] = localHome.value();
-
-      return interfaces;
+      // Return
+      return localInterfaces.toArray(new Class<?>[]
+      {});
    }
    
    protected boolean bindHomeAndBusinessTogether(EJBContainer container)
@@ -87,11 +100,14 @@
       super.start();
       EJBContainer statelessContainer = (EJBContainer) getContainer();
       LocalHome localHome = (LocalHome) statelessContainer.resolveAnnotation(LocalHome.class);
+    
       if (localHome != null && !bindHomeAndBusinessTogether(statelessContainer))
       {
+         StatelessLocalProxy proxy = new StatelessLocalProxy(getContainer());
+         
          Class[] interfaces = {localHome.value()};
          Object homeProxy = java.lang.reflect.Proxy.newProxyInstance(getContainer().getBeanClass().getClassLoader(),
-                                                                     interfaces, new StatelessLocalProxy(getContainer()));
+                                                                     interfaces, proxy);
          Util.rebind(getContainer().getInitialContext(), ProxyFactoryHelper.getLocalHomeJndiName(getContainer()), homeProxy);
       }
    }

Modified: branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java	2007-12-03 17:43:04 UTC (rev 67786)
+++ branches/JBPAPP_4_2_0_GA_CP/ejb3/src/main/org/jboss/ejb3/stateless/StatelessRemoteProxyFactory.java	2007-12-03 17:50:40 UTC (rev 67787)
@@ -21,8 +21,14 @@
  */
 package org.jboss.ejb3.stateless;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.ejb.EJBObject;
 import javax.ejb.RemoteHome;
 import javax.naming.NamingException;
+
 import org.jboss.annotation.ejb.RemoteBinding;
 import org.jboss.aop.Advisor;
 import org.jboss.aop.AspectManager;
@@ -32,8 +38,8 @@
 import org.jboss.ejb3.ProxyFactoryHelper;
 import org.jboss.ejb3.remoting.RemoteProxyFactory;
 import org.jboss.logging.Logger;
+import org.jboss.naming.Util;
 import org.jboss.remoting.InvokerLocator;
-import org.jboss.naming.Util;
 
 /**
  * Comment
@@ -55,34 +61,41 @@
       this.binding = binding;
    }
 
-   protected Class[] getInterfaces()
+   protected Class<?>[] getInterfaces()
    {
-      Class[] interfaces;
-      
       StatelessContainer statelessContainer = (StatelessContainer) getContainer();
       RemoteHome remoteHome = (RemoteHome) statelessContainer.resolveAnnotation(RemoteHome.class);
-      
+
       boolean bindTogether = false;
-      
+
       if (remoteHome != null && bindHomeAndBusinessTogether(statelessContainer))
          bindTogether = true;
-      
-      Class[] remoteInterfaces = ProxyFactoryHelper.getRemoteInterfaces(getContainer());
-      
-      if (bindTogether)
-         interfaces = new Class[remoteInterfaces.length + 3];
+
+      // Obtain all remote interfaces
+      List<Class<?>> remoteInterfaces = new ArrayList<Class<?>>();
+      remoteInterfaces.addAll(Arrays.asList(ProxyFactoryHelper.getRemoteInterfaces(statelessContainer)));
+
+      // Ensure remote interfaces defined
+      if (remoteInterfaces.size() > 0)
+      {
+         // Add JBossProxy
+         remoteInterfaces.add(JBossProxy.class);
+
+         // If binding along w/ home, add home
+         if (bindTogether)
+         {
+            remoteInterfaces.add(remoteHome.value());
+         }
+      }
       else
-         interfaces = new Class[remoteInterfaces.length + 2];
-      
-      System.arraycopy(remoteInterfaces, 0, interfaces, 0,
-            remoteInterfaces.length);
-      interfaces[remoteInterfaces.length] = JBossProxy.class;
-      interfaces[remoteInterfaces.length + 1] = javax.ejb.EJBObject.class;
-      
-      if (bindTogether)
-         interfaces[remoteInterfaces.length + 2] = remoteHome.value();
+      {
+         // No remote interfaces defined, log warning
+         log.warn("[EJBTHREE-933] NPE when deploying web service beans");
+      }
 
-      return interfaces;
+      // Return
+      return remoteInterfaces.toArray(new Class<?>[]
+      {});
    }
    
    protected boolean bindHomeAndBusinessTogether(EJBContainer container)
@@ -157,8 +170,6 @@
    public Object createHomeProxy(Class homeInterface)
    {
       try {
-         Object containerId = getContainer().getObjectName().getCanonicalName();
-         ;
          String stackName = "StatelessSessionClientInterceptors";
          if (binding.interceptorStack() != null
                && !binding.interceptorStack().equals(""))
@@ -183,8 +194,6 @@
    {
       // try
       {
-         Object containerId = getContainer().getObjectName().getCanonicalName();
-         ;
          String stackName = "StatelessSessionClientInterceptors";
          if (binding.interceptorStack() != null
                && !binding.interceptorStack().equals(""))




More information about the jboss-cvs-commits mailing list