[jboss-cvs] JBossAS SVN: r85621 - in projects/webbeans-ri-int/trunk: microcontainer/src/test/java/org/jboss/test/webbeans/deployers/support and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Mar 8 17:43:56 EDT 2009
Author: petemuir
Date: 2009-03-08 17:43:55 -0400 (Sun, 08 Mar 2009)
New Revision: 85621
Removed:
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/transaction/TransactionSynchronizedRunnable.java
Modified:
projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/transaction/JBossTransactionServices.java
projects/webbeans-ri-int/trunk/microcontainer/src/test/java/org/jboss/test/webbeans/deployers/support/MockTransactionServices.java
Log:
WBRI-167
Modified: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/transaction/JBossTransactionServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/transaction/JBossTransactionServices.java 2009-03-08 19:06:44 UTC (rev 85620)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/transaction/JBossTransactionServices.java 2009-03-08 21:43:55 UTC (rev 85621)
@@ -1,123 +1,92 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.webbeans.integration.transaction;
-
-import javax.inject.ExecutionException;
-import static javax.transaction.Status.STATUS_ACTIVE;
-import javax.transaction.SystemException;
-import javax.transaction.TransactionManager;
-
-import org.jboss.webbeans.transaction.spi.TransactionServices;
-
-/**
- * JBoss AS implementation of TransactionServices. The transaction manager
- * for the application server is injected directly into this bean and
- * used to provide the services.
- *
- * @author David Allen
- * @author ales.justin at jboss.org
- *
- */
-public class JBossTransactionServices implements TransactionServices
-{
- /** The TM */
- protected TransactionManager transactionManager;
-
- /* (non-Javadoc)
- * @see org.jboss.webbeans.transaction.spi.TransactionServices#executeAfterTransactionCompletion(java.lang.Runnable)
- */
- public void executeAfterTransactionCompletion(Runnable task)
- {
- try
- {
- getTransactionManager().getTransaction().registerSynchronization(new TransactionSynchronizedRunnable(task, false));
- }
- catch (Exception e)
- {
- throw new ExecutionException("Failed to register task " + task + " for after transaction completion", e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.jboss.webbeans.transaction.spi.TransactionServices#executeAfterTransactionCompletion(java.lang.Runnable, org.jboss.webbeans.transaction.spi.TransactionServices.Status)
- */
- public void executeAfterTransactionCompletion(Runnable task, Status desiredStatus)
- {
- try
- {
- getTransactionManager().getTransaction().registerSynchronization(new TransactionSynchronizedRunnable(task, desiredStatus));
- }
- catch (Exception e)
- {
- throw new ExecutionException("Failed to register task " + task + " for after transaction completion, status " + desiredStatus, e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.jboss.webbeans.transaction.spi.TransactionServices#executeBeforeTransactionCompletion(java.lang.Runnable)
- */
- public void executeBeforeTransactionCompletion(Runnable task)
- {
- try
- {
- getTransactionManager().getTransaction().registerSynchronization(new TransactionSynchronizedRunnable(task, true));
- }
- catch (Exception e)
- {
- throw new ExecutionException("Failed to register task " + task + " for before transaction completion", e);
- }
- }
-
- public boolean isTransactionActive()
- {
- try
- {
- return getTransactionManager().getStatus() == STATUS_ACTIVE;
- }
- catch (SystemException e)
- {
- throw new ExecutionException("Failed to determine transaction status", e);
- }
- }
-
- /**
- * Get transaction manager. \
- *
- * It might throw IllegalArgumentException if it's not yet configured
- * as we inject it via callback - only available in deploy/ when TM gets deployed.
- *
- * @return the transaction manager
- */
- protected TransactionManager getTransactionManager()
- {
- if (transactionManager == null)
- throw new IllegalArgumentException("Transaction manager is not yet set.");
-
- return transactionManager;
- }
-
- /**
- * Set transaction manager.
- *
- * @param transactionManager the transaction manager
- */
- public void setTransactionManager(TransactionManager transactionManager)
- {
- this.transactionManager = transactionManager;
- }
-}
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jboss.webbeans.integration.transaction;
+
+import javax.inject.ExecutionException;
+import static javax.transaction.Status.STATUS_ACTIVE;
+
+import javax.transaction.Synchronization;
+import javax.transaction.SystemException;
+import javax.transaction.TransactionManager;
+
+import org.jboss.webbeans.transaction.spi.TransactionServices;
+
+/**
+ * JBoss AS implementation of TransactionServices. The transaction manager for
+ * the application server is injected directly into this bean and used to
+ * provide the services.
+ *
+ * @author David Allen
+ * @author ales.justin at jboss.org
+ *
+ */
+public class JBossTransactionServices implements TransactionServices
+{
+ /** The TM */
+ protected TransactionManager transactionManager;
+
+ public boolean isTransactionActive()
+ {
+ try
+ {
+ return getTransactionManager().getStatus() == STATUS_ACTIVE;
+ }
+ catch (SystemException e)
+ {
+ throw new ExecutionException("Failed to determine transaction status", e);
+ }
+ }
+
+ /**
+ * Get transaction manager.
+ *
+ * It might throw IllegalArgumentException if it's not yet configured as we
+ * inject it via callback - only available in deploy/ when TM gets deployed.
+ *
+ * @return the transaction manager
+ */
+ protected TransactionManager getTransactionManager()
+ {
+ if (transactionManager == null)
+ throw new IllegalArgumentException("Transaction manager is not yet set.");
+
+ return transactionManager;
+ }
+
+ /**
+ * Set transaction manager.
+ *
+ * @param transactionManager the transaction manager
+ */
+ public void setTransactionManager(TransactionManager transactionManager)
+ {
+ this.transactionManager = transactionManager;
+ }
+
+ public void registerSynchronization(Synchronization synchronizedObserver)
+ {
+ try
+ {
+ getTransactionManager().getTransaction().registerSynchronization(synchronizedObserver);
+ }
+ catch (Exception e)
+ {
+ throw new ExecutionException("Failed to register synchronization " + synchronizedObserver + " for current transaction", e);
+ }
+ }
+}
Deleted: projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/transaction/TransactionSynchronizedRunnable.java
===================================================================
--- projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/transaction/TransactionSynchronizedRunnable.java 2009-03-08 19:06:44 UTC (rev 85620)
+++ projects/webbeans-ri-int/trunk/ejb/src/main/java/org/jboss/webbeans/integration/transaction/TransactionSynchronizedRunnable.java 2009-03-08 21:43:55 UTC (rev 85621)
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jboss.webbeans.integration.transaction;
-
-import static javax.transaction.Status.STATUS_COMMITTED;
-
-import javax.transaction.Synchronization;
-
-import org.jboss.webbeans.transaction.spi.TransactionServices;
-
-/**
- * A JTA transaction sychronization which wraps a Runnable.
- *
- * @author David Allen
- *
- */
-public class TransactionSynchronizedRunnable implements Synchronization
-{
- private final TransactionServices.Status desiredStatus;
- private final Runnable task;
- private final boolean before;
-
- public TransactionSynchronizedRunnable(Runnable task, boolean before)
- {
- this(task, TransactionServices.Status.ALL, before);
- }
-
- public TransactionSynchronizedRunnable(Runnable task, TransactionServices.Status desiredStatus)
- {
- this(task, desiredStatus, false); // Status is only applicable after the transaction
- }
-
- private TransactionSynchronizedRunnable(Runnable task, TransactionServices.Status desiredStatus, boolean before)
- {
- this.task = task;
- this.desiredStatus = desiredStatus;
- this.before = before;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.transaction.Synchronization#afterCompletion(int)
- */
- public void afterCompletion(int status)
- {
- if ((desiredStatus == TransactionServices.Status.SUCCESS && status == STATUS_COMMITTED) || (desiredStatus == TransactionServices.Status.FAILURE && status != STATUS_COMMITTED) || (desiredStatus == TransactionServices.Status.ALL))
- {
- task.run();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see javax.transaction.Synchronization#beforeCompletion()
- */
- public void beforeCompletion()
- {
- if (before)
- {
- task.run();
- }
- }
-
-}
Modified: projects/webbeans-ri-int/trunk/microcontainer/src/test/java/org/jboss/test/webbeans/deployers/support/MockTransactionServices.java
===================================================================
--- projects/webbeans-ri-int/trunk/microcontainer/src/test/java/org/jboss/test/webbeans/deployers/support/MockTransactionServices.java 2009-03-08 19:06:44 UTC (rev 85620)
+++ projects/webbeans-ri-int/trunk/microcontainer/src/test/java/org/jboss/test/webbeans/deployers/support/MockTransactionServices.java 2009-03-08 21:43:55 UTC (rev 85621)
@@ -1,47 +1,41 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.test.webbeans.deployers.support;
-
-import org.jboss.webbeans.transaction.spi.TransactionServices;
-
-/**
- * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
- */
-public class MockTransactionServices implements TransactionServices
-{
- public void executeBeforeTransactionCompletion(Runnable task)
- {
- }
-
- public void executeAfterTransactionCompletion(Runnable task)
- {
- }
-
- public void executeAfterTransactionCompletion(Runnable task, Status desiredStatus)
- {
- }
-
- public boolean isTransactionActive()
- {
- return false;
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.test.webbeans.deployers.support;
+
+import javax.transaction.Synchronization;
+
+import org.jboss.webbeans.transaction.spi.TransactionServices;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class MockTransactionServices implements TransactionServices
+{
+ public boolean isTransactionActive()
+ {
+ return false;
+ }
+
+ public void registerSynchronization(Synchronization synchronizedObserver)
+ {
+ }
}
\ No newline at end of file
More information about the jboss-cvs-commits
mailing list