[jboss-cvs] JBossAS SVN: r71021 - in branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3: src/main/org/jboss/annotation/ejb and 7 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Mar 19 13:37:46 EDT 2008


Author: tkimura at redhat.com
Date: 2008-03-19 13:37:46 -0400 (Wed, 19 Mar 2008)
New Revision: 71021

Added:
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/resources/test/ejbthree994/
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/resources/test/ejbthree994/ejbthree994-connectors-service.xml
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/BusinessInterface.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/StatefulBean.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/MultiBindingsTestCase.java
Modified:
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/build-test.xml
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/annotation/ejb/RemoteBinding.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/annotation/ejb/RemoteBindingImpl.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
   branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
Log:
[JBPAPP-694] Port fix and testcase

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/build-test.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/build-test.xml	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/build-test.xml	2008-03-19 17:37:46 UTC (rev 71021)
@@ -1822,6 +1822,19 @@
       
       <build-simple-jar name="ejbthree963"/>
    </target>
+
+   <target name="ejbthree994"
+      description="Builds a simple jar files."
+      depends="compile-classes">
+      
+      <build-simple-jar name="ejbthree994"/>
+
+      <copy todir="${build.lib}">
+         <fileset dir="${resources}/test/ejbthree994">
+            <include name="ejbthree994-connectors-service.xml"/>
+         </fileset>
+      </copy>
+   </target>
    
    <target name="jbas4489"
       description="Builds a simple jar files."
@@ -3221,7 +3234,7 @@
    <target name="jars" depends="entityoptimisticlocking, concurrentnaming, propertyreplacement, persistenceunits, invalidtxmdb, descriptortypo, libdeployment, homeinterface, timestampentity, servicexmbean, arjuna, mdbtransactions, unauthenticatedprincipal, clusteredservice, invoker, classloader, 
       circulardependency, jsp, timerdependency, servicedependency, servlet, stateless14, webservices, ear, ejbthree440, 
       ejbthree454, ejbthree653, ejbthree670, ejbthree712, ejbthree724, ejbthree751, ejbthree832, ejbthree921,
-      ejbthree959, ejbthree963,
+      ejbthree959, ejbthree963, ejbthree994,
       jbas4489,
       aspectdomain, ejbcontext, schema, mail, scopedclassloader, dependency, jaxws,
       pkg, securitydomain, enventry, 
@@ -3753,6 +3766,9 @@
          <param name="test" value="ejbthree963"/>
       </antcall>
       <antcall target="test" inheritRefs="true">
+         <param name="test" value="ejbthree994"/>
+      </antcall>
+      <antcall target="test" inheritRefs="true">
          <param name="test" value="jbas4489"/>
       </antcall>
    </target>

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/annotation/ejb/RemoteBinding.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/annotation/ejb/RemoteBinding.java	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/annotation/ejb/RemoteBinding.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -44,6 +44,8 @@
    String interceptorStack() default "";
 
    String clientBindUrl() default "";
+   
+   String invokerName() default "";
 
    Class factory() default org.jboss.ejb3.remoting.RemoteProxyFactory.class;
 }

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/annotation/ejb/RemoteBindingImpl.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/annotation/ejb/RemoteBindingImpl.java	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/annotation/ejb/RemoteBindingImpl.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -40,6 +40,7 @@
    private String jndi;
    private String stack;
    private String bindUrl;
+   private String invokerName;
    private Class proxyFactory;
    
    public RemoteBindingImpl()
@@ -47,6 +48,7 @@
       jndi = "";
       stack = "";
       bindUrl = "";
+      invokerName = "";
       proxyFactory = org.jboss.ejb3.remoting.RemoteProxyFactory.class;
    }
 
@@ -55,9 +57,19 @@
       this.jndi = jndi;
       this.stack = stack;
       this.bindUrl = bindUrl;
+      this.invokerName = "";
       this.proxyFactory = proxyFactory;
    }
    
+   public RemoteBindingImpl(String jndi, String stack, String bindUrl, String invokerName, Class proxyFactory)
+   {
+      this.jndi = jndi;
+      this.stack = stack;
+      this.bindUrl = bindUrl;
+      this.invokerName = invokerName;
+      this.proxyFactory = proxyFactory;
+   }
+   
    public void setStack(String stack)
    {
       this.stack = stack;
@@ -73,6 +85,11 @@
       this.jndi = jndi;
    }
    
