[jboss-cvs] JBossAS SVN: r99933 - in branches/JBPAPP_5_0: iiop/src/main/org/jboss/iiop/rmi and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 26 07:02:34 EST 2010


Author: wolfc
Date: 2010-01-26 07:02:34 -0500 (Tue, 26 Jan 2010)
New Revision: 99933

Modified:
   branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
   branches/JBPAPP_5_0/iiop/src/main/org/jboss/iiop/rmi/AttributeAnalysis.java
   branches/JBPAPP_5_0/iiop/src/main/org/jboss/iiop/rmi/ContainerAnalysis.java
Log:
JBPAPP-3540: make sure the right interface is checked for operations

Modified: branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java
===================================================================
--- branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2010-01-26 11:22:59 UTC (rev 99932)
+++ branches/JBPAPP_5_0/ejb3/src/main/org/jboss/ejb3/iiop/IORFactory.java	2010-01-26 12:02:34 UTC (rev 99933)
@@ -21,21 +21,10 @@
  */
 package org.jboss.ejb3.iiop;
 
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.net.URL;
-
-import javax.ejb.EJBHome;
-import javax.ejb.EJBObject;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.rmi.PortableRemoteObject;
-
 import org.jboss.classloading.spi.RealClassLoader;
 import org.jboss.ejb3.InitialContextFactory;
 import org.jboss.ejb3.annotation.IIOP;
+import org.jboss.ejb3.common.lang.ClassHelper;
 import org.jboss.ejb3.core.proxy.spi.EJB2RemoteProxyFactory;
 import org.jboss.ejb3.core.proxy.spi.RemoteProxyFactory;
 import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
@@ -57,23 +46,28 @@
 import org.jboss.util.naming.NonSerializableFactory;
 import org.jboss.web.WebClassLoader;
 import org.jboss.web.WebServiceMBean;
-import org.omg.CORBA.Any;
-import org.omg.CORBA.InterfaceDef;
-import org.omg.CORBA.InterfaceDefHelper;
-import org.omg.CORBA.ORB;
-import org.omg.CORBA.Policy;
-import org.omg.CORBA.Repository;
-import org.omg.CosNaming.NameComponent;
-import org.omg.CosNaming.NamingContext;
-import org.omg.CosNaming.NamingContextExt;
-import org.omg.CosNaming.NamingContextExtHelper;
-import org.omg.CosNaming.NamingContextHelper;
+import org.omg.CORBA.*;
+import org.omg.CosNaming.*;
 import org.omg.CosNaming.NamingContextPackage.NotFound;
 import org.omg.PortableServer.Current;
 import org.omg.PortableServer.CurrentHelper;
 import org.omg.PortableServer.POA;
 import org.omg.PortableServer.Servant;
 
