[jboss-cvs] JBossAS SVN: r73757 - in projects/ejb3/trunk/proxy: src/main/java/org/jboss/ejb3/proxy and 13 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed May 28 19:03:09 EDT 2008


Author: ALRubinger
Date: 2008-05-28 19:03:08 -0400 (Wed, 28 May 2008)
New Revision: 73757

Added:
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/IsLocalProxyFactoryInterceptor.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/RemotingTargetIds.java
Modified:
   projects/ejb3/trunk/proxy/pom.xml
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
   projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase.java
   projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCaseBase.java
   projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase-beans.xml
   projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionTestCase-beans.xml
   projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionTestCase-beans.xml
Log:
[EJBTHREE-1345] Hooked in Remoting to EJB3 Proxy, still failing due to NotSerializable

Modified: projects/ejb3/trunk/proxy/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy/pom.xml	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/pom.xml	2008-05-28 23:03:08 UTC (rev 73757)
@@ -81,12 +81,12 @@
 
   <dependencyManagement>
     <dependencies>
-      <!-- Because of a bug in m2eclipse the version of reflect must be explicitly defined -->
+      <!-- Because of a bug in m2eclipse the version of reflect must be explicitly defined 
       <dependency>
         <groupId>org.jboss</groupId>
         <artifactId>jboss-reflect</artifactId>
         <version>2.0.0.Beta12</version>
-      </dependency>
+      </dependency> -->
     </dependencies>
   </dependencyManagement>
   
@@ -140,7 +140,39 @@
       <version>0.1.0-SNAPSHOT</version>
       <scope>test</scope>
     </dependency>
-    
+
+     <dependency>
+       <groupId>org.jboss.aspects</groupId>
+       <artifactId>jboss-remoting-aspects</artifactId>
+       <version>1.0.0-SNAPSHOT</version>
+     </dependency>
+     
+     <dependency>
+       <groupId>oswego-concurrent</groupId>
+       <artifactId>concurrent</artifactId>
+       <version>1.3.4-jboss-update1</version>
+       <scope>test</scope>
+     </dependency>   <!--
+     <dependency>
+       <groupId>org.jboss.remoting</groupId>
+       <artifactId>jboss-remoting</artifactId>
+       <version>2.4.0.CR2</version>
+     </dependency> 
+     
+    TODO: who should declare this dependency? 
+    <dependency>
+      <groupId>jboss</groupId>
+      <artifactId>jboss-serialization</artifactId>
+      <version>1.0.3.GA</version>
+      <exclusions>
+        <exclusion>
+          <groupId>jboss</groupId>
+          <artifactId>jboss-logging-log4j</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency> -->
+     
+
   </dependencies>
 
 </project>

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/ProxyFactory.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -21,6 +21,8 @@
  */
 package org.jboss.ejb3.proxy.factory;
 
+import java.io.Serializable;
+
 /**
  * ProxyFactory
  * 
@@ -31,7 +33,7 @@
  * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
  * @version $Revision: $
  */
