You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2012/07/30 01:10:52 UTC
[2/2] git commit: DELTASPIKE-250 changed strategy name
DELTASPIKE-250 changed strategy name
Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/4a2fd5d0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/4a2fd5d0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/4a2fd5d0
Branch: refs/heads/master
Commit: 4a2fd5d0f7bcf8a6d1211b58138cad55cd488bbf
Parents: a042540
Author: gpetracek <gp...@apache.org>
Authored: Mon Jul 30 01:02:43 2012 +0200
Committer: gpetracek <gp...@apache.org>
Committed: Mon Jul 30 01:02:43 2012 +0200
----------------------------------------------------------------------
...dvancedEnvironmentAwareTransactionStrategy.java | 4 +-
.../EnvironmentAwareTransactionStrategy.java | 98 ---------------
.../SimpleEnvironmentAwareTransactionStrategy.java | 98 +++++++++++++++
3 files changed, 100 insertions(+), 100 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/4a2fd5d0/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/AdvancedEnvironmentAwareTransactionStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/AdvancedEnvironmentAwareTransactionStrategy.java b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/AdvancedEnvironmentAwareTransactionStrategy.java
index 32d8a16..3f76997 100644
--- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/AdvancedEnvironmentAwareTransactionStrategy.java
+++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/AdvancedEnvironmentAwareTransactionStrategy.java
@@ -38,12 +38,12 @@ import java.util.logging.Logger;
* (or producer-constellations) which allow a mixed usage of JTA and RESOURCE_LOCAL.
* (Within a transactional call it isn't possible to mix different transaction-types.)
*
- * @see EnvironmentAwareTransactionStrategy
+ * @see SimpleEnvironmentAwareTransactionStrategy
*/
@Dependent
@Alternative
@SuppressWarnings("UnusedDeclaration")
-public class AdvancedEnvironmentAwareTransactionStrategy extends EnvironmentAwareTransactionStrategy
+public class AdvancedEnvironmentAwareTransactionStrategy extends SimpleEnvironmentAwareTransactionStrategy
{
private static final long serialVersionUID = -4432802805095533499L;
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/4a2fd5d0/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/EnvironmentAwareTransactionStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/EnvironmentAwareTransactionStrategy.java b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/EnvironmentAwareTransactionStrategy.java
deleted file mode 100644
index cbe12c6..0000000
--- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/EnvironmentAwareTransactionStrategy.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.deltaspike.jpa.impl.transaction;
-
-import org.apache.deltaspike.core.impl.util.JndiUtils;
-import org.apache.deltaspike.jpa.impl.transaction.context.EntityManagerEntry;
-import org.apache.deltaspike.jpa.impl.transaction.context.JtaEntityManagerEntry;
-
-import javax.enterprise.context.Dependent;
-import javax.enterprise.inject.Alternative;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityTransaction;
-import javax.transaction.UserTransaction;
-import java.lang.annotation.Annotation;
-import java.util.logging.Logger;
-
-/**
- * This alternative {@link org.apache.deltaspike.jpa.spi.TransactionStrategy} uses a simple auto-detection
- * based on a failed JNDI lookup (of java:comp/UserTransaction) and
- * can be used if different environments (dev., prod.,...) should use different transaction-types.
- * It requires additional logic in the producer for the {@link EntityManager} to create the {@link EntityManager}
- * for the correct persistence-unit. In case of a project-stage based logic
- * {@link org.apache.deltaspike.core.api.exclude.annotation.Exclude} can be used to switch between different
- * producer-beans.
- *
- * It's a better alternative than extending
- * {@link BeanManagedUserTransactionTransactionStrategy}
- * (which would lead to an impl. dependency) only for using
- * {@link org.apache.deltaspike.core.api.exclude.annotation.Exclude} at the custom
- * {@link org.apache.deltaspike.jpa.spi.TransactionStrategy}
- * (or doing a custom veto-extension).
- */
-@Dependent
-@Alternative
-@SuppressWarnings("UnusedDeclaration")
-public class EnvironmentAwareTransactionStrategy extends BeanManagedUserTransactionTransactionStrategy
-{
- private static final long serialVersionUID = -3432802805095533499L;
-
- private static final Logger LOGGER =
- Logger.getLogger(EnvironmentAwareTransactionStrategy.class.getName());
-
- @Override
- protected EntityManagerEntry createEntityManagerEntry(
- EntityManager entityManager, Class<? extends Annotation> qualifier)
- {
- try
- {
- //just used for detecting the environment (e.g. servlet-container vs. application-server)
- JndiUtils.lookup(USER_TRANSACTION_JNDI_NAME, UserTransaction.class);
- }
- catch (IllegalStateException e)
- {
- return new JtaEntityManagerEntry(entityManager, qualifier, false);
- }
- return super.createEntityManagerEntry(entityManager, qualifier);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void beforeProceed(EntityManagerEntry entityManagerEntry)
- {
- //cast without check is valid, because the entry was created by this class - see #createEntityManagerEntry
- if (((JtaEntityManagerEntry)entityManagerEntry).isTransactionTypeJta())
- {
- super.beforeProceed(entityManagerEntry);
- }
- }
-
- @Override
- protected EntityTransaction getTransaction(EntityManagerEntry entityManagerEntry)
- {
- if (((JtaEntityManagerEntry)entityManagerEntry).isTransactionTypeJta())
- {
- return super.getTransaction(entityManagerEntry);
- }
-
- return entityManagerEntry.getEntityManager().getTransaction();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/4a2fd5d0/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/SimpleEnvironmentAwareTransactionStrategy.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/SimpleEnvironmentAwareTransactionStrategy.java b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/SimpleEnvironmentAwareTransactionStrategy.java
new file mode 100644
index 0000000..f7c6d3f
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/SimpleEnvironmentAwareTransactionStrategy.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.deltaspike.jpa.impl.transaction;
+
+import org.apache.deltaspike.core.impl.util.JndiUtils;
+import org.apache.deltaspike.jpa.impl.transaction.context.EntityManagerEntry;
+import org.apache.deltaspike.jpa.impl.transaction.context.JtaEntityManagerEntry;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.inject.Alternative;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import javax.transaction.UserTransaction;
+import java.lang.annotation.Annotation;
+import java.util.logging.Logger;
+
+/**
+ * This alternative {@link org.apache.deltaspike.jpa.spi.TransactionStrategy} uses a simple auto-detection
+ * based on a failed JNDI lookup (of java:comp/UserTransaction) and
+ * can be used if different environments (dev., prod.,...) should use different transaction-types.
+ * It requires additional logic in the producer for the {@link EntityManager} to create the {@link EntityManager}
+ * for the correct persistence-unit. In case of a project-stage based logic
+ * {@link org.apache.deltaspike.core.api.exclude.annotation.Exclude} can be used to switch between different
+ * producer-beans.
+ *
+ * It's a better alternative than extending
+ * {@link BeanManagedUserTransactionTransactionStrategy}
+ * (which would lead to an impl. dependency) only for using
+ * {@link org.apache.deltaspike.core.api.exclude.annotation.Exclude} at the custom
+ * {@link org.apache.deltaspike.jpa.spi.TransactionStrategy}
+ * (or doing a custom veto-extension).
+ */
+@Dependent
+@Alternative
+@SuppressWarnings("UnusedDeclaration")
+public class SimpleEnvironmentAwareTransactionStrategy extends BeanManagedUserTransactionTransactionStrategy
+{
+ private static final long serialVersionUID = -3432802805095533499L;
+
+ private static final Logger LOGGER =
+ Logger.getLogger(SimpleEnvironmentAwareTransactionStrategy.class.getName());
+
+ @Override
+ protected EntityManagerEntry createEntityManagerEntry(
+ EntityManager entityManager, Class<? extends Annotation> qualifier)
+ {
+ try
+ {
+ //just used for detecting the environment (e.g. servlet-container vs. application-server)
+ JndiUtils.lookup(USER_TRANSACTION_JNDI_NAME, UserTransaction.class);
+ }
+ catch (IllegalStateException e)
+ {
+ return new JtaEntityManagerEntry(entityManager, qualifier, false);
+ }
+ return super.createEntityManagerEntry(entityManager, qualifier);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void beforeProceed(EntityManagerEntry entityManagerEntry)
+ {
+ //cast without check is valid, because the entry was created by this class - see #createEntityManagerEntry
+ if (((JtaEntityManagerEntry)entityManagerEntry).isTransactionTypeJta())
+ {
+ super.beforeProceed(entityManagerEntry);
+ }
+ }
+
+ @Override
+ protected EntityTransaction getTransaction(EntityManagerEntry entityManagerEntry)
+ {
+ if (((JtaEntityManagerEntry)entityManagerEntry).isTransactionTypeJta())
+ {
+ return super.getTransaction(entityManagerEntry);
+ }
+
+ return entityManagerEntry.getEntityManager().getTransaction();
+ }
+}