+   public void setInvokerName(String invokerName)
+   {
+      this.invokerName = invokerName;
+   }
+   
    public void setBindUrl(String bindUrl)
    {
       this.bindUrl = bindUrl;
@@ -92,6 +109,11 @@
    {
       return bindUrl;
    }
+   
+   public String invokerName()
+   {
+      return invokerName;
+   }
 
    public Class factory()
    {
@@ -109,6 +131,9 @@
       if (bindUrl.length() == 0)
          bindUrl = annotation.clientBindUrl();
       
+      if (invokerName.length() == 0)
+         invokerName = annotation.invokerName();
+      
       if (proxyFactory == org.jboss.ejb3.remoting.RemoteProxyFactory.class)
          proxyFactory = annotation.factory();
       
@@ -126,6 +151,7 @@
       sb.append(", jndi=" + jndi);
       sb.append(", stack=" + stack);
       sb.append(", bindUrl=" + bindUrl);
+      sb.append(", invokerName=" + invokerName);
       sb.append(", proxyFactory=" + proxyFactory);
       sb.append(']');
       return sb.toString();

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/ClientKernelAbstraction.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -21,10 +21,10 @@
 */
 package org.jboss.ejb3;
 
+import java.util.Set;
+
 import javax.management.ObjectName;
 
-import javax.management.MBeanServer;
-
 /**
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
  */
@@ -33,4 +33,6 @@
    Object invoke(ObjectName name, String operationName, Object[] params, String[] signature) throws Exception;
 
    public Object getAttribute(ObjectName name, String attribute) throws Exception;
+   
+   Set getMBeans(ObjectName query) throws Exception;
 }

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/JmxClientKernelAbstraction.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -21,6 +21,8 @@
 */
 package org.jboss.ejb3;
 
+import java.util.Set;
+
 import javax.management.MBeanServerConnection;
 import javax.management.ObjectName;
 import org.jboss.logging.Logger;
@@ -48,4 +50,11 @@
    {
       return server.getAttribute(name, attribute);
    }
+   
+   public Set getMBeans(ObjectName query) throws Exception
+   {
+      Set mbeans = server.queryMBeans(query, null);
+      
+      return mbeans;
+   }
 }

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/MCClientKernelAbstraction.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -29,6 +29,8 @@
 import javax.management.ObjectName;
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
  * @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
@@ -82,4 +84,12 @@
       }
       return null;
    }
+   
+   public Set getMBeans(ObjectName query) throws Exception
+   {
+      Object target = kernel.getRegistry().getEntry(query);
+      Set set = new HashSet();
+      set.add(target);
+      return set;
+   }
 }

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/ProxyFactoryHelper.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -37,13 +37,16 @@
 import javax.ejb.Remote;
 import javax.ejb.RemoteHome;
 import javax.jws.WebService;
