[jboss-cvs] JBossAS SVN: r111666 - in projects/ejb3/branches/jboss-ejb3-core-1.3/src/main: java/org/jboss/ejb3/core/timer and 3 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jun 24 07:38:18 EDT 2011
Author: wolfc
Date: 2011-06-24 07:38:17 -0400 (Fri, 24 Jun 2011)
New Revision: 111666
Added:
projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/
projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/EnlistTimerInterceptor.java
projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/TimerCallbackInvocationHelper.java
Modified:
projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java
projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/resources/ejb3-interceptors-aop.xml
Log:
JBPAPP-4656 / EJBTHREE-2035: upported fix for Timer callback rollback
Added: projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/EnlistTimerInterceptor.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/EnlistTimerInterceptor.java (rev 0)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/EnlistTimerInterceptor.java 2011-06-24 11:38:17 UTC (rev 111666)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2011, 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.core.timer;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.ejb3.aop.AbstractInterceptor;
+import org.jboss.ejb3.tx.TxUtil;
+import org.jboss.logging.Logger;
+
+import javax.ejb.Timer;
+import javax.transaction.Status;
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+
+import static org.jboss.ejb3.core.timer.TimerCallbackInvocationHelper.getTimer;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class EnlistTimerInterceptor extends AbstractInterceptor
+{
+ private static final Logger log = Logger.getLogger(EnlistTimerInterceptor.class);
+
+ private final TransactionManager tm;
+
+ public EnlistTimerInterceptor()
+ {
+ this.tm = TxUtil.getTransactionManager();
+ }
+
+ @Override
+ public Object invoke(Invocation invocation) throws Throwable
+ {
+ final Timer timer = getTimer(invocation);
+ if (timer == null)
+ throw new IllegalStateException("EJBTHREE-2035: timer not set on invocation");
+ if (timer instanceof Synchronization)
+ {
+ final Transaction tx = getTransaction();
+ if (tx != null && tx.getStatus() != Status.STATUS_MARKED_ROLLBACK)
+ {
+ tx.registerSynchronization((Synchronization) timer);
+ }
+ }
+ else
+ log.warn("EJBTHREE-2035: Timer does not implement Synchronization, transaction semantics will not work");
+ return invocation.invokeNext();
+ }
+
+ private Transaction getTransaction() throws SystemException
+ {
+ return tm.getTransaction();
+ }
+}
Added: projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/TimerCallbackInvocationHelper.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/TimerCallbackInvocationHelper.java (rev 0)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/core/timer/TimerCallbackInvocationHelper.java 2011-06-24 11:38:17 UTC (rev 111666)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright (c) 2011, 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.core.timer;
+
+import org.jboss.aop.joinpoint.Invocation;
+import org.jboss.aop.util.PayloadKey;
+
+import javax.ejb.Timer;
+
+/**
+ * @author <a href="cdewolf at redhat.com">Carlo de Wolf</a>
+ */
+public class TimerCallbackInvocationHelper
+{
+ private static final String TAG = Timer.class.getSimpleName();
+ private static final String ATTR = TAG;
+
+ public static Timer getTimer(final Invocation invocation)
+ {
+ return (Timer) invocation.getMetaData(TAG, ATTR);
+ }
+
+ public static void setTimer(final Invocation invocation, final Timer timer)
+ {
+ invocation.getMetaData().addMetaData(TAG, ATTR, timer, PayloadKey.TRANSIENT);
+ }
+}
Modified: projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java 2011-06-24 09:49:05 UTC (rev 111665)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/mdb/MessagingContainer.java 2011-06-24 11:38:17 UTC (rev 111666)
@@ -21,22 +21,6 @@
*/
package org.jboss.ejb3.mdb;
-import java.io.Serializable;
-import java.lang.reflect.Method;
-import java.util.Hashtable;
-import java.util.Map;
-
-import javax.ejb.ActivationConfigProperty;
-import javax.ejb.EJBException;
-import javax.ejb.Timer;
-import javax.jms.Destination;
-import javax.jms.Queue;
-import javax.jms.Topic;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-import javax.naming.Context;
-import javax.naming.NamingException;
-
import org.jboss.aop.Domain;
import org.jboss.aop.MethodInfo;
import org.jboss.aop.advice.Interceptor;
@@ -59,6 +43,22 @@
import org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData;
import org.jboss.metadata.ejb.spec.NamedMethodMetaData;
+import javax.ejb.ActivationConfigProperty;
+import javax.ejb.EJBException;
+import javax.ejb.Timer;
+import javax.jms.Destination;
+import javax.jms.Queue;
+import javax.jms.Topic;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+import javax.naming.Context;
+import javax.naming.NamingException;
+import java.lang.reflect.Method;
+import java.util.Hashtable;
+import java.util.Map;
+
+import static org.jboss.ejb3.core.timer.TimerCallbackInvocationHelper.setTimer;
+
/**
* @version <tt>$Revision$</tt>
* @author <a href="mailto:bdecoste at jboss.com">William DeCoste</a>
@@ -669,6 +669,7 @@
Interceptor[] timeoutMethodAOPInterceptors = this.getInterceptors(info.getJoinpoint(),MDB_TIMEOUT_METHOD_AOP_INTERCEPTOR_STACK_NAME);
// now create an invocation for the method info and the timeout method interceptors
EJBContainerInvocation nextInvocation = new MessageContainerInvocation(info, timeoutMethodAOPInterceptors);
+ setTimer(nextInvocation, timer);
nextInvocation.setAdvisor(getAdvisor());
nextInvocation.setArguments(args);
nextInvocation.invokeNext();
Modified: projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2011-06-24 09:49:05 UTC (rev 111665)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/java/org/jboss/ejb3/stateless/StatelessContainer.java 2011-06-24 11:38:17 UTC (rev 111666)
@@ -59,6 +59,7 @@
import org.jboss.ejb3.common.registrar.spi.Ejb3RegistrarLocator;
import org.jboss.ejb3.core.proxy.spi.CurrentRemoteProxyFactory;
import org.jboss.ejb3.core.proxy.spi.EJB2RemoteProxyFactory;
+import org.jboss.ejb3.core.timer.EnlistTimerInterceptor;
import org.jboss.ejb3.proxy.clustered.objectstore.ClusteredObjectStoreBindings;
import org.jboss.ejb3.proxy.factory.ProxyFactoryHelper;
import org.jboss.ejb3.proxy.impl.EJBMetaDataImpl;
@@ -90,7 +91,9 @@
import org.jboss.wsf.spi.invocation.integration.InvocationContextCallback;
import org.jboss.wsf.spi.invocation.integration.ServiceEndpointContainer;
+import static org.jboss.ejb3.core.timer.TimerCallbackInvocationHelper.setTimer;
+
/**
* Comment
*
@@ -677,6 +680,7 @@
Interceptor[] timeoutMethodAOPInterceptors = this.getInterceptors(info.getJoinpoint(),SLSB_TIMEOUT_METHOD_AOP_INTERCEPTOR_STACK_NAME);
// now create an invocation for the method info and the timeout method interceptors
EJBContainerInvocation nextInvocation = new SessionContainerInvocation(null, info, timeoutMethodAOPInterceptors);
+ setTimer(nextInvocation, timer);
nextInvocation.setAdvisor(getAdvisor());
nextInvocation.setArguments(args);
nextInvocation.invokeNext();
Modified: projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/resources/ejb3-interceptors-aop.xml
===================================================================
--- projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/resources/ejb3-interceptors-aop.xml 2011-06-24 09:49:05 UTC (rev 111665)
+++ projects/ejb3/branches/jboss-ejb3-core-1.3/src/main/resources/ejb3-interceptors-aop.xml 2011-06-24 11:38:17 UTC (rev 111666)
@@ -70,6 +70,7 @@
<interceptor class="org.jboss.ejb3.BlockContainerShutdownInterceptor" scope="PER_VM"/>
<interceptor factory="org.jboss.ejb3.connectionmanager.CachedConnectionInterceptorFactory" scope="PER_CLASS"/>
<interceptor class="org.jboss.ejb3.interceptor.EJB3TCCLInterceptor" scope="PER_VM"/>
+ <interceptor name="EnlistTimerInterceptor" class="org.jboss.ejb3.core.timer.EnlistTimerInterceptor" scope="PER_VM"/>
<!--
INTERCEPTORS
-->
@@ -152,6 +153,7 @@
<interceptor-ref name="org.jboss.aspects.currentinvocation.CurrentInvocationInterceptor"/>
<interceptor-ref name="CurrentInvocationContextInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.BlockContainerShutdownInterceptor"/>
+ <interceptor-ref name="EnlistTimerInterceptor"/>
</stack>
</domain>
@@ -205,6 +207,7 @@
<interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="EnlistTimerInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
</stack>
@@ -425,6 +428,7 @@
<interceptor-ref name="org.jboss.ejb3.stateless.StatelessInstanceInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.tx.BMTTxInterceptorFactory"/>
<interceptor-ref name="org.jboss.ejb3.AllowedOperationsInterceptor"/>
+ <interceptor-ref name="EnlistTimerInterceptor"/>
<interceptor-ref name="org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor"/>
More information about the jboss-cvs-commits
mailing list