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

[1/2] git commit: DELTASPIKE-250 changed strategy name

Updated Branches:
  refs/heads/master a04254010 -> 0e110fb6b


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/0e110fb6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/0e110fb6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/0e110fb6

Branch: refs/heads/master
Commit: 0e110fb6b9c63b62d55b5ac29516457e4ab294db
Parents: 4a2fd5d
Author: gpetracek <gp...@apache.org>
Authored: Mon Jul 30 01:04:20 2012 +0200
Committer: gpetracek <gp...@apache.org>
Committed: Mon Jul 30 01:04:20 2012 +0200

----------------------------------------------------------------------
 ...dvancedEnvironmentAwareTransactionStrategy.java |  104 ---------------
 .../EnvironmentAwareTransactionStrategy.java       |  104 +++++++++++++++
 2 files changed, 104 insertions(+), 104 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/0e110fb6/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
deleted file mode 100644
index 3f76997..0000000
--- a/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/AdvancedEnvironmentAwareTransactionStrategy.java
+++ /dev/null
@@ -1,104 +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.api.projectstage.ProjectStage;
-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.inject.Inject;
-import javax.persistence.EntityManager;
-import java.lang.annotation.Annotation;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * This alternative {@link org.apache.deltaspike.jpa.spi.TransactionStrategy} uses auto-detection and
- * can be used if different environments (dev., prod.,...) should use different transaction-types.
- *
- * This implementation uses a different approach for the auto-detection which can be used for environments
- * (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 SimpleEnvironmentAwareTransactionStrategy
- */
-@Dependent
-@Alternative
-@SuppressWarnings("UnusedDeclaration")
-public class AdvancedEnvironmentAwareTransactionStrategy extends SimpleEnvironmentAwareTransactionStrategy
-{
-    private static final long serialVersionUID = -4432802805095533499L;
-
-    private static final Logger LOGGER =
-        Logger.getLogger(AdvancedEnvironmentAwareTransactionStrategy.class.getName());
-
-    private static ThreadLocal<Boolean> isJtaModeDetected = new ThreadLocal<Boolean>();
-
-    @Inject
-    private ProjectStage projectStage;
-
-    @Override
-    protected EntityManagerEntry createEntityManagerEntry(
-            EntityManager entityManager, Class<? extends Annotation> qualifier)
-    {
-        boolean isTransactionTypeJta = false;
-
-        //Ensures that nested transactional beans with different entity-managers don't lead to a rollback
-        //(in case of transaction-type JTA).
-        if (isJtaModeDetected.get() == null)
-        {
-            try
-            {
-                //This check is only valid here, because the transaction isn't started.
-                entityManager.getTransaction();
-            }
-            catch (IllegalStateException e)
-            {
-                isTransactionTypeJta = true;
-            }
-            isJtaModeDetected.set(isTransactionTypeJta);
-        }
-        else
-        {
-            isTransactionTypeJta = isJtaModeDetected.get();
-        }
-
-        if (!isTransactionTypeJta && this.projectStage == ProjectStage.Development)
-        {
-            LOGGER.log(Level.INFO, getClass().getName() + " is active and " +
-                    "RESOURCE_LOCAL is configured for persistent-unit-transaction-type in the persistence.xml. " +
-                    "That's valid in case of different transaction-types for different environments " +
-                    "e.g. for development and production. " +
-                    "Please check your setup - if that isn't the intended use-case, " +
-                    "you could also use the default strategy " + ResourceLocalTransactionStrategy.class.getName());
-        }
-
-        return new JtaEntityManagerEntry(entityManager, qualifier, isTransactionTypeJta);
-    }
-
-    @Override
-    protected void onCloseTransactionScope()
-    {
-        super.onCloseTransactionScope();
-        isJtaModeDetected.set(null);
-        isJtaModeDetected.remove();
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/0e110fb6/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
new file mode 100644
index 0000000..6c5afbc
--- /dev/null
+++ b/deltaspike/modules/jpa/impl/src/main/java/org/apache/deltaspike/jpa/impl/transaction/EnvironmentAwareTransactionStrategy.java
@@ -0,0 +1,104 @@
+/*
+ * 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.api.projectstage.ProjectStage;
+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.inject.Inject;
+import javax.persistence.EntityManager;
+import java.lang.annotation.Annotation;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * This alternative {@link org.apache.deltaspike.jpa.spi.TransactionStrategy} uses auto-detection and
+ * can be used if different environments (dev., prod.,...) should use different transaction-types.
+ *
+ * This implementation uses a different approach for the auto-detection which can be used for environments
+ * (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 SimpleEnvironmentAwareTransactionStrategy
+ */
+@Dependent
+@Alternative
+@SuppressWarnings("UnusedDeclaration")
+public class EnvironmentAwareTransactionStrategy extends SimpleEnvironmentAwareTransactionStrategy
+{
+    private static final long serialVersionUID = -4432802805095533499L;
+
+    private static final Logger LOGGER =
+        Logger.getLogger(EnvironmentAwareTransactionStrategy.class.getName());
+
+    private static ThreadLocal<Boolean> isJtaModeDetected = new ThreadLocal<Boolean>();
+
+    @Inject
+    private ProjectStage projectStage;
+
+    @Override
+    protected EntityManagerEntry createEntityManagerEntry(
+            EntityManager entityManager, Class<? extends Annotation> qualifier)
+    {
+        boolean isTransactionTypeJta = false;
+
+        //Ensures that nested transactional beans with different entity-managers don't lead to a rollback
+        //(in case of transaction-type JTA).
+        if (isJtaModeDetected.get() == null)
+        {
+            try
+            {
+                //This check is only valid here, because the transaction isn't started.
+                entityManager.getTransaction();
+            }
+            catch (IllegalStateException e)
+            {
+                isTransactionTypeJta = true;
+            }
+            isJtaModeDetected.set(isTransactionTypeJta);
+        }
+        else
+        {
+            isTransactionTypeJta = isJtaModeDetected.get();
+        }
+
+        if (!isTransactionTypeJta && this.projectStage == ProjectStage.Development)
+        {
+            LOGGER.log(Level.INFO, getClass().getName() + " is active and " +
+                    "RESOURCE_LOCAL is configured for persistent-unit-transaction-type in the persistence.xml. " +
+                    "That's valid in case of different transaction-types for different environments " +
+                    "e.g. for development and production. " +
+                    "Please check your setup - if that isn't the intended use-case, " +
+                    "you could also use the default strategy " + ResourceLocalTransactionStrategy.class.getName());
+        }
+
+        return new JtaEntityManagerEntry(entityManager, qualifier, isTransactionTypeJta);
+    }
+
+    @Override
+    protected void onCloseTransactionScope()
+    {
+        super.onCloseTransactionScope();
+        isJtaModeDetected.set(null);
+        isJtaModeDetected.remove();
+    }
+}