-public interface ProxyFactory
+public interface ProxyFactory extends Serializable
 {
    // --------------------------------------------------------------------------------||
    // Lifecycle Methods --------------------------------------------------------------||

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionLocalProxyFactory.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -24,7 +24,6 @@
 import java.util.Set;
 
 import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
-import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 
 /**
@@ -41,7 +40,7 @@
    // Class Members ------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
 
-   private static final Logger logger = Logger.getLogger(StatefulSessionLocalProxyFactory.class);
+   private static final long serialVersionUID = 1L;
 
    // --------------------------------------------------------------------------------||
    // Constructor --------------------------------------------------------------------||

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateful/StatefulSessionRemoteProxyFactory.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -40,6 +40,8 @@
    // --------------------------------------------------------------------------------||
    // Class Members ------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
+   
+   private static final long serialVersionUID = 1L;
 
    private static final Logger logger = Logger.getLogger(StatefulSessionRemoteProxyFactory.class);
 

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionLocalProxyFactory.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -41,6 +41,8 @@
    // Class Members ------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
 
+   private static final long serialVersionUID = 1L;
+
    private static final Logger logger = Logger.getLogger(StatelessSessionLocalProxyFactory.class);
 
    // --------------------------------------------------------------------------------||

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/factory/session/stateless/StatelessSessionRemoteProxyFactory.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -40,6 +40,7 @@
    // --------------------------------------------------------------------------------||
    // Class Members ------------------------------------------------------------------||
    // --------------------------------------------------------------------------------||
+   private static final long serialVersionUID = 1L;
 
    private static final Logger logger = Logger.getLogger(StatelessSessionRemoteProxyFactory.class);
 

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/jndiregistrar/JndiSessionRegistrarBase.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -40,6 +40,7 @@
 import org.jboss.logging.Logger;
 import org.jboss.metadata.ejb.jboss.JBossEnterpriseBeanMetaData;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
 import org.jboss.metadata.ejb.spec.BusinessLocalsMetaData;
 import org.jboss.metadata.ejb.spec.BusinessRemotesMetaData;
 import org.jboss.naming.Util;
@@ -150,26 +151,12 @@
     * responsible for creation and registration of any all ProxyFactory
     * implementations required by the EJB
     * 
-    * @param md
+    * @param smd
     * @param cl The CL of the Container
     * @param containerName The name under which the target container is registered
     */
-   public void bindEjb(final JBossEnterpriseBeanMetaData md, final ClassLoader cl, final String containerName)
+   public void bindEjb(final JBossSessionBeanMetaData smd, final ClassLoader cl, final String containerName)
    {
-      // Assert castable
-      assert (md instanceof JBossSessionBeanMetaData) : md + " claims to be a Session Bean but is not of type "
-            + JBossSessionBeanMetaData.class.getName();
-      JBossSessionBeanMetaData smd = null;
-      try
-      {
-         smd = JBossSessionBeanMetaData.class.cast(md);
-      }
-      catch (ClassCastException cce)
-      {
-         throw new RuntimeException(md + " claiming to be Session Bean could not be cast to "
-               + JBossSessionBeanMetaData.class.getName(), cce);
-      }
-
       // Log 
       String ejbName = smd.getEjbName();
       log.debug("Found Session Bean: " + ejbName);
@@ -205,7 +192,7 @@
       if (hasLocalView)
       {
          // Create and register a local proxy factory
-         ProxyFactory factory = this.createLocalProxyFactory(smd, cl);
+         SessionProxyFactory factory = this.createLocalProxyFactory(smd, cl);
          localProxyFactoryKey = this.registerProxyFactory(factory, smd, true);
       }
 
@@ -213,8 +200,8 @@
       String remoteProxyFactoryKey = null;
       if (hasRemoteView)
       {
-         // Create and register a local proxy factory
-         ProxyFactory factory = this.createRemoteProxyFactory(smd, cl);
+         // Create and register a remote proxy factory
+         SessionProxyFactory factory = this.createRemoteProxyFactory(smd, cl);
          remoteProxyFactoryKey = this.registerProxyFactory(factory, smd, false);
       }
 
@@ -249,17 +236,22 @@
          else if (smd.getHome() != null && !smd.getHome().equals(""))
          {
             String homeType = smd.getHome();
-            RefAddr refAddr = new StringRefAddr(
+            RefAddr refAddrHomeInterface = new StringRefAddr(
                   ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_EJB2x_INTERFACE_HOME_REMOTE, homeType);
+            RefAddr refAddrRemoting = this.createRemotingRefAddr(smd);
             Reference homeRef = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + homeType, this
                   .getSessionProxyObjectFactoryType(), null);
-            homeRef.add(refAddr);
+            homeRef.add(refAddrHomeInterface);
+            homeRef.add(refAddrRemoting);
             String homeAddress = smd.determineResolvedJndiName(homeType);
             log.debug("Remote Home View for EJB " + smd.getEjbName() + " to be bound into JNDI at \"" + homeAddress
                   + "\"");
             this.bind(homeRef, homeAddress, remoteProxyFactoryKey, containerName);
          }
 
+         // Add a Reference Address for the Remoting URL
+         refAddrsForDefaultRemote.add(this.createRemotingRefAddr(smd));
+
          /*
           * Bind ObjectFactory for default remote businesses (and home if bound together)
           */
@@ -289,11 +281,13 @@
          // Bind ObjectFactory specific to each Remote Business Interface
          for (String businessRemote : businessRemotes)
          {
-            RefAddr refAddr = new StringRefAddr(
+            RefAddr refAddrBusinessInterface = new StringRefAddr(
                   ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_BUSINESS_INTERFACE_REMOTE, businessRemote);
+            RefAddr refAddrRemoting = this.createRemotingRefAddr(smd);
             Reference ref = new Reference(JndiSessionRegistrarBase.OBJECT_FACTORY_CLASSNAME_PREFIX + businessRemote,
                   this.getSessionProxyObjectFactoryType(), null);
-            ref.add(refAddr);
+            ref.add(refAddrBusinessInterface);
+            ref.add(refAddrRemoting);
             String address = smd.determineResolvedJndiName(businessRemote);
             log.debug("Remote Business View for " + businessRemote + " of EJB " + smd.getEjbName()
                   + " to be bound into JNDI at \"" + address + "\"");
@@ -474,6 +468,29 @@
    }
 
    /**
+    * Creates and returns a new RefAddr to flag the proper
+    * InvokerLocator URL used by remoting for the EJB represented
+    * by the specified metadata 
+    * 
+    * @param smd
+    * @return
+    */
+   protected RefAddr createRemotingRefAddr(JBossSessionBeanMetaData smd)
+   {
+      // Obtain RemoteBinding
+      List<RemoteBindingMetaData> bindings = smd.getRemoteBindings();
+      assert bindings != null && bindings.size() > 0 : "Remote Bindings are required and none are present";
+      RemoteBindingMetaData remoteBinding = smd.getRemoteBindings().get(0);
+
+      // Create RefAddr
+      RefAddr refAddr = new StringRefAddr(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_INVOKER_LOCATOR_URL,
+            remoteBinding.getClientBindUrl());
+
+      // Return
+      return refAddr;
+   }
+
+   /**
     * Returns the name of the unique key under which a Proxy Factory will 
     * be registered.  Will follow form:
     * 

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyFactoryReferenceAddressTypes.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -78,6 +78,13 @@
     * The following are ReferenceAddress types denoting the Name of the EJB Container associated 
     * with a Reference
     */
+   
    String REF_ADDR_TYPE_EJBCONTAINER_NAME = "EJB Container Name";
+   
+   /*
+    * The following are Reference Address Types used in Remoting
+    */
+   
+   String REF_ADDR_TYPE_INVOKER_LOCATOR_URL = "Remoting Host URL";
 
 }

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/ProxyObjectFactory.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -22,6 +22,7 @@
 package org.jboss.ejb3.proxy.objectfactory;
 
 import java.io.Serializable;
+import java.lang.reflect.Proxy;
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashMap;
@@ -35,10 +36,17 @@
 import javax.naming.Reference;
 import javax.naming.spi.ObjectFactory;
 
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.aspects.remoting.PojiProxy;
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
 import org.jboss.ejb3.common.registrar.spi.NotBoundException;
 import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.remoting.IsLocalProxyFactoryInterceptor;
+import org.jboss.ejb3.proxy.remoting.RemotingTargetIds;
 import org.jboss.logging.Logger;
+import org.jboss.remoting.InvokerLocator;
 
 /**
  * ProxyObjectFactory
@@ -94,20 +102,39 @@
       Map<String, List<String>> refAddrs = this.getReferenceAddresses(ref);
 
       // Obtain the key used for looking up the appropriate ProxyFactory in the Registry
-      List<String> proxyFactoryRegistryKeys = refAddrs
-            .get(ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY);
-      String assertionErrorMessage = "Exactly one Reference Address of type \""
-            + ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY + "\" is required, found "
-            + proxyFactoryRegistryKeys;
-      assert proxyFactoryRegistryKeys != null : assertionErrorMessage;
-      assert proxyFactoryRegistryKeys.size() == 1 : assertionErrorMessage;
-      String proxyFactoryRegistryKey = proxyFactoryRegistryKeys.get(0);
+      String proxyFactoryRegistryKey = this.getSingleRequiredReferenceAddressValue(name, refAddrs,
+            ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY);
 
+      // Obtain the URL for invoking upon the Registry
+      String url = this.getSingleReferenceAddressValue(name, refAddrs,
+            ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_INVOKER_LOCATOR_URL);
+
+      // Initialize Ejb3Registrar
+      Ejb3Registrar registrar = null;
+
+      // If Remoting Defined
+      if (url != null)
+      {
+         // Create a POJI Proxy to the Registrar
+         InvokerLocator locator = new InvokerLocator(url);
+         Interceptor[] interceptors =
+         {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
+         PojiProxy handler = new PojiProxy(RemotingTargetIds.TARGET_ID_EJB_REGISTRAR, locator, interceptors);
+         Class<?>[] interfaces = new Class<?>[]
+         {Ejb3Registrar.class};
+         registrar = (Ejb3Registrar) Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, handler);
+      }
+      // Local
+      else
+      {
+         registrar = Ejb3RegistrarLocator.locateRegistrar();
+      }
+
       // Obtain Proxy Factory
       ProxyFactory proxyFactory = null;
       try
       {
-         Object pfObj = Ejb3RegistrarLocator.locateRegistrar().lookup(proxyFactoryRegistryKey);
+         Object pfObj = registrar.lookup(proxyFactoryRegistryKey);
          assert pfObj != null : ProxyFactory.class.getName() + " from key " + proxyFactoryRegistryKey + " was null";
          assert pfObj instanceof ProxyFactory : " Object obtained from key " + proxyFactoryRegistryKey
                + " was expected to be of type " + ProxyFactory.class.getName() + " but was instead " + pfObj;
@@ -126,28 +153,54 @@
    }
 
    /**
-    * Obtains the container name bound as a reference address to the JNDI Name specified
+    * Obtains the single value of the specified type as obtained from the specified reference 
+    * addresses bound at the specified Name.  Asserts that the value exists and is the only one
+    * for the specified type. 
     * 
     * @param name
     * @param referenceAddresses
+    * @param refAddrType
     * @return
     */
-   protected String getContainerName(Name name, Map<String, List<String>> referenceAddresses)
+   protected String getSingleRequiredReferenceAddressValue(Name name, Map<String, List<String>> referenceAddresses,
+         String refAddrType)
    {
-      // Get the Container Name
-      String refAddrType = ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_EJBCONTAINER_NAME;
-      List<String> containerNames = referenceAddresses.get(refAddrType);
-      assert containerNames != null : RefAddr.class.getSimpleName() + " type of " + refAddrType
-            + " is required to find the EJB Container associated with the " + Reference.class.getSimpleName()
-            + " for JNDI Name " + name;
-      assert containerNames.size() == 1 : "Only one " + RefAddr.class.getSimpleName() + " of type " + refAddrType
-            + " may be defined, instead found: " + containerNames;
-      String containerName = containerNames.get(0);
+      // Get the value
+      String value = this.getSingleReferenceAddressValue(name, referenceAddresses, refAddrType);
+      assert (value != null && !value.trim().equals("")) : "Exactly one " + RefAddr.class.getSimpleName() + " of type "
+            + refAddrType + " must be defined, none found";
 
       // Return
-      return containerName;
+      return value;
    }
 
+   /**
+    * Obtains the single value of the specified type as obtained from the specified reference 
+    * addresses bound at the specified Name.  Asserts that the value exists and is the only one
+    * for the specified type. 
+    * 
+    * @param name
+    * @param referenceAddresses
+    * @param refAddrType
+    * @return
+    */
+   protected String getSingleReferenceAddressValue(Name name, Map<String, List<String>> referenceAddresses,
+         String refAddrType)
+   {
+      // Get the values
+      List<String> values = referenceAddresses.get(refAddrType);
+      assert values == null || values.size() == 1 : "Only one " + RefAddr.class.getSimpleName() + " of type "
+            + refAddrType + " may be defined, instead found: " + values;
+      String value = null;
+      if (values != null)
+      {
+         value = values.get(0).trim();
+      }
+
+      // Return
+      return value;
+   }
+
    // --------------------------------------------------------------------------------||
    // Specifications -----------------------------------------------------------------||
    // --------------------------------------------------------------------------------||

Modified: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/objectfactory/session/SessionProxyObjectFactory.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -140,7 +140,8 @@
       }
 
       // Obtain the target container name
-      String containerName = this.getContainerName(name, referenceAddresses);
+      String containerName = this.getSingleRequiredReferenceAddressValue(name, referenceAddresses,
+            ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_EJBCONTAINER_NAME);
 
       // Get the proxy's invocation handler
       InvocationHandler handler = Proxy.getInvocationHandler(proxy);

Copied: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/IsLocalProxyFactoryInterceptor.java (from rev 73728, projects/ejb3/trunk/core/src/main/java/org/jboss/ejb3/remoting/IsLocalProxyFactoryInterceptor.java)
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/IsLocalProxyFactoryInterceptor.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/IsLocalProxyFactoryInterceptor.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -0,0 +1,79 @@
+/*
+ * 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.proxy.remoting;
+
+import java.io.Serializable;
+
+import org.jboss.aop.Dispatcher;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.joinpoint.InvocationResponse;
+import org.jboss.logging.Logger;
+
+/**
+ * Routes the call to the local container, bypassing further client-side
+ * interceptors and any remoting layer, if this interceptor was created 
+ * in this JVM.
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author Brian Stansberry
+ * 
+ * @version $Revision: 61667 $
+ */
+public class IsLocalProxyFactoryInterceptor implements Interceptor, Serializable
+{
+   private static final long serialVersionUID = -1264055696758370812L;
+
+   public static final IsLocalProxyFactoryInterceptor singleton = new IsLocalProxyFactoryInterceptor();
+
+   private static final Logger log = Logger.getLogger(IsLocalProxyFactoryInterceptor.class);
+
+   private static final long stamp = System.currentTimeMillis();
+
+   private long marshalledStamp = stamp;
+
+   public String getName()
+   {
+      return getClass().getName();
+   }
+
+   public Object invoke(Invocation invocation) throws Throwable
+   {
+      if (isLocal())
+      {
+         Object oid = invocation.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
+         if (Dispatcher.singleton.isRegistered(oid))
+         {
+            InvocationResponse response = Dispatcher.singleton.invoke(invocation);
+            invocation.setResponseContextInfo(response.getContextInfo());
+            log.debug("Local invocation, handling locally via current Dispatcher");
+            return response.getResponse();
+         }
+      }
+      return invocation.invokeNext();
+   }
+
+   private boolean isLocal()
+   {
+      return stamp == marshalledStamp;
+   }
+}

Added: projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/RemotingTargetIds.java
===================================================================
--- projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/RemotingTargetIds.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy/src/main/java/org/jboss/ejb3/proxy/remoting/RemotingTargetIds.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.proxy.remoting;
+
+import org.jboss.ejb3.common.registrar.spi.Ejb3Registrar;
+
+/**
+ * RemotingTargetIds
+ * 
+ * This interface defines the key constants used as 
+ * valid Remoting Target IDs for use in the
+ * Dispatcher singleton
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface RemotingTargetIds
+{
+   // --------------------------------------------------------------------------------||
+   // Constants ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * ID of the EJB3 Registrar
+    */
+   String TARGET_ID_EJB_REGISTRAR = Ejb3Registrar.class.getSimpleName();
+
+}
\ No newline at end of file

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/common/Utils.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -22,8 +22,10 @@
 package org.jboss.ejb3.test.proxy.common;
 
 import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