+import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 import javax.naming.Context;
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Iterator;
+import java.util.Set;
 
 /**
  * Comment
@@ -472,17 +475,57 @@
       String clientBindUrl = binding.clientBindUrl();
       if (clientBindUrl.trim().length() == 0)
       {
-         ObjectName connectionON = new ObjectName("jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3");
-         KernelAbstraction kernelAbstraction = KernelAbstractionFactory.getInstance();
-         try
+         if (binding.invokerName() != null && binding.invokerName().trim().length() != 0)
          {
-            clientBindUrl = (String)kernelAbstraction.getAttribute(connectionON, "InvokerLocator");
+            try
+            {
+               ObjectName connectionON = new ObjectName(binding.invokerName());
+               KernelAbstraction kernelAbstraction = KernelAbstractionFactory.getInstance();
+               clientBindUrl = (String)kernelAbstraction.getAttribute(connectionON, "InvokerLocator");
+            }
+            catch (Exception e)
+            {
+               log.warn("Unable to find InvokerLocator " + binding.invokerName() + ". Using default. " + e);
+               clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
+            }
          }
-         catch (Exception e)
+         else
          {
-            clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
+            try
+            {
+               ObjectName connectionON = new ObjectName("jboss.remoting:type=Connector,name=DefaultEjb3Connector,handler=ejb3");
+               KernelAbstraction kernelAbstraction = KernelAbstractionFactory.getInstance();
+               clientBindUrl = (String)kernelAbstraction.getAttribute(connectionON, "InvokerLocator");
+            }
+            catch (Exception e)
+            {
+               log.warn("Unable to find default InvokerLocator. Using default. " + e);
+               clientBindUrl = RemoteProxyFactory.DEFAULT_CLIENT_BINDING;
+            }
          }
       }
+      else if (clientBindUrl.indexOf("0.0.0.0") != -1)
+      {
+         KernelAbstraction kernelAbstraction = KernelAbstractionFactory.getInstance();
+         ObjectName query = new ObjectName("jboss.remoting:type=Connector,handler=ejb3,*");
+         Set mbeanSet = kernelAbstraction.getMBeans(query);
+         
+         URI targetUri = new URI(clientBindUrl);
+         Iterator mbeans = mbeanSet.iterator();
+         while (mbeans.hasNext())
+         {
+            ObjectInstance invokerInstance = (ObjectInstance)mbeans.next();
+            ObjectName invokerName = invokerInstance.getObjectName();
+            String invokerLocator = (String)kernelAbstraction.getAttribute(invokerName, "InvokerLocator");
+            URI uri = new URI(invokerLocator);
+          
+            if (uri.getScheme().equals(targetUri.getScheme()) && uri.getPort() == targetUri.getPort())
+            {
+               return invokerLocator;
+            }
+         }
+         return clientBindUrl;
+      }
       
       return clientBindUrl;
    }

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -63,7 +63,7 @@
 {
    private static final Logger log = Logger.getLogger(StatefulClusterProxyFactory.class);
    
-   public static final String FACTORY_ATTRIBUTE = ",element=ProxyFactory,partition=";
+//   public static final String FACTORY_ATTRIBUTE = ",element=ProxyFactory,partition=";
    
    private RemoteBinding binding;
    private InvokerLocator locator;
@@ -195,10 +195,13 @@
       return handle;
    }
    
+   /**
+    * @return unique name for this proxy factory
+    */
    protected String getTargetId()
    {  
       String partition = ((StatefulContainer) container).getPartitionName();
-      return container.getObjectName().getCanonicalName() + FACTORY_ATTRIBUTE + partition;
+      return jndiName + PROXY_FACTORY_NAME + "@" + partition;
    }
    
    public synchronized void replicantsChanged (String key, 

Modified: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2008-03-19 17:33:35 UTC (rev 71020)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -55,7 +55,7 @@
 {
    private static final Logger log = Logger.getLogger(StatefulRemoteProxyFactory.class);
    
-   public static final String FACTORY_ATTRIBUTE = ",element=ProxyFactory";
+//   public static final String FACTORY_ATTRIBUTE = ",element=ProxyFactory";
    
    private RemoteBinding binding;
    private InvokerLocator locator;
@@ -258,9 +258,12 @@
       }
    }
    
+   /**
+    * @return unique name for this proxy factory
+    */
    protected String getTargetId()
    {  
-      return container.getObjectName().getCanonicalName() + FACTORY_ATTRIBUTE;
+      return jndiName + PROXY_FACTORY_NAME;
    }
    
    protected Object createPojiProxy(Object oid, Class[] interfaces, String uri) throws Exception

Added: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/resources/test/ejbthree994/ejbthree994-connectors-service.xml
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/resources/test/ejbthree994/ejbthree994-connectors-service.xml	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/resources/test/ejbthree994/ejbthree994-connectors-service.xml	2008-03-19 17:37:46 UTC (rev 71021)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   JBoss EJB3Deployer
+   
+   $Id: ejbthree994-connectors-service.xml 69965 2008-02-20 06:27:57Z bdecoste $
+-->
+<server>
+
+   <mbean code="org.jboss.remoting.transport.Connector"
+          name="jboss.remoting:type=Connector,name=Ejbthree994Ejb3Connector,handler=ejb3">
+      <attribute name="InvokerLocator">socket://${jboss.bind.address}:3874</attribute>
+      <attribute name="Configuration">
+         <handlers>
+            <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
+         </handlers>
+      </attribute>
+   </mbean>
+   
+   <mbean code="org.jboss.remoting.transport.Connector"
+          name="jboss.remoting.test:type=Connector,name=Ejbthree994TestEjb3Connector,handler=ejb3">
+      <attribute name="InvokerLocator">socket://${jboss.bind.address}:3875</attribute>
+      <attribute name="Configuration">
+         <handlers>
+            <handler subsystem="AOP">org.jboss.aspects.remoting.AOPRemotingInvocationHandler</handler>
+         </handlers>
+      </attribute>
+   </mbean>
+   
+</server>