+import javax.ejb.EJBHome;
+import javax.ejb.EJBObject;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+import java.io.Serializable;
+import java.lang.Object;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.List;
+
 /**
  * Comment
  *
@@ -208,7 +202,20 @@
    {
       return ProxyFactoryHelper.getDefaultRemoteBusinessJndiName(container);
    }
-   
+
+   /**
+    * A slow method that works around a lot of hacks to return the remote interface.
+    * @return session bean’s remote interface, if the session bean provides an EJB 2.1 remote client view.
+    */
+   protected Class<?> getRemoteInterface()
+   {
+      Class<?> homeInterface = ProxyFactoryHelper.getRemoteHomeInterface(container);
+      assert homeInterface != null : "homeInterface is null";
+      List<Method> createMethods = ClassHelper.getAllMethodsByPrefix(homeInterface, "create");
+      assert createMethods.size() > 0 : "no create methods on " + homeInterface;
+      return createMethods.get(0).getReturnType();
+   }
+
    protected RemoteProxyFactory getRemoteProxyFactory()
    {
       return remoteProxyFactory;
@@ -261,11 +268,8 @@
    
    public void start() throws Exception
    {
-      // TODO: IORFactory only supports 1 remote interface
-      Class remoteInterfaces[] = ProxyFactoryHelper.getRemoteAndBusinessRemoteInterfaces(container);
-      if(remoteInterfaces.length > 1)
-         log.warn("IIOP binding only works on 1 interface, using: " + remoteInterfaces[0].getName());
-      InterfaceAnalysis interfaceAnalysis = InterfaceAnalysis.getInterfaceAnalysis(remoteInterfaces[0]);
+      Class<?> remoteInterface = getRemoteInterface();
+      InterfaceAnalysis interfaceAnalysis = InterfaceAnalysis.getInterfaceAnalysis(remoteInterface);
       this.beanRepositoryIds = interfaceAnalysis.getAllTypeIds();
       
       InterfaceAnalysis homeInterfaceAnalysis = null;
@@ -278,6 +282,8 @@
          this.homeRepositoryIds = homeInterfaceAnalysis.getAllTypeIds();
       }
       // To allow EJB3 Stateless beans to operate we can function without a home interface.
+      // Note that a lot of other constructs both in the deployer and this class prevent a non-homed bean to work,
+      // so basically a bean without an EJB 2.1 remote view does not work.
       
       // Get orb and irPoa references
       try {
@@ -297,7 +303,7 @@
       if(iiop.interfaceRepositorySupported())
       {
          this.iri = new InterfaceRepository(orb, irPoa, getJndiName());
-         iri.mapClass(remoteInterfaces[0]);
+         iri.mapClass(remoteInterface);
          if(homeInterface != null)
             iri.mapClass(homeInterface);
          iri.finishBuild();

Modified: branches/JBPAPP_5_0/iiop/src/main/org/jboss/iiop/rmi/AttributeAnalysis.java
===================================================================
--- branches/JBPAPP_5_0/iiop/src/main/org/jboss/iiop/rmi/AttributeAnalysis.java	2010-01-26 11:22:59 UTC (rev 99932)
+++ branches/JBPAPP_5_0/iiop/src/main/org/jboss/iiop/rmi/AttributeAnalysis.java	2010-01-26 12:02:34 UTC (rev 99933)
@@ -50,7 +50,7 @@
    /**
     *  Create an attribute analysis.
     */
-   private AttributeAnalysis(String javaName, AttributeMode mode,
+   private AttributeAnalysis(Class<?> definingClass, String javaName, AttributeMode mode,
                              Method accessor, Method mutator)
       throws RMIIIOPViolationException
    {
@@ -61,9 +61,13 @@
       this.accessor = accessor;
       this.mutator = mutator;
 
+      assert accessor.getDeclaringClass().isAssignableFrom(definingClass) : definingClass + " must be a sub-class of " + accessor.getDeclaringClass();
+
+      // JBPAPP-3540: the sub-class might be declaring the extension on remote, so we need to check the real interface
+      // instead of the declaring class.
       // Only do operation analysis if the attribute is in a remote interface.
-      if (accessor.getDeclaringClass().isInterface() &&
-          Remote.class.isAssignableFrom(accessor.getDeclaringClass())) {
+      if (definingClass.isInterface() &&
+          Remote.class.isAssignableFrom(definingClass)) {
          accessorAnalysis = new OperationAnalysis(accessor);
          if (mutator != null)
             mutatorAnalysis = new OperationAnalysis(mutator);
@@ -76,19 +80,19 @@
    /**
     *  Create an attribute analysis for a read-only attribute.
     */
-   AttributeAnalysis(String javaName, Method accessor)
+   AttributeAnalysis(Class<?> definingClass, String javaName, Method accessor)
       throws RMIIIOPViolationException
    {
-      this(javaName, AttributeMode.ATTR_READONLY, accessor, null);
+      this(definingClass, javaName, AttributeMode.ATTR_READONLY, accessor, null);
    }
 
    /**
     *  Create an attribute analysis for a read-write attribute.
     */
-   AttributeAnalysis(String javaName, Method accessor, Method mutator)
+   AttributeAnalysis(Class<?> definingClass, String javaName, Method accessor, Method mutator)
       throws RMIIIOPViolationException
    {
-      this(javaName, AttributeMode.ATTR_NORMAL, accessor, mutator);
+      this(definingClass, javaName, AttributeMode.ATTR_NORMAL, accessor, mutator);
    }
 
    // Public --------------------------------------------------------

Modified: branches/JBPAPP_5_0/iiop/src/main/org/jboss/iiop/rmi/ContainerAnalysis.java
===================================================================
--- branches/JBPAPP_5_0/iiop/src/main/org/jboss/iiop/rmi/ContainerAnalysis.java	2010-01-26 11:22:59 UTC (rev 99932)
+++ branches/JBPAPP_5_0/iiop/src/main/org/jboss/iiop/rmi/ContainerAnalysis.java	2010-01-26 12:02:34 UTC (rev 99933)
@@ -602,9 +602,9 @@
 
             logger.debug("Attribute["+i+"] name= " + name);
             if ((m_flags[i]&M_READONLY) != 0)
-               a.add(new AttributeAnalysis(name, methods[i]));
+               a.add(new AttributeAnalysis(cls, name, methods[i]));
             else
-               a.add(new AttributeAnalysis(name, methods[i],
+               a.add(new AttributeAnalysis(cls, name, methods[i],
                                            methods[mutators[i]]));
          }
       }




More information about the jboss-cvs-commits mailing list