+import java.util.List;
 
 import org.jboss.ejb3.test.proxy.common.container.StatefulContainer;
 import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
@@ -34,6 +36,7 @@
 import org.jboss.metadata.ejb.jboss.JBossMetaData;
 import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
 import org.jboss.metadata.ejb.jboss.JBossSessionPolicyDecorator;
+import org.jboss.metadata.ejb.jboss.RemoteBindingMetaData;
 import org.jboss.metadata.ejb.spec.EjbJar30MetaData;
 
 /**
@@ -113,9 +116,17 @@
       // emulate merge deployer
       JBossMetaData mergedMetaData = new JBossMetaData();
       mergedMetaData.merge(null, metaData);
-
+      
+      // Get delegate
       JBossSessionBeanMetaData beanMetaDataDelegate = (JBossSessionBeanMetaData) mergedMetaData
             .getEnterpriseBean(beanImplClass.getSimpleName());
+      
+      // Add Remote Binding manually
+      List<RemoteBindingMetaData> remoteBindings = new ArrayList<RemoteBindingMetaData>();
+      RemoteBindingMetaData remoteBinding = new RemoteBindingMetaData();
+      remoteBinding.setClientBindUrl("socket://localhost:3874");
+      remoteBindings.add(remoteBinding);
+      beanMetaDataDelegate.setRemoteBindings(remoteBindings);
 
       // Use a Session JNDI Binding Policy for the metadata
       JBossSessionPolicyDecorator beanMetaData = new JBossSessionPolicyDecorator(beanMetaDataDelegate);

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/MockServer.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -1,7 +1,9 @@
 package org.jboss.ejb3.test.proxy.remoteaccess;
 
+import org.jboss.aop.Dispatcher;
 import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.proxy.remoting.RemotingTargetIds;
 import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
 import org.jboss.ejb3.test.proxy.common.Utils;
 import org.jboss.ejb3.test.proxy.common.container.StatelessContainer;
@@ -85,7 +87,7 @@
 
       // Create a new Launcher
       MockServer launcher = new MockServer(testClass);
-      MockServer.setServer(server);
+      MockServer.setServer(launcher);
 
       // Initialize the launcher in a new Thread
       new Startup(launcher).start();
@@ -116,6 +118,10 @@
       // Bind the Ejb3Registrar
       Ejb3RegistrarLocator.bindRegistrar(new Ejb3McRegistrar(bootstrap.getKernel()));
 
+      // Register the EJB3 Registrar with Remoting
+      Dispatcher.singleton.registerTarget(RemotingTargetIds.TARGET_ID_EJB_REGISTRAR, Ejb3RegistrarLocator
+            .locateRegistrar());
+
       // Deploy *-beans.xml
       this.getBootstrap().deploy(this.getTestClass());
 

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -133,7 +133,6 @@
        * This is far from a graceful shutdown, but hey, this is only for a test
        */
       Process p = RemoteAccessTestCase.getRemoteProcess();
