diff --git a/api/src/main/java/org/jboss/seam/transaction/DefaultTransaction.java b/api/src/main/java/org/jboss/seam/transaction/DefaultTransaction.java
deleted file mode 100644
index 9537859..0000000
--- a/api/src/main/java/org/jboss/seam/transaction/DefaultTransaction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-import javax.transaction.UserTransaction;
-
-/**
- * Qualifier that is used to denote the SeamTransaction implementation that is
- * used by the transaction interceptor and other seam transaction services.
- *
- * A qualifier is necessary to prevent the seam provided {@link UserTransaction}
- * wrapper {@link SeamTransaction} from conflicting with the container provided
- * built-in UserTransaction
- *
- * @author Stuart Douglas
- */
-@Qualifier
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
-public @interface DefaultTransaction {
- ;
-}
diff --git a/api/src/main/java/org/jboss/seam/transaction/SeamApplicationException.java b/api/src/main/java/org/jboss/seam/transaction/SeamApplicationException.java
deleted file mode 100644
index 26c1206..0000000
--- a/api/src/main/java/org/jboss/seam/transaction/SeamApplicationException.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.ejb.ApplicationException;
-
-/**
- * Seam Annotation for identifying an Exception class as an Application
- * Exception, which does not cause a transaction rollback.
- *
- * This will NOT control the behavior of EJB container managed transactions. To
- * avoid confusion, it is recommended that this annotation is only used outside
- * an EE environment when @{link {@link ApplicationException} is not available.
- */
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-@Documented
-@Inherited
-public @interface SeamApplicationException {
- /**
- * Indicates whether the application exception designation should apply to
- * subclasses of the annotated exception class.
- */
- boolean inherited() default true;
-
- /**
- * Indicates whether the container should cause the transaction to rollback
- * when the exception is thrown.
- */
- boolean rollback() default false;
-}
diff --git a/api/src/main/java/org/jboss/seam/transaction/SeamTransaction.java b/api/src/main/java/org/jboss/seam/transaction/SeamTransaction.java
deleted file mode 100644
index 34340b3..0000000
--- a/api/src/main/java/org/jboss/seam/transaction/SeamTransaction.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.persistence.EntityManager;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-
-/**
- * Extends the standard UserTransaction interface with a couple of helpful
- * methods.
- *
- * @author Gavin King
- */
-public interface SeamTransaction extends javax.transaction.UserTransaction {
-
- public boolean isActive() throws SystemException;
-
- public boolean isActiveOrMarkedRollback() throws SystemException;
-
- public boolean isRolledBackOrMarkedRollback() throws SystemException;
-
- public boolean isMarkedRollback() throws SystemException;
-
- public boolean isNoTransaction() throws SystemException;
-
- public boolean isRolledBack() throws SystemException;
-
- public boolean isCommitted() throws SystemException;
-
- public boolean isConversationContextRequired();
-
- public abstract void registerSynchronization(Synchronization sync);
-
- public void enlist(EntityManager entityManager) throws SystemException;
-}
diff --git a/api/src/main/java/org/jboss/seam/transaction/TransactionPropagation.java b/api/src/main/java/org/jboss/seam/transaction/TransactionPropagation.java
deleted file mode 100644
index b0183e2..0000000
--- a/api/src/main/java/org/jboss/seam/transaction/TransactionPropagation.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-/**
- * @author Dan Allen
- */
-public enum TransactionPropagation {
- /**
- * A transaction will be started if one is not currently active.
- */
- REQUIRED,
- /**
- * A transaction will not be started if there is not one currently active,
- * however this method supports running inside an existing transaction
- */
- SUPPORTS,
- /**
- * Requires a transaction to be active. If no transaction is active an
- * {@link IllegalStateException} is thrown
- */
- MANDATORY,
- /**
- * Requires no transaction to be active. If a transaction is active an
- * {@link IllegalStateException} is thrown
- */
- NEVER;
-
- public boolean isNewTransactionRequired(boolean transactionActive) {
- switch (this) {
- case REQUIRED:
- return !transactionActive;
- case SUPPORTS:
- return false;
- case MANDATORY:
- if (!transactionActive) {
- throw new IllegalStateException("No transaction active on call to MANDATORY method");
- } else {
- return false;
- }
- case NEVER:
- if (transactionActive) {
- throw new IllegalStateException("Transaction active on call to NEVER method");
- } else {
- return false;
- }
- default:
- throw new IllegalArgumentException();
- }
- }
-}
\ No newline at end of file
diff --git a/api/src/main/java/org/jboss/seam/transaction/TransactionScoped.java b/api/src/main/java/org/jboss/seam/transaction/TransactionScoped.java
deleted file mode 100644
index 319fbfa..0000000
--- a/api/src/main/java/org/jboss/seam/transaction/TransactionScoped.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.enterprise.context.NormalScope;
-
-/**
- * CDI Scope that spans the current transaction
- *
- * @author Stuart Douglas
- */
-@Documented
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
-@NormalScope(passivating = false)
-public @interface TransactionScoped {
-
-}
diff --git a/api/src/main/java/org/jboss/seam/transaction/Transactional.java b/api/src/main/java/org/jboss/seam/transaction/Transactional.java
deleted file mode 100644
index c10e349..0000000
--- a/api/src/main/java/org/jboss/seam/transaction/Transactional.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Demarcates transaction boundaries
- *
- * Note that is you are using seam managed transactions seam will automatically
- * manage your transactions for you, rendering this unnecessary
- *
- * Note that this annotation is not actually an intercepter binding. It is
- * replaced by an intercepter binding at runtime by a portable extension in the
- * ProcessAnnotatedType phase
- *
- * @author Dan Allen
- */
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD, ElementType.TYPE})
-public @interface Transactional {
- /**
- * The transaction propagation type.
- *
- * @return REQUIRED by default
- */
- TransactionPropagation value() default TransactionPropagation.REQUIRED;
-}
\ No newline at end of file
diff --git a/api/src/main/java/org/jboss/seam/transaction/literal/DefaultTransactionLiteral.java b/api/src/main/java/org/jboss/seam/transaction/literal/DefaultTransactionLiteral.java
deleted file mode 100644
index bcd5b25..0000000
--- a/api/src/main/java/org/jboss/seam/transaction/literal/DefaultTransactionLiteral.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction.literal;
-
-import javax.enterprise.util.AnnotationLiteral;
-
-import org.jboss.seam.transaction.DefaultTransaction;
-
-public class DefaultTransactionLiteral extends AnnotationLiteral implements DefaultTransaction {
- private DefaultTransactionLiteral() {
- }
-
- public static final DefaultTransactionLiteral INSTANCE = new DefaultTransactionLiteral();
-
-}
\ No newline at end of file
diff --git a/api/src/main/java/org/jboss/seam/transaction/literal/TransactionScopedLiteral.java b/api/src/main/java/org/jboss/seam/transaction/literal/TransactionScopedLiteral.java
deleted file mode 100644
index 994bab3..0000000
--- a/api/src/main/java/org/jboss/seam/transaction/literal/TransactionScopedLiteral.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction.literal;
-
-import javax.enterprise.util.AnnotationLiteral;
-
-import org.jboss.seam.transaction.TransactionScoped;
-
-public class TransactionScopedLiteral extends AnnotationLiteral implements TransactionScoped {
- private TransactionScopedLiteral() {
- }
-
- public static TransactionScopedLiteral INSTANCE = new TransactionScopedLiteral();
-
-}
\ No newline at end of file
diff --git a/combined/pom.xml b/combined/pom.xml
deleted file mode 100644
index 8b539eb..0000000
--- a/combined/pom.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
- 4.0.0
-
-
- org.jboss.seam.persistence
- seam-persistence-parent
- 3.0.1-SNAPSHOT
- ../pom.xml
-
-
- seam-persistence
-
- jar
- Seam Persistence
-
- ${project.parent.url}
-
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
- true
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
-
-
- package
-
- shade
-
-
- true
- true
-
-
- org.jboss.seam.persistence:*
-
-
-
-
-
-
-
-
-
-
-
-
- org.jboss.seam.persistence
- seam-persistence-api
-
-
-
- org.jboss.seam.persistence
- seam-persistence-impl
-
-
-
-
-
diff --git a/dist/pom.xml b/dist/pom.xml
index 7e01d2c..91f3fb3 100644
--- a/dist/pom.xml
+++ b/dist/pom.xml
@@ -27,12 +27,6 @@
true
-
- org.jboss.seam.persistence
- seam-persistence-impl
- true
-
-
org.jboss.seam.persistence
seam-persistence
@@ -49,7 +43,7 @@
org.jboss.seam.persistence
- seam-persistence-impl
+ seam-persistence
${project.version}
sources
true
diff --git a/dist/src/main/assembly/assembly.xml b/dist/src/main/assembly/assembly.xml
index 5d31de1..8a1a75e 100644
--- a/dist/src/main/assembly/assembly.xml
+++ b/dist/src/main/assembly/assembly.xml
@@ -88,7 +88,7 @@
false
org.jboss.seam.persistence:seam-persistence-api:*:sources
- org.jboss.seam.persistence:seam-persistence-impl:*:sources
+ org.jboss.seam.persistence:seam-persistence:*:sources
diff --git a/impl/pom.xml b/impl/pom.xml
index 72cc8cf..2739211 100644
--- a/impl/pom.xml
+++ b/impl/pom.xml
@@ -9,7 +9,7 @@
../pom.xml
- seam-persistence-impl
+ seam-persistence
jar
Seam Persistence Implementation
diff --git a/impl/src/main/java/org/jboss/seam/transaction/AbstractUserTransaction.java b/impl/src/main/java/org/jboss/seam/transaction/AbstractUserTransaction.java
deleted file mode 100644
index 1aa8b70..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/AbstractUserTransaction.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.persistence.EntityManager;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-
-import static javax.transaction.Status.STATUS_ACTIVE;
-import static javax.transaction.Status.STATUS_COMMITTED;
-import static javax.transaction.Status.STATUS_MARKED_ROLLBACK;
-import static javax.transaction.Status.STATUS_NO_TRANSACTION;
-import static javax.transaction.Status.STATUS_ROLLEDBACK;
-
-/**
- * Base implementation of UserTransaction
- *
- * @author Gavin King
- */
-public abstract class AbstractUserTransaction implements SeamTransaction {
-
- private Synchronizations synchronizations;
-
- public boolean isActive() throws SystemException {
- return getStatus() == STATUS_ACTIVE;
- }
-
- public boolean isActiveOrMarkedRollback() throws SystemException {
- int status = getStatus();
- return status == STATUS_ACTIVE || status == STATUS_MARKED_ROLLBACK;
- }
-
- public boolean isRolledBackOrMarkedRollback() throws SystemException {
- int status = getStatus();
- return status == STATUS_ROLLEDBACK || status == STATUS_MARKED_ROLLBACK;
- }
-
- public boolean isMarkedRollback() throws SystemException {
- return getStatus() == STATUS_MARKED_ROLLBACK;
- }
-
- public boolean isNoTransaction() throws SystemException {
- return getStatus() == STATUS_NO_TRANSACTION;
- }
-
- public boolean isRolledBack() throws SystemException {
- return getStatus() == STATUS_ROLLEDBACK;
- }
-
- public boolean isCommitted() throws SystemException {
- return getStatus() == STATUS_COMMITTED;
- }
-
- public boolean isConversationContextRequired() {
- return false;
- }
-
- public abstract void registerSynchronization(Synchronization sync);
-
- public void enlist(EntityManager entityManager) throws SystemException {
- if (isActiveOrMarkedRollback()) {
- entityManager.joinTransaction();
- }
- }
-
- public Synchronizations getSynchronizations() {
- return synchronizations;
- }
-
- protected void setSynchronizations(Synchronizations synchronizations) {
- this.synchronizations = synchronizations;
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/CMTTransaction.java b/impl/src/main/java/org/jboss/seam/transaction/CMTTransaction.java
deleted file mode 100644
index 7b135aa..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/CMTTransaction.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.ejb.EJBContext;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-import javax.transaction.UserTransaction;
-
-import org.jboss.seam.solder.core.Veto;
-
-/**
- * Wraps EJBContext transaction management in a UserTransaction interface. Note
- * that container managed transactions cannot be controlled by the application,
- * so begin(), commit() and rollback() are disallowed in a CMT.
- *
- * @author Mike Youngstrom
- * @author Gavin King
- * @author Stuart Douglas
- */
-@Veto
-public class CMTTransaction extends AbstractUserTransaction {
-
- private final EJBContext ejbContext;
-
- public CMTTransaction(EJBContext ejbContext, Synchronizations sync) {
- setSynchronizations(sync);
- this.ejbContext = ejbContext;
- if (ejbContext == null) {
- throw new IllegalArgumentException("null EJBContext");
- }
- }
-
- public void begin() throws NotSupportedException, SystemException {
- ejbContext.getUserTransaction().begin();
- getSynchronizations().afterTransactionBegin();
- }
-
- public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
- UserTransaction userTransaction = ejbContext.getUserTransaction();
- boolean success = false;
- Synchronizations synchronizations = getSynchronizations();
- synchronizations.beforeTransactionCommit();
- try {
- userTransaction.commit();
- success = true;
- } finally {
- synchronizations.afterTransactionCompletion(success);
- }
- }
-
- public void rollback() throws IllegalStateException, SecurityException, SystemException {
- UserTransaction userTransaction = ejbContext.getUserTransaction();
- try {
- userTransaction.rollback();
- } finally {
- getSynchronizations().afterTransactionCompletion(false);
- }
- }
-
- public int getStatus() throws SystemException {
- try {
- // TODO: not correct for SUPPORTS or NEVER!
- if (!ejbContext.getRollbackOnly()) {
- return Status.STATUS_ACTIVE;
- } else {
- return Status.STATUS_MARKED_ROLLBACK;
- }
- } catch (IllegalStateException ise) {
- try {
- return ejbContext.getUserTransaction().getStatus();
- } catch (IllegalStateException is) {
- return Status.STATUS_NO_TRANSACTION;
- }
- }
- }
-
- public void setRollbackOnly() throws IllegalStateException, SystemException {
- ejbContext.setRollbackOnly();
- }
-
- public void setTransactionTimeout(int timeout) throws SystemException {
- ejbContext.getUserTransaction().setTransactionTimeout(timeout);
- }
-
- @Override
- public void registerSynchronization(Synchronization sync) {
- Synchronizations synchronizations = getSynchronizations();
- if (synchronizations.isAwareOfContainerTransactions()) {
- synchronizations.registerSynchronization(sync);
- } else {
- throw new UnsupportedOperationException("cannot register synchronization with container transaction, use ");
- }
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/DefaultSeamTransaction.java b/impl/src/main/java/org/jboss/seam/transaction/DefaultSeamTransaction.java
deleted file mode 100644
index 3e597a3..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/DefaultSeamTransaction.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.inject.Inject;
-import javax.naming.InitialContext;
-import javax.naming.NameNotFoundException;
-import javax.naming.NamingException;
-import javax.persistence.EntityManager;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-
-import org.jboss.seam.persistence.util.EJBContextUtils;
-import org.jboss.seam.persistence.util.NamingUtils;
-import org.jboss.seam.solder.bean.defaultbean.DefaultBean;
-
-/**
- * Supports injection of a Seam UserTransaction object that wraps the current
- * JTA transaction or EJB container managed transaction.
- *
- * @author Stuart Douglas
- */
-@DefaultBean(SeamTransaction.class)
-@DefaultTransaction
-public class DefaultSeamTransaction implements SeamTransaction {
- @Inject
- private Synchronizations synchronizations;
-
- public void enlist(EntityManager entityManager) throws SystemException {
- getSeamTransaction().enlist(entityManager);
- }
-
- public boolean isActive() throws SystemException {
- return getSeamTransaction().isActive();
- }
-
- public boolean isActiveOrMarkedRollback() throws SystemException {
- return getSeamTransaction().isActiveOrMarkedRollback();
- }
-
- public boolean isCommitted() throws SystemException {
- return getSeamTransaction().isCommitted();
- }
-
- public boolean isConversationContextRequired() {
- return getSeamTransaction().isConversationContextRequired();
- }
-
- public boolean isMarkedRollback() throws SystemException {
- return getSeamTransaction().isMarkedRollback();
- }
-
- public boolean isNoTransaction() throws SystemException {
- return getSeamTransaction().isNoTransaction();
- }
-
- public boolean isRolledBack() throws SystemException {
- return getSeamTransaction().isRolledBack();
- }
-
- public boolean isRolledBackOrMarkedRollback() throws SystemException {
- return getSeamTransaction().isRolledBackOrMarkedRollback();
- }
-
- public void registerSynchronization(Synchronization sync) {
- getSeamTransaction().registerSynchronization(sync);
- }
-
- public void begin() throws NotSupportedException, SystemException {
- getSeamTransaction().begin();
- }
-
- public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
- getSeamTransaction().commit();
- }
-
- public int getStatus() throws SystemException {
- return getSeamTransaction().getStatus();
- }
-
- public void rollback() throws IllegalStateException, SecurityException, SystemException {
- getSeamTransaction().rollback();
- }
-
- public void setRollbackOnly() throws IllegalStateException, SystemException {
- getSeamTransaction().setRollbackOnly();
- }
-
- public void setTransactionTimeout(int seconds) throws SystemException {
- getSeamTransaction().setTransactionTimeout(seconds);
- }
-
- protected SeamTransaction getSeamTransaction() {
- try {
- return createUTTransaction();
- } catch (NameNotFoundException nnfe) {
- try {
- return createCMTTransaction();
- } catch (NameNotFoundException nnfe2) {
- return createNoTransaction();
- } catch (NamingException e) {
- throw new RuntimeException(e);
- }
- } catch (NamingException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected SeamTransaction createNoTransaction() {
- return new NoTransaction();
- }
-
- protected SeamTransaction createCMTTransaction() throws NamingException {
- return new CMTTransaction(EJBContextUtils.getEJBContext(), synchronizations);
- }
-
- protected SeamTransaction createUTTransaction() throws NamingException {
- return new UTTransaction(getUserTransaction(), synchronizations);
- }
-
- protected javax.transaction.UserTransaction getUserTransaction() throws NamingException {
- InitialContext context = NamingUtils.getInitialContext();
- try {
- return (javax.transaction.UserTransaction) context.lookup("java:comp/UserTransaction");
- } catch (NameNotFoundException nnfe) {
- try {
- // Embedded JBoss has no java:comp/UserTransaction
- javax.transaction.UserTransaction ut = (javax.transaction.UserTransaction) context.lookup("UserTransaction");
- ut.getStatus(); // for glassfish, which can return an unusable UT
- return ut;
- } catch (Exception e) {
- throw nnfe;
- }
- }
- }
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/EntityTransaction.java b/impl/src/main/java/org/jboss/seam/transaction/EntityTransaction.java
deleted file mode 100644
index 8c1ae8b..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/EntityTransaction.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import org.jboss.logging.Logger;
-import org.jboss.seam.persistence.DefaultPersistenceProvider;
-import org.jboss.seam.solder.core.Veto;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.persistence.EntityManager;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-
-/**
- * Support for the JPA EntityTransaction API.
- *
- * Adapts JPA transaction management to a Seam UserTransaction interface.For use
- * in non-JTA-capable environments.
- *
- * @author Gavin King
- */
-@ApplicationScoped
-@DefaultTransaction
-@Veto
-public class EntityTransaction extends AbstractUserTransaction {
- private static final Logger log = Logger.getLogger(EntityTransaction.class);
-
- @Inject
- private EntityManager entityManager;
-
- @Inject
- private DefaultPersistenceProvider persistenceProvider;
-
- @Inject
- public void init(Synchronizations sync) {
- setSynchronizations(sync);
- }
-
- public EntityTransaction() {
- }
-
- private javax.persistence.EntityTransaction getDelegate() {
- return entityManager.getTransaction();
- }
-
- public void begin() throws NotSupportedException, SystemException {
- log.debug("beginning JPA resource-local transaction");
- // TODO: translate exceptions that occur into the correct JTA exception
- try {
- getDelegate().begin();
- getSynchronizations().afterTransactionBegin();
- } catch (RuntimeException re) {
- throw re;
- }
- }
-
- public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
- log.debug("committing JPA resource-local transaction");
- javax.persistence.EntityTransaction delegate = getDelegate();
- boolean success = false;
- try {
- if (delegate.getRollbackOnly()) {
- delegate.rollback();
- throw new RollbackException();
- } else {
- getSynchronizations().beforeTransactionCommit();
- delegate.commit();
- success = true;
- }
- } finally {
- getSynchronizations().afterTransactionCompletion(success);
- }
- }
-
- public void rollback() throws IllegalStateException, SecurityException, SystemException {
- log.debug("rolling back JPA resource-local transaction");
- // TODO: translate exceptions that occur into the correct JTA exception
- javax.persistence.EntityTransaction delegate = getDelegate();
- try {
- delegate.rollback();
- } finally {
- getSynchronizations().afterTransactionCompletion(false);
- }
- }
-
- public void setRollbackOnly() throws IllegalStateException, SystemException {
- log.debug("marking JPA resource-local transaction for rollback");
- getDelegate().setRollbackOnly();
- }
-
- public int getStatus() throws SystemException {
- if (getDelegate().isActive()) {
- if (getDelegate().getRollbackOnly()) {
- return Status.STATUS_MARKED_ROLLBACK;
- }
- return Status.STATUS_ACTIVE;
- } else {
- return Status.STATUS_NO_TRANSACTION;
- }
- }
-
- public void setTransactionTimeout(int timeout) throws SystemException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void registerSynchronization(Synchronization sync) {
- if (log.isDebugEnabled()) {
- log.debug("registering synchronization: " + sync);
- }
- // try to register the synchronization directly with the
- // persistence provider, but if this fails, just hold
- // on to it myself
- if (!persistenceProvider.registerSynchronization(sync, entityManager)) {
- getSynchronizations().registerSynchronization(sync);
- }
- }
-
- @Override
- public boolean isConversationContextRequired() {
- return true;
- }
-
- @Override
- public void enlist(EntityManager entityManager) {
- // no-op
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/HibernateTransaction.java b/impl/src/main/java/org/jboss/seam/transaction/HibernateTransaction.java
deleted file mode 100644
index 195d9cd..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/HibernateTransaction.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.enterprise.context.RequestScoped;
-import javax.inject.Inject;
-import javax.persistence.EntityManager;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-
-import org.hibernate.Session;
-import org.hibernate.Transaction;
-import org.jboss.logging.Logger;
-import org.jboss.seam.solder.core.Veto;
-
-/**
- * Support for the Hibernate transaction API.
- *
- * @author Stuart Douglas
- */
-@RequestScoped
-@DefaultTransaction
-@Veto
-public class HibernateTransaction extends AbstractUserTransaction implements Synchronization {
- private static final Logger log = Logger.getLogger(HibernateTransaction.class);
-
- @Inject
- private Session session;
-
- private boolean rollbackOnly; // Hibernate Transaction doesn't have a
- // "rollback only" state
-
- private boolean synchronizationRegistered = false;
-
- @Inject
- public void init(Synchronizations sync) {
- setSynchronizations(sync);
- }
-
- public HibernateTransaction() {
- }
-
- private Transaction getDelegate() {
- return session.getTransaction();
- }
-
- public void begin() throws NotSupportedException, SystemException {
- log.debug("beginning JPA resource-local transaction");
- // TODO: translate exceptions that occur into the correct JTA exception
- try {
- getDelegate().begin();
- getSynchronizations().afterTransactionBegin();
- // use hibernate to manage the synchronizations
- // that way even if the user commits the transaction
- // themselves they will still be handled
- getDelegate().registerSynchronization(this);
- synchronizationRegistered = true;
- } catch (RuntimeException re) {
- throw re;
- }
- }
-
- public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
- log.debug("committing JPA resource-local transaction");
- Transaction delegate = getDelegate();
- boolean success = false;
- boolean tempSynchronizationRegistered = synchronizationRegistered;
- try {
- if (delegate.isActive()) {
- if (!rollbackOnly) {
- if (!tempSynchronizationRegistered) {
- // should only occur if the user started the transaction
- // directly through the session
- getSynchronizations().beforeTransactionCommit();
- }
- delegate.commit();
- success = true;
- } else {
- rollback();
- }
- }
- } finally {
- if (!tempSynchronizationRegistered) {
- getSynchronizations().afterTransactionCompletion(success);
- }
- }
- }
-
- public void rollback() throws IllegalStateException, SecurityException, SystemException {
- log.debug("rolling back JPA resource-local transaction");
- // TODO: translate exceptions that occur into the correct JTA exception
- Transaction delegate = getDelegate();
- rollbackOnly = false;
- boolean tempSynchronizationRegistered = synchronizationRegistered;
- delegate.rollback();
- if (!tempSynchronizationRegistered) {
- getSynchronizations().afterTransactionCompletion(false);
- }
- }
-
- public void setRollbackOnly() throws IllegalStateException, SystemException {
- log.debug("marking JPA resource-local transaction for rollback");
- rollbackOnly = true;
- }
-
- public int getStatus() throws SystemException {
- if (getDelegate().isActive()) {
- if (rollbackOnly) {
- return Status.STATUS_MARKED_ROLLBACK;
- }
- return Status.STATUS_ACTIVE;
- } else {
- return Status.STATUS_NO_TRANSACTION;
- }
- }
-
- public void setTransactionTimeout(int timeout) throws SystemException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void registerSynchronization(Synchronization sync) {
- if (log.isDebugEnabled()) {
- log.debug("registering synchronization: " + sync);
- }
- getDelegate().registerSynchronization(sync);
- }
-
- @Override
- public boolean isConversationContextRequired() {
- return true;
- }
-
- @Override
- public void enlist(EntityManager entityManager) {
- throw new RuntimeException("You should not try and enlist an EntityManager in a HibernateTransaction, use EntityTransaction or JTA instead");
- }
-
- public void afterCompletion(int status) {
- boolean success = Status.STATUS_COMMITTED == status;
- getSynchronizations().afterTransactionCompletion(success);
- rollbackOnly = false;
- synchronizationRegistered = false;
- }
-
- public void beforeCompletion() {
- getSynchronizations().beforeTransactionCommit();
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/NoTransaction.java b/impl/src/main/java/org/jboss/seam/transaction/NoTransaction.java
deleted file mode 100644
index 6ec8e3b..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/NoTransaction.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.persistence.EntityManager;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-
-import org.jboss.seam.solder.core.Veto;
-
-/**
- * When no kind of transaction management exists.
- *
- * @author Mike Youngstrom
- * @author Gavin King
- */
-@Veto
-public class NoTransaction extends AbstractUserTransaction {
-
- public NoTransaction() {
- }
-
- public void begin() throws NotSupportedException, SystemException {
- throw new UnsupportedOperationException("no transaction");
- }
-
- public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
- throw new UnsupportedOperationException("no transaction");
- }
-
- public int getStatus() throws SystemException {
- return Status.STATUS_NO_TRANSACTION;
- }
-
- public void rollback() throws IllegalStateException, SecurityException, SystemException {
- throw new UnsupportedOperationException("no transaction");
- }
-
- public void setRollbackOnly() throws IllegalStateException, SystemException {
- throw new UnsupportedOperationException("no transaction");
- }
-
- public void setTransactionTimeout(int timeout) throws SystemException {
- throw new UnsupportedOperationException("no transaction");
- }
-
- @Override
- public void registerSynchronization(Synchronization sync) {
- throw new UnsupportedOperationException("no transaction");
- }
-
- @Override
- public void enlist(EntityManager entityManager) throws SystemException {
- // no-op
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/SeSynchronizations.java b/impl/src/main/java/org/jboss/seam/transaction/SeSynchronizations.java
deleted file mode 100644
index c2d485a..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/SeSynchronizations.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.transaction.Synchronization;
-
-import org.jboss.seam.solder.core.Veto;
-
-/**
- * This implementation does not have access to the JTA TransactionManager, so it is not fully aware of container managed
- * transaction lifecycle, and is not able to register Synchronizations with a container managed transaction.
- *
- * @author Gavin King
- * @author Stuart Douglas
- * @author Lincoln Baxter, III
- */
-@ApplicationScoped
-@Veto
-public class SeSynchronizations implements Synchronizations
-{
- protected ThreadLocalStack synchronizations = new ThreadLocalStack();
-
- public void afterTransactionBegin()
- {
- synchronizations.push(new SynchronizationRegistry());
- }
-
- public void afterTransactionCompletion(final boolean success)
- {
- if (!synchronizations.isEmpty())
- {
- synchronizations.pop().afterTransactionCompletion(success);
- }
- }
-
- public void beforeTransactionCommit()
- {
- if (!synchronizations.isEmpty())
- {
- synchronizations.peek().beforeTransactionCompletion();
- }
- }
-
- public void registerSynchronization(final Synchronization sync)
- {
- if (synchronizations.isEmpty())
- {
- throw new IllegalStateException(
- "Transaction begin not detected, try installing transaction:ejb-transaction in components.xml");
- }
- else
- {
- synchronizations.peek().registerSynchronization(sync);
- }
- }
-
- public boolean isAwareOfContainerTransactions()
- {
- return false;
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/SynchronizationRegistry.java b/impl/src/main/java/org/jboss/seam/transaction/SynchronizationRegistry.java
deleted file mode 100644
index e9f1c24..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/SynchronizationRegistry.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-
-import org.jboss.logging.Logger;
-
-/**
- * A list of Synchronizations to be invoked before and after transaction completion. This class is used when we can't
- * register a synchronization directly with JTA.
- *
- * @author Lincoln Baxter, III
- * @author Gavin King
- */
-class SynchronizationRegistry
-{
-
- public SynchronizationRegistry()
- {
- }
-
- private static final Logger log = Logger.getLogger(SynchronizationRegistry.class);
-
- private final List synchronizations = new ArrayList();
-
- void registerSynchronization(final Synchronization sync)
- {
- synchronizations.add(sync);
- }
-
- void afterTransactionCompletion(final boolean success)
- {
- for (Synchronization sync : synchronizations)
- {
- try
- {
- sync.afterCompletion(success ? Status.STATUS_COMMITTED : Status.STATUS_ROLLEDBACK);
- }
- catch (Exception e)
- {
- log.error("Exception processing transaction Synchronization after completion", e);
- }
- }
- synchronizations.clear();
- }
-
- void beforeTransactionCompletion()
- {
- for (Synchronization sync : synchronizations)
- {
- try
- {
- sync.beforeCompletion();
- }
- catch (Exception e)
- {
- log.error("Exception processing transaction Synchronization before completion", e);
- }
- }
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/Synchronizations.java b/impl/src/main/java/org/jboss/seam/transaction/Synchronizations.java
deleted file mode 100644
index 02206e5..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/Synchronizations.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.transaction.Synchronization;
-
-/**
- * Interface for registering transaction synchronizations
- *
- * @author Gavin King
- */
-public interface Synchronizations {
- public void afterTransactionBegin();
-
- public void afterTransactionCompletion(boolean success);
-
- public void beforeTransactionCommit();
-
- public void registerSynchronization(Synchronization sync);
-
- public boolean isAwareOfContainerTransactions();
-}
\ No newline at end of file
diff --git a/impl/src/main/java/org/jboss/seam/transaction/ThreadLocalStack.java b/impl/src/main/java/org/jboss/seam/transaction/ThreadLocalStack.java
deleted file mode 100644
index 7bea8e1..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/ThreadLocalStack.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import java.util.NoSuchElementException;
-import java.util.concurrent.LinkedBlockingDeque;
-
-class ThreadLocalStack {
- private final ThreadLocal> stack = new ThreadLocal>();
-
- public void push(T t) {
- if (stack.get() == null) {
- stack.set(new LinkedBlockingDeque());
- }
- stack.get().push(t);
- }
-
- public T pop() {
- LinkedBlockingDeque queue = stack.get();
- if (queue == null) {
- throw new NoSuchElementException();
- }
- T t = queue.pop();
- if (queue.isEmpty()) {
- stack.remove();
- }
- return t;
- }
-
- public T peek() {
- LinkedBlockingDeque queue = stack.get();
- if (queue == null) {
- return null;
- }
- return queue.peek();
- }
-
- public boolean isEmpty() {
- LinkedBlockingDeque queue = stack.get();
- if (queue == null) {
- return true;
- }
- return queue.isEmpty();
- }
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/TransactionExtension.java b/impl/src/main/java/org/jboss/seam/transaction/TransactionExtension.java
deleted file mode 100644
index 688b674..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/TransactionExtension.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.Annotated;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-
-import org.jboss.logging.Logger;
-import org.jboss.seam.persistence.util.EjbApi;
-import org.jboss.seam.solder.reflection.annotated.AnnotatedTypeBuilder;
-
-/**
- * Extension than provides a {@link SeamTransaction} if no other UserTransaction
- * has been registered.
- *
- * This allows the user to register a transaction via seam XML and have it
- * automatically replace the default UserTransaction implementation
- *
- * This is not done with alternatives, because that would require specifying the
- * transaction manager on a per module basis, and some of the UserTransaction
- * implementations need to be configured via seam xml anyway, so they would have
- * to be configured twice
- *
- * @author Stuart Douglas
- */
-public class TransactionExtension implements Extension {
- private static final Logger log = Logger.getLogger(TransactionExtension.class);
-
- private final Set exceptions = new HashSet();
-
- private final Map, Annotation> classLevelAnnotations = new HashMap, Annotation>();
-
- /**
- * Looks for @Transaction or @TransactionAttribute annotations and if they
- * are found adds the transaction intercepter binding
- */
- public void processAnnotatedType(@Observes ProcessAnnotatedType event, final BeanManager beanManager) {
- AnnotatedTypeBuilder builder = null;
- AnnotatedType type = event.getAnnotatedType();
- boolean addedToClass = false;
- if (type.isAnnotationPresent(Transactional.class)) {
- builder = new AnnotatedTypeBuilder().readFromType(type);
- builder.addToClass(TransactionInterceptorBindingLiteral.INSTANCE);
- addedToClass = true;
- classLevelAnnotations.put(type.getJavaClass(), type.getAnnotation(Transactional.class));
- } else if (type.isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE) && !EjbApi.isEjb(event.getAnnotatedType())) {
- checkTransactionAttributeIsValue(type, type);
- builder = new AnnotatedTypeBuilder().readFromType(type);
- builder.addToClass(TransactionInterceptorBindingLiteral.INSTANCE);
- addedToClass = true;
- classLevelAnnotations.put(type.getJavaClass(), type.getAnnotation(EjbApi.TRANSACTION_ATTRIBUTE));
- }
- if (!addedToClass) {
- for (final Annotation annotation : type.getAnnotations()) {
- if (beanManager.isStereotype(annotation.annotationType())) {
- for (Annotation stereotypeAnnotation : beanManager.getStereotypeDefinition(annotation.annotationType())) {
- if (stereotypeAnnotation.annotationType().equals(Transactional.class)) {
- builder = new AnnotatedTypeBuilder().readFromType(type);
- builder.addToClass(TransactionInterceptorBindingLiteral.INSTANCE);
- addedToClass = true;
- classLevelAnnotations.put(type.getJavaClass(), stereotypeAnnotation);
- } else if (stereotypeAnnotation.annotationType().equals(EjbApi.TRANSACTION_ATTRIBUTE) && !EjbApi.isEjb(event.getAnnotatedType())) {
- checkTransactionAttributeIsValue(type, type);
- builder = new AnnotatedTypeBuilder().readFromType(type);
- builder.addToClass(TransactionInterceptorBindingLiteral.INSTANCE);
- addedToClass = true;
- classLevelAnnotations.put(type.getJavaClass(), stereotypeAnnotation);
- }
- }
- }
- }
- }
- if (!addedToClass) {
- for (AnnotatedMethod super X> m : type.getMethods()) {
- if (m.isAnnotationPresent(Transactional.class)) {
- if (builder == null) {
- builder = new AnnotatedTypeBuilder().readFromType(type);
- }
- builder.addToMethod(m, TransactionInterceptorBindingLiteral.INSTANCE);
- } else if (m.isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE) && !EjbApi.isEjb(event.getAnnotatedType())) {
- checkTransactionAttributeIsValue(type, m);
- if (builder == null) {
- builder = new AnnotatedTypeBuilder().readFromType(type);
- }
- builder.addToMethod(m, TransactionInterceptorBindingLiteral.INSTANCE);
- }
- }
- }
- if (builder != null) {
- event.setAnnotatedType(builder.create());
- }
- }
-
- public Annotation getClassLevelTransactionAnnotation(Class> clazz) {
- return classLevelAnnotations.get(clazz);
- }
-
- private void afterBeanDiscover(@Observes AfterBeanDiscovery event) {
- for (Throwable throwable : exceptions) {
- event.addDefinitionError(throwable);
- }
- }
-
- private void checkTransactionAttributeIsValue(AnnotatedType type, Annotated element) {
- Object attribute = element.getAnnotation(EjbApi.TRANSACTION_ATTRIBUTE);
- if (attribute == EjbApi.REQUIRES_NEW) {
- exceptions.add(new RuntimeException("TransactionAttributeType.REQUIRED_NEW is not supported on Managed Beans that are not EJB's. Annotation was found on type " + type));
- }
- if (attribute == EjbApi.NOT_SUPPORTED) {
- exceptions.add(new RuntimeException("TransactionAttributeType.NOT_SUPPORTED is not supported on Managed Beans that are not EJB's. Annotation was found on type " + type));
- }
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptor.java b/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptor.java
deleted file mode 100644
index d30a092..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptor.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import org.jboss.seam.persistence.util.BeanManagerUtils;
-import org.jboss.seam.persistence.util.EjbApi;
-import org.jboss.seam.transaction.literal.DefaultTransactionLiteral;
-
-import javax.enterprise.inject.spi.BeanManager;
-import javax.inject.Inject;
-import javax.interceptor.AroundInvoke;
-import javax.interceptor.Interceptor;
-import javax.interceptor.InvocationContext;
-import java.io.Serializable;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Implements transaction propagation rules for Seam JavaBean components.
- *
- * @author Gavin King
- * @author Shane Bryzak
- * @author Stuart Douglas
- */
-@TransactionalInterceptorBinding
-@Interceptor
-public class TransactionInterceptor implements Serializable {
- private static final long serialVersionUID = -4364203056333738988L;
-
- transient private Map transactionMetadata = new HashMap();
-
- private transient SeamTransaction seamTransaction;
-
- @Inject
- private TransactionExtension transactionExtension;
-
- @Inject
- private BeanManager beanManager;
-
- private class TransactionMetadata {
- private final boolean annotationPresent;
- private final TransactionPropagation propType;
-
- public TransactionMetadata(Annotation annotation) {
- if (annotation == null) {
- annotationPresent = false;
- propType = null;
- } else if (annotation.annotationType() == Transactional.class) {
- annotationPresent = true;
- propType = ((Transactional) annotation).value();
- } else if (annotation.annotationType() == EjbApi.TRANSACTION_ATTRIBUTE) {
- annotationPresent = true;
- try {
- Object value = annotation.getClass().getMethod("value").invoke(annotation);
-
- if (value == EjbApi.REQUIRED) {
- propType = TransactionPropagation.REQUIRED;
- } else if (value == EjbApi.MANDATORY) {
- propType = TransactionPropagation.MANDATORY;
- } else if (value == EjbApi.NEVER) {
- propType = TransactionPropagation.NEVER;
- } else if (value == EjbApi.SUPPORTS) {
- propType = TransactionPropagation.SUPPORTS;
- } else if (value == EjbApi.NOT_SUPPORTED) {
- throw new RuntimeException("TransactionAttributeType.NOT_SUPPORTED is not allowed on managed beans that are not EJB's.");
- } else if (value == EjbApi.REQUIRES_NEW) {
- throw new RuntimeException("TransactionAttributeType.REQUIRES_NEW is not allowed on managed beans that are not EJB's.");
- } else {
- throw new RuntimeException("Unkown TransactionAttributeType: " + value);
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- } else {
- annotationPresent = false;
- propType = null;
- }
- }
-
- public boolean isAnnotationPresent() {
- return annotationPresent;
- }
-
- public boolean isNewTransactionRequired(boolean transactionActive) {
- return propType != null && propType.isNewTransactionRequired(transactionActive);
- }
- }
-
- private TransactionMetadata lookupTransactionMetadata(Method element) {
- if (transactionMetadata == null) {
- transactionMetadata = new HashMap();
- }
-
- TransactionMetadata metadata = transactionMetadata.get(element);
-
- if (metadata == null) {
- synchronized (this) {
- if (element.isAnnotationPresent(Transactional.class)) {
- metadata = new TransactionMetadata(element.getAnnotation(Transactional.class));
- } else if (element.isAnnotationPresent(EjbApi.TRANSACTION_ATTRIBUTE)) {
- metadata = new TransactionMetadata(element.getAnnotation(EjbApi.TRANSACTION_ATTRIBUTE));
- } else {
- metadata = new TransactionMetadata(null);
- }
- transactionMetadata.put(element, metadata);
- }
- }
- return metadata;
- }
-
- private TransactionMetadata lookupTransactionMetadata(Class> element) {
- if (transactionMetadata == null) {
- transactionMetadata = new HashMap();
- }
-
- TransactionMetadata metadata = transactionMetadata.get(element);
-
- if (metadata == null) {
- synchronized (this) {
- // we need access to cached stereotype information, so we load it
- // from the transaction extension
- metadata = new TransactionMetadata(transactionExtension.getClassLevelTransactionAnnotation(element));
- transactionMetadata.put((AnnotatedElement) element, metadata);
- }
- }
- return metadata;
- }
-
- @AroundInvoke
- public Object aroundInvoke(final InvocationContext invocation) throws Exception {
- return new Work() {
-
- @Override
- protected Object work() throws Exception {
- return invocation.proceed();
- }
-
- @Override
- protected boolean isNewTransactionRequired(boolean transactionActive) {
- return isNewTransactionRequired(invocation.getMethod(), invocation.getMethod().getDeclaringClass(), transactionActive);
- }
-
- private boolean isNewTransactionRequired(Method method, Class> beanClass, boolean transactionActive) {
- TransactionMetadata metadata = lookupTransactionMetadata(method);
- if (metadata.isAnnotationPresent()) {
- return metadata.isNewTransactionRequired(transactionActive);
- } else {
- metadata = lookupTransactionMetadata(beanClass);
- return metadata.isNewTransactionRequired(transactionActive);
- }
- }
-
- }.workInTransaction(getTransaction());
- }
-
- private SeamTransaction getTransaction() {
- if(seamTransaction == null) {
- seamTransaction = BeanManagerUtils.getContextualInstance(beanManager, SeamTransaction.class, DefaultTransactionLiteral.INSTANCE);
- }
- return seamTransaction;
- }
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptorBindingLiteral.java b/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptorBindingLiteral.java
deleted file mode 100644
index b87f64a..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/TransactionInterceptorBindingLiteral.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.enterprise.util.AnnotationLiteral;
-
-class TransactionInterceptorBindingLiteral extends AnnotationLiteral {
- static TransactionInterceptorBindingLiteral INSTANCE = new TransactionInterceptorBindingLiteral();
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/TransactionManagerSynchronizations.java b/impl/src/main/java/org/jboss/seam/transaction/TransactionManagerSynchronizations.java
deleted file mode 100644
index ce85b5c..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/TransactionManagerSynchronizations.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import org.jboss.logging.Logger;
-import org.jboss.seam.solder.bean.defaultbean.DefaultBean;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.transaction.Status;
-import javax.transaction.Synchronization;
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-
-/**
- * Synchronizations implementation that registers synchronizations with a JTA {@link TransactionManager}
- */
-@ApplicationScoped
-@DefaultBean(Synchronizations.class)
-public class TransactionManagerSynchronizations implements Synchronization, Synchronizations {
- private static final Logger log = Logger.getLogger(TransactionManagerSynchronizations.class);
-
- private final String[] JNDI_LOCATIONS = { "java:jboss/TransactionManager", "java:/TransactionManager",
- "java:appserver/TransactionManager", "java:comp/TransactionManager", "java:pm/TransactionManager" };
-
- /**
- * The location that the TM was found under JNDI. This is static, as it will not change between deployed apps on the same
- * JVM
- */
- private static volatile String foundJndiLocation;
-
- protected ThreadLocalStack synchronizations = new ThreadLocalStack();
-
- protected ThreadLocalStack transactions = new ThreadLocalStack();
-
- @Override
- public void beforeCompletion() {
- log.debug("beforeCompletion");
- SynchronizationRegistry sync = synchronizations.peek();
- sync.beforeTransactionCompletion();
- }
-
- @Override
- public void afterCompletion(final int status) {
- transactions.pop();
- log.debug("afterCompletion");
- synchronizations.pop().afterTransactionCompletion((Status.STATUS_COMMITTED & status) == 0);
- }
-
- @Override
- public boolean isAwareOfContainerTransactions() {
- return true;
- }
-
- @Override
- public void registerSynchronization(final Synchronization sync) {
- try {
- TransactionManager manager = getTransactionManager();
- Transaction transaction = manager.getTransaction();
- if (transactions.isEmpty() || transactions.peek().equals(transaction)) {
- transactions.push(transaction);
- synchronizations.push(new SynchronizationRegistry());
- transaction.registerSynchronization(this);
- }
- synchronizations.peek().registerSynchronization(sync);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public TransactionManager getTransactionManager() {
- if (foundJndiLocation != null) {
- try {
- return (TransactionManager) new InitialContext().lookup(foundJndiLocation);
- } catch (NamingException e) {
- log.trace("Could not find transaction manager under" + foundJndiLocation);
- }
- }
- for (String location : JNDI_LOCATIONS) {
- try {
- TransactionManager manager = (TransactionManager) new InitialContext().lookup(location);
- foundJndiLocation = location;
- return manager;
- } catch (NamingException e) {
- log.trace("Could not find transaction manager under" + location);
- }
- }
- throw new RuntimeException("Could not find TransactionManager in JNDI");
- }
-
- @Override
- public void afterTransactionBegin() {
-
- }
-
- @Override
- public void afterTransactionCompletion(final boolean success) {
-
- }
-
- @Override
- public void beforeTransactionCommit() {
-
- }
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/TransactionalInterceptorBinding.java b/impl/src/main/java/org/jboss/seam/transaction/TransactionalInterceptorBinding.java
deleted file mode 100644
index 4d32f27..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/TransactionalInterceptorBinding.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import javax.interceptor.InterceptorBinding;
-
-/**
- * Interceptor binding for the seam transaction interceceptor. This binding is
- * applied automatically by a portable extension, the user should not need to
- * apply it themselves
- *
- * @author Stuart Douglas
- */
-@Retention(RetentionPolicy.RUNTIME)
-@InterceptorBinding
-@Target({ElementType.TYPE, ElementType.METHOD})
- @interface TransactionalInterceptorBinding {
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/UTTransaction.java b/impl/src/main/java/org/jboss/seam/transaction/UTTransaction.java
deleted file mode 100644
index 179b98a..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/UTTransaction.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.RollbackException;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-
-import org.jboss.logging.Logger;
-import org.jboss.seam.solder.core.Veto;
-
-/**
- * Wraps JTA transaction management in a Seam UserTransaction interface.
- *
- * @author Mike Youngstrom
- * @author Gavin King
- */
-@Veto
-public class UTTransaction extends AbstractUserTransaction {
- private static final Logger log = Logger.getLogger(UTTransaction.class);
-
- private final javax.transaction.UserTransaction delegate;
-
- UTTransaction(javax.transaction.UserTransaction delegate, Synchronizations sync) {
- this.setSynchronizations(sync);
- this.delegate = delegate;
- if (delegate == null) {
- throw new IllegalArgumentException("null UserTransaction");
- }
- }
-
- public void begin() throws NotSupportedException, SystemException {
- log.debug("beginning JTA transaction");
- delegate.begin();
- getSynchronizations().afterTransactionBegin();
- }
-
- public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException, SecurityException, IllegalStateException, SystemException {
- log.debug("committing JTA transaction");
- boolean success = false;
- Synchronizations synchronizations = getSynchronizations();
- synchronizations.beforeTransactionCommit();
- try {
- delegate.commit();
- success = true;
- } finally {
- synchronizations.afterTransactionCompletion(success);
- }
- }
-
- public void rollback() throws IllegalStateException, SecurityException, SystemException {
- log.debug("rolling back JTA transaction");
- try {
- delegate.rollback();
- } finally {
- getSynchronizations().afterTransactionCompletion(false);
- }
- }
-
- public int getStatus() throws SystemException {
- return delegate.getStatus();
- }
-
- public void setRollbackOnly() throws IllegalStateException, SystemException {
- delegate.setRollbackOnly();
- }
-
- public void setTransactionTimeout(int timeout) throws SystemException {
- delegate.setTransactionTimeout(timeout);
- }
-
- @Override
- public void registerSynchronization(Synchronization sync) {
- getSynchronizations().registerSynchronization(sync);
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/Work.java b/impl/src/main/java/org/jboss/seam/transaction/Work.java
deleted file mode 100644
index 26417a1..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/Work.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction;
-
-import javax.transaction.Status;
-
-import org.jboss.logging.Logger;
-import org.jboss.seam.persistence.util.ExceptionUtil;
-
-/**
- * Performs work in a JTA transaction.
- *
- * @author Gavin King
- */
-public abstract class Work {
- private static final Logger log = Logger.getLogger(Work.class);
-
- protected abstract T work() throws Exception;
-
- protected boolean isNewTransactionRequired(boolean transactionActive) {
- return !transactionActive;
- }
-
- public final T workInTransaction(org.jboss.seam.transaction.SeamTransaction transaction) throws Exception {
- boolean transactionActive = transaction.isActiveOrMarkedRollback() || transaction.isRolledBack();
- // TODO: temp workaround, what should we really do in this case??
- boolean newTransactionRequired = isNewTransactionRequired(transactionActive);
-
- try {
- if (newTransactionRequired) {
- log.debug("beginning transaction");
- transaction.begin();
- }
-
- T result = work();
- if (newTransactionRequired) {
- if (transaction.isMarkedRollback()) {
- log.debug("rolling back transaction");
- transaction.rollback();
- } else {
- log.debug("committing transaction");
- transaction.commit();
- }
- }
- return result;
- } catch (Exception e) {
- if (newTransactionRequired && transaction.getStatus() != Status.STATUS_NO_TRANSACTION) {
- if (ExceptionUtil.exceptionCausesRollback(e)) {
- log.debug("rolling back transaction");
- transaction.rollback();
- } else {
- log.debug("committing transaction after ApplicationException(rollback=false):" + e.getMessage());
- transaction.commit();
- }
- } else if (transaction.getStatus() != Status.STATUS_NO_TRANSACTION && ExceptionUtil.exceptionCausesRollback(e)) {
- transaction.setRollbackOnly();
- }
- throw e;
- }
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/scope/ContextualIdentifierStore.java b/impl/src/main/java/org/jboss/seam/transaction/scope/ContextualIdentifierStore.java
deleted file mode 100644
index 7c0528a..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/scope/ContextualIdentifierStore.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction.scope;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.inject.spi.PassivationCapable;
-
-/**
- * Class that maps a Contextual to an identifier. If the Contextual is
- * {@link PassivationCapable} then the id used, otherwise one is generated
- *
- * @author Stuart Douglas
- */
-public class ContextualIdentifierStore {
- private final Map, String> identifiers = new ConcurrentHashMap, String>();
-
- private final Map> contextualForIdentifier = new ConcurrentHashMap>();
-
- private int count = 0;
-
- private final String PREFIX = "CID-";
-
- public Contextual> getContextual(String id) {
- return contextualForIdentifier.get(id);
- }
-
- public String getId(Contextual> contextual) {
- if (identifiers.containsKey(contextual)) {
- return identifiers.get(contextual);
- }
- if (contextual instanceof PassivationCapable) {
- PassivationCapable p = (PassivationCapable) contextual;
- String id = p.getId();
- contextualForIdentifier.put(id, contextual);
- return id;
- } else {
- synchronized (this) {
- // check again inside the syncronized block
- if (identifiers.containsKey(contextual)) {
- return identifiers.get(contextual);
- }
- String id = PREFIX + getClass().getName() + "-" + (count++);
- identifiers.put(contextual, id);
- contextualForIdentifier.put(id, contextual);
- return id;
- }
- }
- }
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/scope/TransactionScopeContext.java b/impl/src/main/java/org/jboss/seam/transaction/scope/TransactionScopeContext.java
deleted file mode 100644
index ffd17a1..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/scope/TransactionScopeContext.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction.scope;
-
-import java.lang.annotation.Annotation;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-import javax.enterprise.context.spi.Context;
-import javax.enterprise.context.spi.Contextual;
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.transaction.Synchronization;
-import javax.transaction.SystemException;
-
-import org.jboss.seam.transaction.DefaultTransaction;
-import org.jboss.seam.transaction.SeamTransaction;
-import org.jboss.seam.transaction.TransactionScoped;
-import org.jboss.seam.transaction.literal.DefaultTransactionLiteral;
-
-/**
- * Context for the {@link TransactionScoped} scope
- *
- * @author stuart
- */
-public class TransactionScopeContext implements Context, Synchronization {
-
- private SeamTransaction userTransaction;
-
- private final BeanManager beanManager;
-
- private final ContextualIdentifierStore identifierStore = new ContextualIdentifierStore();
-
- private final ThreadLocal contextData = new ThreadLocal() {
- protected TransactionScopeData initialValue() {
- return new TransactionScopeData();
- }
-
- ;
- };
-
- public TransactionScopeContext(BeanManager beanManager) {
- this.beanManager = beanManager;
-
- }
-
- /**
- * we need to resolve the transaction bean lazily, after startup has
- * completed
- */
- private void lazyInitialization() {
- if (userTransaction == null) {
- synchronized (this) {
- if (userTransaction == null) {
- Bean bean = (Bean) beanManager.resolve(beanManager.getBeans(SeamTransaction.class, DefaultTransactionLiteral.INSTANCE));
- if (bean == null) {
- throw new RuntimeException("Could not find SeamTransaction bean with qualifier " + DefaultTransaction.class.getName());
- }
- CreationalContext ctx = beanManager.createCreationalContext(bean);
- userTransaction = (SeamTransaction) beanManager.getReference(bean, SeamTransaction.class, ctx);
- }
- }
- }
- }
-
- /**
- * registers a syncronization so that the beans can be destroyed when the
- * transaction ends
- */
- private void registerSyncronization() {
- TransactionScopeData data = contextData.get();
- if (!data.isSyncronisationRegistered()) {
- data.setSyncronisationRegistered(true);
- userTransaction.registerSynchronization(this);
- }
- }
-
- public T get(Contextual contextual) {
- lazyInitialization();
- registerSyncronization();
- String id = identifierStore.getId(contextual);
- Map map = contextData.get().getInstanceStore();
- return (T) map.get(id);
- }
-
- public T get(Contextual contextual, CreationalContext creationalContext) {
- lazyInitialization();
- registerSyncronization();
- String id = identifierStore.getId(contextual);
- TransactionScopeData data = contextData.get();
- T instance = (T) data.getInstanceStore().get(id);
- if (instance == null) {
- instance = contextual.create(creationalContext);
- data.getCreationalContexts().put(id, creationalContext);
- data.getInstanceStore().put(id, instance);
- }
- return instance;
- }
-
- public Class extends Annotation> getScope() {
- return TransactionScoped.class;
- }
-
- public boolean isActive() {
- lazyInitialization();
- try {
- return userTransaction.isActive();
- } catch (SystemException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * the transaction is done, destory the beans
- */
- public void afterCompletion(int status) {
- TransactionScopeData data = contextData.get();
- for (Entry e : data.getInstanceStore().entrySet()) {
- Contextual contextual = identifierStore.getContextual(e.getKey());
- CreationalContext> ctx = data.getCreationalContexts().get(e.getKey());
- contextual.destroy(e.getValue(), ctx);
- ctx.release();
- }
- contextData.remove();
- }
-
- public void beforeCompletion() {
-
- }
-
- private class TransactionScopeData {
- private final Map instanceStore = new HashMap();
- private final Map> creationalContexts = new HashMap>();
- private boolean syncronisationRegistered;
-
- public boolean isSyncronisationRegistered() {
- return syncronisationRegistered;
- }
-
- public void setSyncronisationRegistered(boolean syncronisationRegistered) {
- this.syncronisationRegistered = syncronisationRegistered;
- }
-
- public Map getInstanceStore() {
- return instanceStore;
- }
-
- public Map> getCreationalContexts() {
- return creationalContexts;
- }
-
- }
-
-}
diff --git a/impl/src/main/java/org/jboss/seam/transaction/scope/TransactionScopeExtension.java b/impl/src/main/java/org/jboss/seam/transaction/scope/TransactionScopeExtension.java
deleted file mode 100644
index e4598a9..0000000
--- a/impl/src/main/java/org/jboss/seam/transaction/scope/TransactionScopeExtension.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and/or its affiliates, 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.seam.transaction.scope;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-
-import org.jboss.seam.transaction.TransactionScoped;
-
-/**
- * Extension that registers the context for {@link TransactionScoped} beans
- *
- * @author Stuart Douglas
- */
-public class TransactionScopeExtension implements Extension {
- public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager manager) {
- event.addContext(new TransactionScopeContext(manager));
- }
-}
diff --git a/tests/base/pom.xml b/tests/base/pom.xml
index 850ed76..f7e5526 100644
--- a/tests/base/pom.xml
+++ b/tests/base/pom.xml
@@ -47,7 +47,7 @@
org.jboss.seam.persistence
- seam-persistence-impl
+ seam-persistence
provided
diff --git a/tests/jbossas-hibernate/pom.xml b/tests/jbossas-hibernate/pom.xml
index b1476fe..93cb0bf 100644
--- a/tests/jbossas-hibernate/pom.xml
+++ b/tests/jbossas-hibernate/pom.xml
@@ -80,7 +80,7 @@
org.jboss.seam.persistence
- seam-persistence-impl
+ seam-persistence
diff --git a/tests/jetty-hibernate/pom.xml b/tests/jetty-hibernate/pom.xml
index fdb3506..c921e20 100644
--- a/tests/jetty-hibernate/pom.xml
+++ b/tests/jetty-hibernate/pom.xml
@@ -106,7 +106,7 @@
org.jboss.seam.persistence
- seam-persistence-impl
+ seam-persistence
test
diff --git a/tests/jetty-openjpa/pom.xml b/tests/jetty-openjpa/pom.xml
index c69f3d8..0c2fc92 100644
--- a/tests/jetty-openjpa/pom.xml
+++ b/tests/jetty-openjpa/pom.xml
@@ -75,7 +75,7 @@
org.jboss.seam.persistence
- seam-persistence-impl
+ seam-persistence
test