[jboss-cvs] JBossAS SVN: r61714 - in branches/Branch_4_2/ejb3: src/main/org/jboss/ejb3/remoting and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Mar 26 14:44:03 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-03-26 14:44:03 -0400 (Mon, 26 Mar 2007)
New Revision: 61714
Added:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalProxyFactoryInterceptor.java
Modified:
branches/Branch_4_2/ejb3/build.xml
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/InvokeLocalTestBase.java
Log:
[EJBTHREE-795] SFSB proxy creation process incorrectly routed locally
Modified: branches/Branch_4_2/ejb3/build.xml
===================================================================
--- branches/Branch_4_2/ejb3/build.xml 2007-03-26 17:23:46 UTC (rev 61713)
+++ branches/Branch_4_2/ejb3/build.xml 2007-03-26 18:44:03 UTC (rev 61714)
@@ -334,7 +334,8 @@
<include name="org/jboss/ejb3/mdb/Producer*.class"/>
<include name="org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.*"/>
<include name="org/jboss/ejb3/remoting/IsLocalInterceptor.*"/>
- <include name="org/jboss/ejb3/stateful/ForwardId.class"/>
+ <include name="org/jboss/ejb3/remoting/IsLocalProxyFactoryInterceptor.*"/>
+ <include name="org/jboss/ejb3/stateful/ForwardId.class"/>
<include name="org/jboss/ejb3/stateful/StatefulRemoteInvocation.class"/>
<include name="org/jboss/ejb3/ProxyUtils.class"/>
<include name="org/jboss/ejb3/**/*Proxy.class"/>
Added: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalProxyFactoryInterceptor.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalProxyFactoryInterceptor.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalProxyFactoryInterceptor.java 2007-03-26 18:44:03 UTC (rev 61714)
@@ -0,0 +1,77 @@
+/*
+ * 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.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());
+ return response.getResponse();
+ }
+ }
+ return invocation.invokeNext();
+ }
+
+ private boolean isLocal()
+ {
+ return stamp == marshalledStamp;
+ }
+}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2007-03-26 17:23:46 UTC (rev 61713)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulClusterProxyFactory.java 2007-03-26 18:44:03 UTC (rev 61714)
@@ -56,6 +56,8 @@
*/
public class StatefulClusterProxyFactory extends BaseStatefulProxyFactory implements RemoteProxyFactory
{
+ public static final String FACTORY_ATTRIBUTE = ",element=ProxyFactory,partition=";
+
private RemoteBinding binding;
private InvokerLocator locator;
private HATarget hatarget;
@@ -105,7 +107,8 @@
wrapper = new FamilyWrapper(proxyFamilyName, hatarget.getReplicants());
super.start();
Class[] interfaces = {ProxyFactory.class};
- Object factoryProxy = Remoting.createPojiProxy(jndiName + PROXY_FACTORY_NAME, interfaces, ProxyFactoryHelper.getClientBindUrl(binding));
+ String targetId = getTargetId();
+ Object factoryProxy = Remoting.createPojiProxy(targetId, interfaces, ProxyFactoryHelper.getClientBindUrl(binding));
try
{
Util.rebind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy);
@@ -115,7 +118,7 @@
namingException.setRootCause(e);
throw namingException;
}
- Dispatcher.singleton.registerTarget(jndiName + PROXY_FACTORY_NAME, this);
+ Dispatcher.singleton.registerTarget(targetId, this);
}
@@ -176,5 +179,11 @@
return handle;
}
+
+ protected String getTargetId()
+ {
+ String partition = ((StatefulContainer) container).getPartitionName();
+ return container.getObjectName().getCanonicalName() + FACTORY_ATTRIBUTE + partition;
+ }
}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java 2007-03-26 17:23:46 UTC (rev 61713)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/stateful/StatefulRemoteProxyFactory.java 2007-03-26 18:44:03 UTC (rev 61714)
@@ -22,6 +22,8 @@
package org.jboss.ejb3.stateful;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Proxy;
+
import javax.naming.NamingException;
import javax.ejb.RemoteHome;
import org.jboss.annotation.ejb.RemoteBinding;
@@ -29,10 +31,13 @@
import org.jboss.aop.AspectManager;
import org.jboss.aop.Dispatcher;
import org.jboss.aop.advice.AdviceStack;
-import org.jboss.aspects.remoting.Remoting;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.aspects.remoting.PojiProxy;
import org.jboss.ejb3.JBossProxy;
import org.jboss.ejb3.ProxyFactory;
import org.jboss.ejb3.ProxyFactoryHelper;
+import org.jboss.ejb3.remoting.IsLocalProxyFactoryInterceptor;
import org.jboss.ejb3.remoting.RemoteProxyFactory;
import org.jboss.logging.Logger;
import org.jboss.naming.Util;
@@ -42,12 +47,16 @@
* Comment
*
* @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @author Brian Stansberry
+ *
* @version $Revision$
*/
public class StatefulRemoteProxyFactory extends BaseStatefulProxyFactory implements RemoteProxyFactory
{
private static final Logger log = Logger.getLogger(StatefulRemoteProxyFactory.class);
-
+
+ public static final String FACTORY_ATTRIBUTE = ",element=ProxyFactory";
+
private RemoteBinding binding;
private InvokerLocator locator;
@@ -106,7 +115,8 @@
super.start();
Class[] interfaces = {ProxyFactory.class};
- Object factoryProxy = Remoting.createPojiProxy(jndiName + PROXY_FACTORY_NAME, interfaces, ProxyFactoryHelper.getClientBindUrl(binding));
+ String targetId = getTargetId();
+ Object factoryProxy = createPojiProxy(targetId, interfaces, ProxyFactoryHelper.getClientBindUrl(binding));
try
{
Util.rebind(container.getInitialContext(), jndiName + PROXY_FACTORY_NAME, factoryProxy);
@@ -117,7 +127,7 @@
namingException.setRootCause(e);
throw namingException;
}
- Dispatcher.singleton.registerTarget(jndiName + PROXY_FACTORY_NAME, this);
+ Dispatcher.singleton.registerTarget(targetId, this);
StatefulContainer statefulContainer = (StatefulContainer) container;
RemoteHome remoteHome = (RemoteHome) statefulContainer.resolveAnnotation(RemoteHome.class);
@@ -247,6 +257,20 @@
throw new RuntimeException(e.getTargetException()); //To change body of catch statement use Options | File Templates.
}
}
+
+ protected String getTargetId()
+ {
+ return container.getObjectName().getCanonicalName() + FACTORY_ATTRIBUTE;
+ }
+
+ protected Object createPojiProxy(Object oid, Class[] interfaces, String uri) throws Exception
+ {
+ InvokerLocator locator = new InvokerLocator(uri);
+ Interceptor[] interceptors = {IsLocalProxyFactoryInterceptor.singleton, InvokeRemoteInterceptor.singleton};
+ PojiProxy proxy = new PojiProxy(oid, locator, interceptors);
+ return Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, proxy);
+ }
+
}
Modified: branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/InvokeLocalTestBase.java
===================================================================
--- branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/InvokeLocalTestBase.java 2007-03-26 17:23:46 UTC (rev 61713)
+++ branches/Branch_4_2/ejb3/src/test/org/jboss/ejb3/test/clusteredsession/unit/InvokeLocalTestBase.java 2007-03-26 18:44:03 UTC (rev 61714)
@@ -55,7 +55,8 @@
super.setUp();
RMIAdaptor[] adaptors = getAdaptors();
- setPartitionName(adaptors[1]);
+ setPartitionName(adaptors[0], "DefaultPartition");
+ setPartitionName(adaptors[1], getPartitionName());
}
@@ -65,6 +66,7 @@
super.tearDown();
RMIAdaptor[] adaptors = getAdaptors();
+ clearPartitionName(adaptors[0]);
clearPartitionName(adaptors[1]);
}
@@ -101,26 +103,27 @@
else
assertFalse("Call went remote", local.equals(passThroughID));
-// passThroughID = tester.getVMIDFromRemoteLookup(jndiURLs[1], jndiName);
-// assertNotNull("Got the remote VMID", passThroughID);
-//
-// if (expectLocal)
-// assertEquals("Call stayed local", local, passThroughID);
-// else
-// assertFalse("Call went remote", local.equals(passThroughID));
+ passThroughID = tester.getVMIDFromRemoteLookup(jndiURLs[1], jndiName);
+ assertNotNull("Got the remote VMID", passThroughID);
+
+ if (expectLocal)
+ assertEquals("Call stayed local", local, passThroughID);
+ else
+ assertFalse("Call went remote", local.equals(passThroughID));
}
protected abstract String getPartitionName();
- private void setPartitionName(RMIAdaptor adaptor) throws Exception
+ private void setPartitionName(RMIAdaptor adaptor, String partitionName) throws Exception
{
- Object[] args = { PARTITION_NAME_PROPERTY, getPartitionName() };
+ Object[] args = { PARTITION_NAME_PROPERTY, partitionName };
String[] sig = { String.class.getName(), String.class.getName() };
adaptor.invoke(new ObjectName(PROPERTIES_SERVICE), "set", args, sig);
}
private void clearPartitionName(RMIAdaptor adaptor) throws Exception
{
+ setPartitionName(adaptor, "DefaultPartition");
Object[] args = { PARTITION_NAME_PROPERTY };
String[] sig = { String.class.getName() };
adaptor.invoke(new ObjectName(PROPERTIES_SERVICE), "remove", args, sig);
More information about the jboss-cvs-commits
mailing list