-      p.getOutputStream().flush();
       p.destroy();
 
    }

Modified: projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCaseBase.java
===================================================================
--- projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCaseBase.java	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/test/java/org/jboss/ejb3/test/proxy/session/unit/ProxySessionTestCaseBase.java	2008-05-28 23:03:08 UTC (rev 73757)
@@ -21,8 +21,10 @@
  */
 package org.jboss.ejb3.test.proxy.session.unit;
 
+import org.jboss.aop.Dispatcher;
 import org.jboss.ejb3.common.registrar.plugin.mc.Ejb3McRegistrar;
 import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
+import org.jboss.ejb3.proxy.remoting.RemotingTargetIds;
 import org.jboss.ejb3.test.mc.bootstrap.EmbeddedTestMcBootstrap;
 
 /**
@@ -53,5 +55,9 @@
 
       // Bind the Registrar
       Ejb3RegistrarLocator.bindRegistrar(new Ejb3McRegistrar(bootstrap.getKernel()));
+      
+      // Register the EJB3 Registrar with Remoting
+      Dispatcher.singleton.registerTarget(RemotingTargetIds.TARGET_ID_EJB_REGISTRAR, Ejb3RegistrarLocator
+            .locateRegistrar());
    }
 }

Modified: projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase-beans.xml	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/remoteaccess/unit/RemoteAccessTestCase-beans.xml	2008-05-28 23:03:08 UTC (rev 73757)
@@ -53,4 +53,34 @@
   <bean name="org.jboss.ejb3.JndiContext"
     class="javax.naming.InitialContext" />
 
+  <!-- 
+    
+    Remoting
+    
+  -->
+
+  <!-- Remoting  Configuration -->
+  <bean name="ServerConfiguration"
+    class="org.jboss.remoting.ServerConfiguration">
+    <property name="invocationHandlers">
+      <map keyClass="java.lang.String" valueClass="java.lang.String">
+        <entry>
+          <key>AOP</key>
+          <value>
+            org.jboss.aspects.remoting.AOPRemotingInvocationHandler
+          </value>
+        </entry>
+      </map>
+    </property>
+  </bean>
+
+  <!-- Remoting Connector -->
+  <bean name="Connector"
+    class="org.jboss.remoting.transport.Connector">
+    <property name="invokerLocator">socket://0.0.0.0:3874</property>
+    <property name="serverConfiguration">
+      <inject bean="ServerConfiguration" />
+    </property>
+  </bean>
+
 </deployment>
\ No newline at end of file

Modified: projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionTestCase-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionTestCase-beans.xml	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatefulSessionTestCase-beans.xml	2008-05-28 23:03:08 UTC (rev 73757)
@@ -44,4 +44,34 @@
   <bean name="org.jboss.ejb3.JndiContext"
     class="javax.naming.InitialContext" />
 
+  <!-- 
+    
+    Remoting
+    
+  -->
+
+  <!-- Remoting  Configuration -->
+  <bean name="ServerConfiguration"
+    class="org.jboss.remoting.ServerConfiguration">
+    <property name="invocationHandlers">
+      <map keyClass="java.lang.String" valueClass="java.lang.String">
+        <entry>
+          <key>AOP</key>
+          <value>
+            org.jboss.aspects.remoting.AOPRemotingInvocationHandler
+          </value>
+        </entry>
+      </map>
+    </property>
+  </bean>
+
+  <!-- Remoting Connector -->
+  <bean name="Connector"
+    class="org.jboss.remoting.transport.Connector">
+    <property name="invokerLocator">socket://0.0.0.0:3874</property>
+    <property name="serverConfiguration">
+      <inject bean="ServerConfiguration" />
+    </property>
+  </bean>
+
 </deployment>
\ No newline at end of file

Modified: projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionTestCase-beans.xml
===================================================================
--- projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionTestCase-beans.xml	2008-05-28 22:58:47 UTC (rev 73756)
+++ projects/ejb3/trunk/proxy/src/test/resources/org/jboss/ejb3/test/proxy/session/unit/ProxyStatelessSessionTestCase-beans.xml	2008-05-28 23:03:08 UTC (rev 73757)
@@ -44,4 +44,34 @@
   <bean name="org.jboss.ejb3.JndiContext"
     class="javax.naming.InitialContext" />
 
+  <!-- 
+    
+    Remoting
+    
+  -->
+
+  <!-- Remoting  Configuration -->
+  <bean name="ServerConfiguration"
+    class="org.jboss.remoting.ServerConfiguration">
+    <property name="invocationHandlers">
+      <map keyClass="java.lang.String" valueClass="java.lang.String">
+        <entry>
+          <key>AOP</key>
+          <value>
+            org.jboss.aspects.remoting.AOPRemotingInvocationHandler
+          </value>
+        </entry>
+      </map>
+    </property>
+  </bean>
+
+  <!-- Remoting Connector -->
+  <bean name="Connector"
+    class="org.jboss.remoting.transport.Connector">
+    <property name="invokerLocator">socket://0.0.0.0:3874</property>
+    <property name="serverConfiguration">
+      <inject bean="ServerConfiguration" />
+    </property>
+  </bean>
+
 </deployment>
\ No newline at end of file




More information about the jboss-cvs-commits mailing list