[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...
Gavin King
gavin.king at jboss.com
Wed May 30 16:27:07 EDT 2007
User: gavin
Date: 07/05/30 16:27:06
Modified: src/main/org/jboss/seam/core Events.java
Added: src/main/org/jboss/seam/core
LocalTransactionListener.java
TransactionListener.java
Log:
move em back
Revision Changes Path
1.25 +0 -2 jboss-seam/src/main/org/jboss/seam/core/Events.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Events.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/Events.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- Events.java 30 May 2007 20:15:59 -0000 1.24
+++ Events.java 30 May 2007 20:27:06 -0000 1.25
@@ -18,8 +18,6 @@
import org.jboss.seam.core.Init.ObserverMethodExpression;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
-import org.jboss.seam.transaction.LocalTransactionListener;
-import org.jboss.seam.transaction.TransactionListener;
@Scope(ScopeType.STATELESS)
@Intercept(NEVER)
1.3 +0 -0 jboss-seam/src/main/org/jboss/seam/core/LocalTransactionListener.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: LocalTransactionListener.java
===================================================================
RCS file: LocalTransactionListener.java
diff -N LocalTransactionListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ LocalTransactionListener.java 30 May 2007 20:27:06 -0000 1.3
@@ -0,0 +1,10 @@
+package org.jboss.seam.core;
+
+import javax.ejb.Local;
+
+ at Local
+public interface LocalTransactionListener
+{
+ public void scheduleEvent(String type, Object... parameters);
+ public void destroy();
+}
1.5 +0 -0 jboss-seam/src/main/org/jboss/seam/core/TransactionListener.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: TransactionListener.java
===================================================================
RCS file: TransactionListener.java
diff -N TransactionListener.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ TransactionListener.java 30 May 2007 20:27:06 -0000 1.5
@@ -0,0 +1,94 @@
+package org.jboss.seam.core;
+
+import static org.jboss.seam.annotations.Install.BUILT_IN;
+
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.ejb.EJBException;
+import javax.ejb.Remove;
+import javax.ejb.SessionSynchronization;
+import javax.ejb.Stateful;
+
+import org.jboss.seam.Component;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.Install;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.contexts.Contexts;
+
+/**
+ * Temporary solution for getting JTA transaction lifecycle
+ * callbacks. Once all appservers support the new EE5 APIs,
+ * this will be removed.
+ *
+ * @author Gavin King
+ *
+ */
+ at Stateful
+ at Scope(ScopeType.EVENT)
+ at Name("org.jboss.seam.core.transactionListener")
+ at Install(value=false, precedence=BUILT_IN)
+public class TransactionListener implements LocalTransactionListener, SessionSynchronization
+{
+ static class Event
+ {
+ private String type;
+ private Object[] parameters;
+
+ public Event(String type, Object[] parameters)
+ {
+ this.type = type;
+ this.parameters = parameters;
+ }
+ public void call()
+ {
+ Events.instance().raiseEvent(type, parameters);
+ }
+ }
+
+ private List<Event> events = new ArrayList<Event>();
+
+ public static LocalTransactionListener instance()
+ {
+ if ( !Contexts.isEventContextActive() )
+ {
+ throw new IllegalStateException("no event context active");
+ }
+ return (LocalTransactionListener) Component.getInstance(TransactionListener.class, ScopeType.EVENT);
+ }
+
+ public void afterBegin() throws EJBException, RemoteException
+ {
+ }
+
+ public void scheduleEvent(String type, Object... parameters)
+ {
+ events.add( new Event(type, parameters) );
+ }
+
+ public void afterCompletion(boolean success) throws EJBException, RemoteException
+ {
+ try
+ {
+ if (success)
+ {
+ for (Event event: events) event.call();
+ }
+ }
+ finally
+ {
+ events.clear();
+ }
+ }
+
+ public void beforeCompletion() throws EJBException, RemoteException
+ {
+ }
+
+ @Remove @Destroy
+ public void destroy() {}
+
+}
More information about the jboss-cvs-commits
mailing list