This content has been marked as final.
Show 1 reply
-
1. Re: Call Clustred SessionBean into same JVM ...
jmspaggi Jan 13, 2004 8:48 AM (in response to jmspaggi)"jmspaggi" wrote:
OK. I have found a solution. Not the best, but a working solution.
In standardjboss.xml
Modify org.jboss.proxy.TransactionInterceptor by org.jboss.proxy.MyInterceptor
Here is MyInterceptor :package org.jboss.invocation; /* * JBoss, the OpenSource J2EE webOS * * Distributable under LGPL license. See terms of license at gnu.org. */ import java.io.Externalizable; import javax.management.ObjectName; import org.jboss.invocation.Invocation; import org.jboss.invocation.InvocationContext; import org.jboss.invocation.Invoker; import org.jboss.invocation.InvokerInterceptor; import org.jboss.system.Registry; /** * A very simple implementation of it that branches to the local stuff. * * @author <a href="mailto:marc.fleury@jboss.org">Marc Fleury</a> * @author Scott.Stark@jboss.org * @version $Revision: 1.2.2.2 $ */ public class MyInterceptor extends InvokerInterceptor implements Externalizable { public static final String FORCEREMOTE = "forceremote"; public static boolean isForceRemote(Invocation invocation) { ObjectName mbean = null; mbean = (ObjectName)Registry.lookup(invocation.getObjectName()); return mbean.getCanonicalName().indexOf(FORCEREMOTE) >= 0; } /** * The invocation on the delegate, calls the right invoker. Remote if we are remote, local if we are local. */ public Object invoke(Invocation invocation) throws Exception { Object returnValue = null; InvocationContext ctx = invocation.getInvocationContext(); // optimize if calling another bean in same server VM if (isForceRemote(invocation) || ! isLocal()) { // The payload will go through marshalling at the invoker layer Invoker invoker = ctx.getInvoker(); returnValue = invoker.invoke(invocation); } else { // The payload as is is good returnValue = localInvoker.invoke(invocation); } return returnValue; } }
After, modify JRMPInvokerProxyHA by changing isLocal like this :public boolean isLocal(Invocation invocation) { return colocation.contains(invocation.getObjectName()) && !MyInterceptor.isForceRemote(invocation); }
When it's done, put back this classes in jbossha.jar in \all\lib\.
Now, if your EJB name containt forceremote, it will be load anywhere in the cluster. On other case, it will be load only on the local JVM.
You can improved this stub by adding XML configuration file with class name instead of looking at "forceremote" in the JNDI name, but it's enough for me.
JMS.