[jboss-cvs] JBossAS SVN: r61667 - in branches/Branch_4_2/ejb3/src: resources and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Mar 25 10:56:32 EDT 2007
Author: bstansberry at jboss.com
Date: 2007-03-25 10:56:32 -0400 (Sun, 25 Mar 2007)
New Revision: 61667
Added:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java
Modified:
branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalInterceptor.java
branches/Branch_4_2/ejb3/src/resources/ejb3-interceptors-aop.xml
Log:
[EJBTHREE-881] Create a clustered version of IsLocalInterceptor
Added: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java (rev 0)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/ClusteredIsLocalInterceptor.java 2007-03-25 14:56:32 UTC (rev 61667)
@@ -0,0 +1,103 @@
+/*
+ * 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 org.jboss.aop.Dispatcher;
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.logging.Logger;
+import org.jboss.ejb3.Container;
+import org.jboss.ejb3.EJBContainer;
+import org.jboss.ejb3.Ejb3Registry;
+
+/**
+ * Routes the call to the local container, bypassing further client-side
+ * interceptors and any remoting layer, if a container with the same OID
+ * and partition name is available.
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: 60233 $
+ */
+public class ClusteredIsLocalInterceptor extends IsLocalInterceptor
+{
+ private static final long serialVersionUID = 5765933584762500725L;
+
+ private static final Logger log = Logger.getLogger(ClusteredIsLocalInterceptor.class);
+
+ public static final String PARTITION_NAME = "PARTITION_NAME";
+
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ Container localContainer = findLocalContainer(invocation);
+ if (localContainer != null)
+ {
+ return invokeLocal(invocation, localContainer);
+ }
+ return invocation.invokeNext();
+ }
+
+ private Container findLocalContainer(Invocation invocation)
+ {
+ Object oid = invocation.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
+ Container container = null;
+ try
+ {
+ container = Ejb3Registry.getContainer(oid.toString());
+ }
+ catch (IllegalStateException ignored)
+ {
+ if (log.isTraceEnabled())
+ log.trace("Cannot find local container for " + oid);
+ }
+
+ if (container != null)
+ {
+ String partitionName = (String) invocation.getMetaData(PARTITION_NAME, PARTITION_NAME);
+ if (partitionName != null)
+ {
+ if (!partitionName.equals(((EJBContainer) container).getPartitionName()))
+ {
+ if (log.isTraceEnabled())
+ {
+ log.trace("Partition (" + ((EJBContainer) container).getPartitionName() +
+ ") for local container " + oid + " does not match invocation (" +
+ partitionName + ")");
+ }
+ container = null;
+ }
+ else if (log.isTraceEnabled())
+ {
+ log.trace("Partition (" + ((EJBContainer) container).getPartitionName() +
+ ") for local container " + oid + " matches invocation (" +
+ partitionName + ")");
+ }
+ }
+ else
+ {
+ log.warn("No PARTITION_NAME metadata associated with invocation");
+ container = null;
+ }
+ }
+
+ return container;
+ }
+}
Modified: branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalInterceptor.java
===================================================================
--- branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalInterceptor.java 2007-03-25 14:48:20 UTC (rev 61666)
+++ branches/Branch_4_2/ejb3/src/main/org/jboss/ejb3/remoting/IsLocalInterceptor.java 2007-03-25 14:56:32 UTC (rev 61667)
@@ -34,13 +34,19 @@
import org.jboss.ejb3.Ejb3Registry;
/**
- * Comment
+ * 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$
*/
public class IsLocalInterceptor implements Interceptor, Serializable
{
+ private static final long serialVersionUID = 337700910587744646L;
+
private static final Logger log = Logger.getLogger(IsLocalInterceptor.class);
public static final String IS_LOCAL = "IS_LOCAL";
@@ -60,31 +66,37 @@
{
Object oid = invocation.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
Container container = Ejb3Registry.getContainer(oid.toString());
- Invocation copy = (Invocation) new MarshalledObjectForLocalCalls(invocation).get();
- copy.getMetaData().addMetaData(IS_LOCAL, IS_LOCAL, Boolean.TRUE);
- org.jboss.aop.joinpoint.InvocationResponse response = ((Advisor) container).dynamicInvoke(null, copy);
- Map contextInfo = response.getContextInfo();
- if (contextInfo != null)
+
+ return invokeLocal(invocation, container);
+ }
+ return invocation.invokeNext();
+ }
+
+ protected Object invokeLocal(Invocation invocation, Container container) throws Throwable
+ {
+ Invocation copy = (Invocation) new MarshalledObjectForLocalCalls(invocation).get();
+ copy.getMetaData().addMetaData(IS_LOCAL, IS_LOCAL, Boolean.TRUE);
+ org.jboss.aop.joinpoint.InvocationResponse response = ((Advisor) container).dynamicInvoke(null, copy);
+ Map contextInfo = response.getContextInfo();
+ if (contextInfo != null)
+ {
+ MarshalledObjectForLocalCalls wrappedException = (MarshalledObjectForLocalCalls) response.getContextInfo().get(IS_LOCAL_EXCEPTION);
+ if (wrappedException != null)
{
- MarshalledObjectForLocalCalls wrappedException = (MarshalledObjectForLocalCalls) response.getContextInfo().get(IS_LOCAL_EXCEPTION);
- if (wrappedException != null)
- {
- throw (Throwable) wrappedException.get();
- }
+ throw (Throwable) wrappedException.get();
}
- invocation.setResponseContextInfo(response.getContextInfo());
- MarshalledObjectForLocalCalls wrapped = (MarshalledObjectForLocalCalls) response.getResponse();
- Object rtn = null;
- if (wrapped != null)
- {
- rtn = wrapped.get();
- }
- return rtn;
}
- return invocation.invokeNext();
+ invocation.setResponseContextInfo(response.getContextInfo());
+ MarshalledObjectForLocalCalls wrapped = (MarshalledObjectForLocalCalls) response.getResponse();
+ Object rtn = null;
+ if (wrapped != null)
+ {
+ rtn = wrapped.get();
+ }
+ return rtn;
}
- private boolean isLocal()
+ protected boolean isLocal()
{
return stamp == marshalledStamp;
}
Modified: branches/Branch_4_2/ejb3/src/resources/ejb3-interceptors-aop.xml
===================================================================
--- branches/Branch_4_2/ejb3/src/resources/ejb3-interceptors-aop.xml 2007-03-25 14:48:20 UTC (rev 61666)
+++ branches/Branch_4_2/ejb3/src/resources/ejb3-interceptors-aop.xml 2007-03-25 14:56:32 UTC (rev 61667)
@@ -8,6 +8,7 @@
<interceptor class="org.jboss.aspects.security.SecurityClientInterceptor" scope="PER_VM"/>
<interceptor class="org.jboss.aspects.tx.ClientTxPropagationInterceptor" scope="PER_VM"/>
<interceptor class="org.jboss.ejb3.remoting.IsLocalInterceptor" scope="PER_VM"/>
+ <interceptor class="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor" scope="PER_VM"/>
<interceptor class="org.jboss.aspects.remoting.ClusterChooserInterceptor" scope="PER_VM"/>
<interceptor class="org.jboss.aspects.tx.TxPropagationInterceptor" scope="PER_VM"/>
@@ -48,7 +49,7 @@
</stack>
<stack name="ClusteredStatelessSessionClientInterceptors">
- <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
<interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
@@ -56,7 +57,7 @@
</stack>
<stack name="ClusteredStatefulSessionClientInterceptors">
- <interceptor-ref name="org.jboss.ejb3.remoting.IsLocalInterceptor"/>
+ <interceptor-ref name="org.jboss.ejb3.remoting.ClusteredIsLocalInterceptor"/>
<interceptor-ref name="org.jboss.aspects.security.SecurityClientInterceptor"/>
<interceptor-ref name="org.jboss.aspects.tx.ClientTxPropagationInterceptor"/>
<interceptor-ref name="org.jboss.aspects.remoting.ClusterChooserInterceptor"/>
More information about the jboss-cvs-commits
mailing list