Added: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/BusinessInterface.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/BusinessInterface.java	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/BusinessInterface.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejbthree994;
+
+/**
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 69056 $
+ */
+public interface BusinessInterface
+{
+   String echo(String s);
+}

Added: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/StatefulBean.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/StatefulBean.java	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/StatefulBean.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejbthree994;
+
+import javax.ejb.Remote;
+import javax.ejb.Stateful;
+import org.jboss.annotation.ejb.RemoteBinding;
+import org.jboss.annotation.ejb.RemoteBindings;
+
+/**
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 69964 $
+ */
+ at Stateful
+ at RemoteBindings({
+   @RemoteBinding(clientBindUrl="socket://0.0.0.0:3873", jndiBinding="Stateful3873"),
+   @RemoteBinding(clientBindUrl="socket://0.0.0.0:3874", jndiBinding="Stateful3874"),
+   @RemoteBinding(invokerName="jboss.remoting.test:type=Connector,name=Ejbthree994TestEjb3Connector,handler=ejb3", jndiBinding="Stateful3875")
+})
+ at Remote(BusinessInterface.class)
+public class StatefulBean implements BusinessInterface
+{
+   public String echo(String s)
+   {
+      return "*** " + s + " ***";
+   }
+}

Added: branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/MultiBindingsTestCase.java
===================================================================
--- branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/MultiBindingsTestCase.java	                        (rev 0)
+++ branches/JBPAPP_4_2_0_GA_JBPAPP-694/ejb3/src/test/org/jboss/ejb3/test/ejbthree994/unit/MultiBindingsTestCase.java	2008-03-19 17:37:46 UTC (rev 71021)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.ejbthree994.unit;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Proxy;
+
+import junit.framework.Test;
+
+import org.jboss.ejb3.test.ejbthree994.BusinessInterface;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.test.JBossTestCase;
+
+
+/**
+ * Test if multiple remote bindings work correctly.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: 69964 $
+ */
+public class MultiBindingsTestCase extends JBossTestCase
+{
+
+   public MultiBindingsTestCase(String name)
+   {
+      super(name);
+   }
+
+   private static String getProxyUri(Object proxy) throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
+   {
+      InvocationHandler handler = Proxy.getInvocationHandler(proxy);
+      Field f = handler.getClass().getDeclaredField("uri");
+      f.setAccessible(true);
+      InvokerLocator locator = (InvokerLocator) f.get(handler);
+      return locator.getOriginalURI();
+   }
+   
+   public void test1() throws Exception
+   {
+      {
+         BusinessInterface bean = (BusinessInterface) getInitialContext().lookup("Stateful3873");
+         String actual = bean.echo("123");
+         assertEquals(actual, "*** 123 ***");
+         
+         String proxyUri = getProxyUri(bean);
+         // Both IP address and hostname should work
+         try {
+             assertEquals("socket://127.0.0.1:3873/", proxyUri);
+         } catch (Throwable t) {
+             assertEquals("socket://localhost:3873/", proxyUri);
+         }
+      }
+
+      {
+         BusinessInterface bean = (BusinessInterface) getInitialContext().lookup("Stateful3874");
+         String actual = bean.echo("456");
+         assertEquals(actual, "*** 456 ***");
+         
+         String proxyUri = getProxyUri(bean);
+         try {
+             assertEquals("socket://127.0.0.1:3874/", proxyUri);
+         } catch (Throwable t) {
+             assertEquals("socket://localhost:3874/", proxyUri);
+         }
+      }
+      
+      {
+         BusinessInterface bean = (BusinessInterface) getInitialContext().lookup("Stateful3875");
+         String actual = bean.echo("789");
+         assertEquals(actual, "*** 789 ***");
+         
+         String proxyUri = getProxyUri(bean);
+         try {
+             assertEquals("socket://127.0.0.1:3875/", proxyUri);
+         } catch (Throwable t) {
+             assertEquals("socket://localhost:3875/", proxyUri);
+         }
+      }
+   }
+   
+   public static Test suite() throws Exception
+   {
+      return getDeploySetup(MultiBindingsTestCase.class, "ejbthree994-connectors-service.xml,ejbthree994.jar");
+   }
+
+}




More information about the jboss-cvs-commits mailing list