diff --git a/appclient/pom.xml b/appclient/pom.xml
index 29d61365558b..9a17b550f71f 100644
--- a/appclient/pom.xml
+++ b/appclient/pom.xml
@@ -93,7 +93,7 @@
org.hibernate.javax.persistence
- hibernate-jpa-2.0-api
+ hibernate-jpa-2.1-api
diff --git a/build/build.xml b/build/build.xml
index 19fb5762559b..1ce5915164b1 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -367,6 +367,10 @@
+
+
+
+
@@ -476,7 +480,7 @@
-
+
@@ -870,19 +874,20 @@
-
+
-
+
-
+
-
+
+
diff --git a/build/pom.xml b/build/pom.xml
index d79a0c80e650..fa3f132cc020 100644
--- a/build/pom.xml
+++ b/build/pom.xml
@@ -245,6 +245,11 @@
cal10n-api
+
+ com.fasterxml
+ classmate
+
+
com.h2database
h2
@@ -734,7 +739,7 @@
org.hibernate.javax.persistence
- hibernate-jpa-2.0-api
+ hibernate-jpa-2.1-api
@@ -1212,8 +1217,8 @@
- org.wildfly
- wildfly-jpa-hibernate3
+ org.jipijapa
+ hibernate3
org.hibernate
@@ -1223,18 +1228,23 @@
- org.wildfly
- wildfly-jpa-hibernate4
+ org.jipijapa
+ hibernate4-3
- org.wildfly
- wildfly-jpa-openjpa
+ org.jipijapa
+ openjpa
- org.wildfly
- wildfly-jpa-spi
+ org.jipijapa
+ spi
+
+
+
+ org.jipijapa
+ core
@@ -2048,7 +2058,7 @@
org.hibernate:hibernate-envers
org.hibernate:hibernate-infinispan
org.hibernate:hibernate-validator
- org.hibernate.javax.persistence:hibernate-jpa-2.0-api
+ org.hibernate.javax.persistence:hibernate-jpa-2.1-api
org.hornetq:hornetq-commons
org.hornetq:hornetq-core-client
org.hornetq:hornetq-jms-client
@@ -2237,10 +2247,10 @@
org.wildfly:wildfly-jdr
org.wildfly:wildfly-jmx
org.wildfly:wildfly-jpa
- org.wildfly:wildfly-jpa-hibernate3
- org.wildfly:wildfly-jpa-hibernate4
- org.wildfly:wildfly-jpa-openjpa
- org.wildfly:wildfly-jpa-spi
+ org.jipijapa:hibernate3
+ org.jipijapa:hibernate4-3
+ org.jipijapa:openjpa
+ org.jipijapa:spi
org.wildfly:wildfly-jpa-util
org.wildfly:wildfly-jsf
org.wildfly:wildfly-jsf-injection
diff --git a/build/src/main/resources/modules/system/layers/base/com/fasterxml/classmate/main/module.xml b/build/src/main/resources/modules/system/layers/base/com/fasterxml/classmate/main/module.xml
new file mode 100644
index 000000000000..24746e4099fb
--- /dev/null
+++ b/build/src/main/resources/modules/system/layers/base/com/fasterxml/classmate/main/module.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build/src/main/resources/modules/system/layers/base/org/hibernate/main/module.xml b/build/src/main/resources/modules/system/layers/base/org/hibernate/main/module.xml
index 5ddc7151b3db..eafc6076c596 100644
--- a/build/src/main/resources/modules/system/layers/base/org/hibernate/main/module.xml
+++ b/build/src/main/resources/modules/system/layers/base/org/hibernate/main/module.xml
@@ -22,7 +22,7 @@
~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->
-
+
@@ -30,18 +30,23 @@
+
+
+
+
+
diff --git a/build/src/main/resources/modules/system/layers/base/org/jboss/as/jpa/main/module.xml b/build/src/main/resources/modules/system/layers/base/org/jboss/as/jpa/main/module.xml
index 0c4d2578fc1b..a94cb001916b 100644
--- a/build/src/main/resources/modules/system/layers/base/org/jboss/as/jpa/main/module.xml
+++ b/build/src/main/resources/modules/system/layers/base/org/jboss/as/jpa/main/module.xml
@@ -35,16 +35,21 @@
+
-
+
+
+
+
+
diff --git a/weld/src/main/java/org/jboss/as/weld/WeldDeploymentMarker.java b/ee/src/main/java/org/jboss/as/ee/weld/WeldDeploymentMarker.java
similarity index 98%
rename from weld/src/main/java/org/jboss/as/weld/WeldDeploymentMarker.java
rename to ee/src/main/java/org/jboss/as/ee/weld/WeldDeploymentMarker.java
index 0b925ae488e6..005c324b67f8 100644
--- a/weld/src/main/java/org/jboss/as/weld/WeldDeploymentMarker.java
+++ b/ee/src/main/java/org/jboss/as/ee/weld/WeldDeploymentMarker.java
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.weld;
+package org.jboss.as.ee.weld;
import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.server.deployment.DeploymentUnit;
diff --git a/ejb3/pom.xml b/ejb3/pom.xml
index 7526de22affe..53aa2779f89b 100644
--- a/ejb3/pom.xml
+++ b/ejb3/pom.xml
@@ -101,7 +101,7 @@ vi:ts=4:sw=4:expandtab
org.hibernate.javax.persistence
- hibernate-jpa-2.0-api
+ hibernate-jpa-2.1-api
diff --git a/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsCdiIntegrationProcessor.java b/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsCdiIntegrationProcessor.java
index d6012de40c0c..80a82e465708 100644
--- a/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsCdiIntegrationProcessor.java
+++ b/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsCdiIntegrationProcessor.java
@@ -31,7 +31,7 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.web.common.WarMetaData;
-import org.jboss.as.weld.WeldDeploymentMarker;
+import org.jboss.as.ee.weld.WeldDeploymentMarker;
import org.jboss.as.weld.deployment.WeldAttachments;
import org.jboss.metadata.javaee.spec.ParamValueMetaData;
import org.jboss.metadata.web.jboss.JBossWebMetaData;
diff --git a/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsDependencyProcessor.java b/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsDependencyProcessor.java
index 732454e3dba6..f1a59a92de1c 100644
--- a/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsDependencyProcessor.java
+++ b/jaxrs/src/main/java/org/jboss/as/jaxrs/deployment/JaxrsDependencyProcessor.java
@@ -29,7 +29,7 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.module.ModuleDependency;
import org.jboss.as.server.deployment.module.ModuleSpecification;
-import org.jboss.as.weld.WeldDeploymentMarker;
+import org.jboss.as.ee.weld.WeldDeploymentMarker;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoader;
diff --git a/jpa/core/pom.xml b/jpa/core/pom.xml
index 7fbaa49f9ba2..dcee0228a91b 100644
--- a/jpa/core/pom.xml
+++ b/jpa/core/pom.xml
@@ -71,10 +71,16 @@
- org.wildfly
- wildfly-jpa-spi
+ org.jipijapa
+ spi
+
+
+
+ org.jipijapa
+ core
+
org.wildfly
wildfly-jpa-util
@@ -100,5 +106,10 @@
pom
test
+
+
+ javax.enterprise
+ cdi-api
+
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/classloader/JPADelegatingClassFileTransformer.java b/jpa/core/src/main/java/org/jboss/as/jpa/classloader/JPADelegatingClassFileTransformer.java
index 8198e368f30f..1cdcece7914a 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/classloader/JPADelegatingClassFileTransformer.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/classloader/JPADelegatingClassFileTransformer.java
@@ -26,7 +26,7 @@
import java.lang.instrument.IllegalClassFormatException;
import java.security.ProtectionDomain;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Helps implement PersistenceUnitInfo.addClassTransformer() by using DelegatingClassFileTransformer
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/classloader/TempClassLoaderFactoryImpl.java b/jpa/core/src/main/java/org/jboss/as/jpa/classloader/TempClassLoaderFactoryImpl.java
index e360330648ac..c885abc3ecf5 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/classloader/TempClassLoaderFactoryImpl.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/classloader/TempClassLoaderFactoryImpl.java
@@ -22,7 +22,7 @@
package org.jboss.as.jpa.classloader;
-import org.jboss.as.jpa.spi.TempClassLoaderFactory;
+import org.jipijapa.plugin.spi.TempClassLoaderFactory;
/**
* Factory implementation that creates {@link TempClassLoader} instances.
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/config/Configuration.java b/jpa/core/src/main/java/org/jboss/as/jpa/config/Configuration.java
index dd2a58daafaa..db0df4b11c04 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/config/Configuration.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/config/Configuration.java
@@ -25,7 +25,8 @@
import java.util.HashMap;
import java.util.Map;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
+
/**
* configuration properties that may appear in persistence.xml
@@ -39,9 +40,14 @@ public class Configuration {
public static final String PROVIDER_MODULE = "jboss.as.jpa.providerModule";
/**
- * Hibernate 4 persistence provider
+ * Hibernate 4.3.x (default) persistence provider
+ */
+ public static final String PROVIDER_MODULE_HIBERNATE4_3 = "org.hibernate";
+
+ /**
+ * Hibernate 4.1.x persistence provider, note that Hibernate 4.1.x is expected to be in the 4.1 slot
*/
- public static final String PROVIDER_MODULE_HIBERNATE4 = "org.hibernate";
+ public static final String PROVIDER_MODULE_HIBERNATE4_1 = "org.hibernate:4.1";
/**
* Hibernate OGM persistence provider
@@ -66,12 +72,17 @@ public class Configuration {
/**
* default if no PROVIDER_MODULE is specified.
*/
- public static final String PROVIDER_MODULE_DEFAULT = PROVIDER_MODULE_HIBERNATE4;
+ public static final String PROVIDER_MODULE_DEFAULT = PROVIDER_MODULE_HIBERNATE4_3;
+
+ /**
+ * Hibernate 4.1.x persistence provider class
+ */
+ public static final String PROVIDER_CLASS_HIBERNATE4_1 = "org.hibernate.ejb.HibernatePersistence";
/**
- * Hibernate persistence provider class
+ * Hibernate 4.3.x persistence provider class
*/
- public static final String PROVIDER_CLASS_HIBERNATE = "org.hibernate.ejb.HibernatePersistence";
+ public static final String PROVIDER_CLASS_HIBERNATE = "org.hibernate.jpa.HibernatePersistenceProvider";
/**
* Hibernate OGM persistence provider class
@@ -157,7 +168,8 @@ public class Configuration {
static {
// always choose the default hibernate version for the Hibernate provider class mapping
// if the user wants a different version. they can specify the provider module name
- providerClassToModuleName.put(PROVIDER_CLASS_HIBERNATE, PROVIDER_MODULE_HIBERNATE4);
+ providerClassToModuleName.put(PROVIDER_CLASS_HIBERNATE, PROVIDER_MODULE_HIBERNATE4_3);
+ providerClassToModuleName.put(PROVIDER_CLASS_HIBERNATE4_1, PROVIDER_MODULE_HIBERNATE4_1);
providerClassToModuleName.put(PROVIDER_CLASS_HIBERNATE_OGM, PROVIDER_MODULE_HIBERNATE_OGM);
providerClassToModuleName.put(PROVIDER_CLASS_TOPLINK_ESSENTIALS, PROVIDER_MODULE_TOPLINK);
providerClassToModuleName.put(PROVIDER_CLASS_TOPLINK, PROVIDER_MODULE_TOPLINK);
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceProviderDeploymentHolder.java b/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceProviderDeploymentHolder.java
index 40095650a34e..6a4d54bb9fdf 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceProviderDeploymentHolder.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceProviderDeploymentHolder.java
@@ -27,7 +27,7 @@
import javax.persistence.spi.PersistenceProvider;
-import org.jboss.as.jpa.spi.PersistenceProviderAdaptor;
+import org.jipijapa.plugin.spi.PersistenceProviderAdaptor;
/**
* holds the deployed persistence provider + adaptor
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceUnitMetadataHolder.java b/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceUnitMetadataHolder.java
index f10b04551187..fd515e0c3c02 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceUnitMetadataHolder.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceUnitMetadataHolder.java
@@ -26,8 +26,8 @@
import javax.persistence.spi.PersistenceUnitInfo;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.server.deployment.AttachmentKey;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Holds the defined persistence units
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceUnitMetadataImpl.java b/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceUnitMetadataImpl.java
index 44b56e3b747a..7f9395393cb0 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceUnitMetadataImpl.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/config/PersistenceUnitMetadataImpl.java
@@ -35,9 +35,9 @@
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.sql.DataSource;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
-import org.jboss.as.jpa.spi.TempClassLoaderFactory;
import org.jboss.jandex.Index;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
+import org.jipijapa.plugin.spi.TempClassLoaderFactory;
/**
* Represents the persistence unit definition
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/container/AbstractEntityManager.java b/jpa/core/src/main/java/org/jboss/as/jpa/container/AbstractEntityManager.java
index e6b45cc951c7..6ad57e677529 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/container/AbstractEntityManager.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/container/AbstractEntityManager.java
@@ -22,20 +22,26 @@
package org.jboss.as.jpa.container;
-import static org.jboss.as.jpa.JpaLogger.ROOT_LOGGER;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.ROOT_LOGGER;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
+import java.util.List;
import java.util.Map;
+import javax.persistence.EntityGraph;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.FlushModeType;
import javax.persistence.LockModeType;
import javax.persistence.Query;
+import javax.persistence.StoredProcedureQuery;
+import javax.persistence.SynchronizationType;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaDelete;
import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.CriteriaUpdate;
import javax.persistence.metamodel.Metamodel;
/**
@@ -62,7 +68,7 @@ public abstract class AbstractEntityManager implements EntityManager {
*/
protected abstract boolean isInTx();
-
+ public abstract SynchronizationType getSynchronizationType();
public T unwrap(Class cls) {
return getEntityManager().unwrap(cls);
@@ -658,6 +664,163 @@ public void setFlushMode(FlushModeType flushMode) {
}
}
+ public Query createQuery(CriteriaUpdate criteriaUpdate) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().createQuery(criteriaUpdate);
+
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("createQuery(CriteriaUpdate) took %dms", elapsed);
+ }
+ }
+ }
+
+ public Query createQuery(CriteriaDelete criteriaDelete) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().createQuery(criteriaDelete);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("createQuery(criteriaDelete) took %dms", elapsed);
+ }
+ }
+ }
+
+ public StoredProcedureQuery createNamedStoredProcedureQuery(String name) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().createNamedStoredProcedureQuery(name);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("createNamedStoredProcedureQuery %s took %dms", name, elapsed);
+ }
+ }
+ }
+
+ public StoredProcedureQuery createStoredProcedureQuery(String procedureName) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().createStoredProcedureQuery(procedureName);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("createStoredProcedureQuery %s took %dms", procedureName, elapsed);
+ }
+ }
+ }
+
+ public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().createStoredProcedureQuery(procedureName, resultClasses);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("createStoredProcedureQuery %s, resultClasses... took %dms", procedureName, elapsed);
+ }
+ }
+ }
+
+ public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().createStoredProcedureQuery(procedureName, resultSetMappings);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("createStoredProcedureQuery %s, resultSetMappings... took %dms", procedureName, elapsed);
+ }
+ }
+ }
+
+ public EntityGraph createEntityGraph(Class tClass) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().createEntityGraph(tClass);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("createEntityGraph %s took %dms", tClass.getName(), elapsed);
+ }
+ }
+
+ }
+
+ public EntityGraph> createEntityGraph(String s) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().createEntityGraph(s);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("createEntityGraph %s took %dms", s, elapsed);
+ }
+ }
+ }
+
+ public EntityGraph getEntityGraph(String s) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().getEntityGraph(s);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("getEntityGraph %s took %dms", s, elapsed);
+ }
+ }
+ }
+
+ public List> getEntityGraphs(Class tClass) {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().getEntityGraphs(tClass);
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("getEntityGraphs %s took %dms", tClass.getName(), elapsed);
+ }
+ }
+ }
+
+ public boolean isJoinedToTransaction() {
+ long start = 0;
+ if (isTraceEnabled)
+ start = System.currentTimeMillis();
+ try {
+ return getEntityManager().isJoinedToTransaction();
+ } finally {
+ if (isTraceEnabled) {
+ long elapsed = System.currentTimeMillis() - start;
+ ROOT_LOGGER.tracef("isJoinedToTransaction() took %dms", elapsed);
+ }
+ }
+ }
+
+
// used by TransactionScopedEntityManager to auto detach loaded entities
// after each non-jta invocation
protected void detachNonTxInvocation(EntityManager underlyingEntityManager) {
@@ -715,5 +878,4 @@ private static String getLockModeAsString(LockModeType lockMode) {
}
}
-
}
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/container/CreatedEntityManagers.java b/jpa/core/src/main/java/org/jboss/as/jpa/container/CreatedEntityManagers.java
index 557f95b6c80b..55d4c3977e95 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/container/CreatedEntityManagers.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/container/CreatedEntityManagers.java
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
/**
* Tracks the lifecycle of created XPC Entity Managers
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/container/ExtendedEntityManager.java b/jpa/core/src/main/java/org/jboss/as/jpa/container/ExtendedEntityManager.java
index e027c7ad3bac..2815bbbb11f6 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/container/ExtendedEntityManager.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/container/ExtendedEntityManager.java
@@ -22,14 +22,14 @@
package org.jboss.as.jpa.container;
-import static org.jboss.as.jpa.JpaLogger.ROOT_LOGGER;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.ROOT_LOGGER;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.io.Serializable;
import javax.persistence.EntityManager;
+import javax.persistence.SynchronizationType;
-import org.jboss.as.jpa.JpaMessages;
import org.jboss.as.jpa.transaction.TransactionUtil;
/**
@@ -190,7 +190,7 @@ else if (isTraceEnabled) {
// referenceCount should never be negative, if it is we need to fix the bug that caused it to decrement too much
if (referenceCount < 0) {
- throw JpaMessages.MESSAGES.referenceCountedEntityManagerNegativeCount(referenceCount, getScopedPuName());
+ throw MESSAGES.referenceCountedEntityManagerNegativeCount(referenceCount, getScopedPuName());
}
}
@@ -239,4 +239,8 @@ public int hashCode() {
return ID != null ? ID.hashCode() : 0;
}
+ @Override
+ public SynchronizationType getSynchronizationType() {
+ return SynchronizationType.SYNCHRONIZED;
+ }
}
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/container/NonTxEmCloser.java b/jpa/core/src/main/java/org/jboss/as/jpa/container/NonTxEmCloser.java
index eb8c7de76774..97a700e7b5f3 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/container/NonTxEmCloser.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/container/NonTxEmCloser.java
@@ -22,7 +22,7 @@
package org.jboss.as.jpa.container;
-import static org.jboss.as.jpa.JpaLogger.ROOT_LOGGER;
+import static org.jboss.as.jpa.messages.JpaLogger.ROOT_LOGGER;
import java.util.HashMap;
import java.util.Map;
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/container/PersistenceUnitSearch.java b/jpa/core/src/main/java/org/jboss/as/jpa/container/PersistenceUnitSearch.java
index 30bce41c0267..673aff5bf7ef 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/container/PersistenceUnitSearch.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/container/PersistenceUnitSearch.java
@@ -22,19 +22,19 @@
package org.jboss.as.jpa.container;
-import static org.jboss.as.jpa.JpaLogger.ROOT_LOGGER;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.ROOT_LOGGER;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.util.List;
import org.jboss.as.jpa.config.PersistenceUnitMetadataHolder;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUtils;
import org.jboss.as.server.deployment.SubDeploymentMarker;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.vfs.VirtualFile;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Perform scoped search for persistence unit name
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/container/ThreadLocalStack.java b/jpa/core/src/main/java/org/jboss/as/jpa/container/ThreadLocalStack.java
index 96917fffae40..e70f212bde97 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/container/ThreadLocalStack.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/container/ThreadLocalStack.java
@@ -21,7 +21,7 @@
*/
package org.jboss.as.jpa.container;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.util.ArrayList;
import java.util.List;
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/container/TransactionScopedEntityManager.java b/jpa/core/src/main/java/org/jboss/as/jpa/container/TransactionScopedEntityManager.java
index 4fbe31bb9c46..816016ce702d 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/container/TransactionScopedEntityManager.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/container/TransactionScopedEntityManager.java
@@ -30,6 +30,7 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
+import javax.persistence.SynchronizationType;
import org.jboss.as.jpa.service.PersistenceUnitServiceImpl;
import org.jboss.as.jpa.transaction.TransactionUtil;
@@ -38,7 +39,8 @@
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.JPA_LOGGER;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
/**
* Transaction scoped entity manager will be injected into SLSB or SFSB beans. At bean invocation time, they
@@ -51,35 +53,38 @@
*/
public class TransactionScopedEntityManager extends AbstractEntityManager implements Serializable {
- private static final long serialVersionUID = 455498111L;
+ private static final long serialVersionUID = 455498112L;
private final String puScopedName; // Scoped name of the persistent unit
private final Map properties;
private transient EntityManagerFactory emf;
+ private transient boolean isJPA21=true; // true if persistence provider supports JPA 2.1
+ private final SynchronizationType synchronizationType;
- public TransactionScopedEntityManager(String puScopedName, Map properties, EntityManagerFactory emf) {
+ public TransactionScopedEntityManager(String puScopedName, Map properties, EntityManagerFactory emf, SynchronizationType synchronizationType) {
this.puScopedName = puScopedName;
this.properties = properties;
this.emf = emf;
+ this.synchronizationType = synchronizationType;
}
@Override
protected EntityManager getEntityManager() {
- EntityManager result;
+ EntityManager entityManager;
boolean isInTx;
isInTx = TransactionUtil.isInTx();
if (isInTx) {
- result = TransactionUtil.getOrCreateTransactionScopedEntityManager(emf, puScopedName, properties);
+ entityManager = getOrCreateTransactionScopedEntityManager(emf, puScopedName, properties, synchronizationType);
} else {
- result = NonTxEmCloser.get(puScopedName);
- if (result == null) {
- result = EntityManagerUtil.createEntityManager(emf, properties);
- NonTxEmCloser.add(puScopedName, result);
+ entityManager = NonTxEmCloser.get(puScopedName);
+ if (entityManager == null) {
+ entityManager = createEntityManager(emf, properties, synchronizationType);
+ NonTxEmCloser.add(puScopedName, entityManager);
}
}
- return result;
+ return entityManager;
}
@Override
@@ -107,6 +112,7 @@ private void readObject(java.io.ObjectInputStream in) throws IOException, ClassN
final ServiceController> controller = currentServiceContainer().getService(JPAServiceNames.getPUServiceName(puScopedName));
final PersistenceUnitServiceImpl persistenceUnitService = (PersistenceUnitServiceImpl) controller.getService();
emf = persistenceUnitService.getEntityManagerFactory();
+ isJPA21 = true;
}
@@ -118,4 +124,83 @@ public ServiceContainer run() {
}
});
}
+
+ @Override
+ public SynchronizationType getSynchronizationType() {
+ return synchronizationType;
+ }
+
+ /**
+ * get or create a Transactional entity manager.
+ * Only call while a transaction is active in the current thread.
+ *
+ * @param emf
+ * @param scopedPuName
+ * @param properties
+ * @param synchronizationType
+ * @return
+ */
+ private EntityManager getOrCreateTransactionScopedEntityManager(
+ final EntityManagerFactory emf,
+ final String scopedPuName,
+ final Map properties,
+ final SynchronizationType synchronizationType) {
+ EntityManager entityManager = TransactionUtil.getTransactionScopedEntityManager(puScopedName);
+ if (entityManager == null) {
+ entityManager = createEntityManager(emf, properties, synchronizationType);
+ if (JPA_LOGGER.isDebugEnabled())
+ JPA_LOGGER.debugf("%s: created entity manager session %s", TransactionUtil.getEntityManagerDetails(entityManager),
+ TransactionUtil.getTransaction().toString());
+ TransactionUtil.registerSynchronization(entityManager, scopedPuName);
+ TransactionUtil.putEntityManagerInTransactionRegistry(scopedPuName, entityManager);
+ }
+ else {
+ testForMixedSyncronizationTypes(entityManager, puScopedName, synchronizationType);
+ if (JPA_LOGGER.isDebugEnabled()) {
+ JPA_LOGGER.debugf("%s: reuse entity manager session already in tx %s", TransactionUtil.getEntityManagerDetails(entityManager),
+ getTransaction().toString());
+ }
+ }
+ return entityManager;
+ }
+
+ private EntityManager createEntityManager(
+ EntityManagerFactory emf, Map properties, final SynchronizationType synchronizationType) {
+ if (isJPA21()) {
+ try {
+ return emf.createEntityManager(synchronizationType, properties); // properties may be null in jpa 2.1
+ } catch (AbstractMethodError consideredNotJPA21Exception) { // dealing with JPA 1.0 or 2.0 provider?
+ setJPA21(false);
+ }
+
+ }
+
+ if (properties != null && properties.size() > 0) {
+ return emf.createEntityManager(properties);
+ }
+ return emf.createEntityManager();
+ }
+
+ private boolean isJPA21() {
+ return isJPA21;
+ }
+
+ private void setJPA21(boolean value) {
+ isJPA21 = value;
+ }
+
+
+ /**
+ * throw error if jta transaction already has an UNSYNCHRONIZED persistence context and a SYNCHRONIZED persistence context
+ * is requested. We are only fussy in this test, if the target component persistence context is SYNCHRONIZED.
+ */
+ private static void testForMixedSyncronizationTypes(EntityManager entityManager, String scopedPuName, final SynchronizationType targetSynchronizationType) {
+ if (SynchronizationType.SYNCHRONIZED.equals(targetSynchronizationType)
+ && entityManager instanceof AbstractEntityManager
+ && SynchronizationType.UNSYNCHRONIZED.equals( ((AbstractEntityManager)entityManager).getSynchronizationType())) {
+ throw MESSAGES.badSynchronizationTypeCombination(scopedPuName);
+ }
+ }
+
+
}
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/injectors/PersistenceContextInjectionSource.java b/jpa/core/src/main/java/org/jboss/as/jpa/injectors/PersistenceContextInjectionSource.java
index ac25e6797fc6..c14da3f56ea8 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/injectors/PersistenceContextInjectionSource.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/injectors/PersistenceContextInjectionSource.java
@@ -22,8 +22,8 @@
package org.jboss.as.jpa.injectors;
-import static org.jboss.as.jpa.JpaLogger.JPA_LOGGER;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.JPA_LOGGER;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.lang.reflect.Proxy;
import java.util.Map;
@@ -31,6 +31,7 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContextType;
+import javax.persistence.SynchronizationType;
import org.jboss.as.ee.component.InjectionSource;
import org.jboss.as.jpa.config.ExtendedPersistenceInheritance;
@@ -44,7 +45,6 @@
import org.jboss.as.jpa.processor.JpaAttachments;
import org.jboss.as.jpa.service.JPAService;
import org.jboss.as.jpa.service.PersistenceUnitServiceImpl;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.naming.ManagedReference;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.ValueManagedReference;
@@ -56,6 +56,7 @@
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.value.ImmediateValue;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Represents the PersistenceContext injected into a component.
@@ -82,11 +83,11 @@ public class PersistenceContextInjectionSource extends InjectionSource {
* for example "org.hibernate.Session" in which case, EntityManager.unwrap(org.hibernate.Session.class is called)
* @param pu
*/
- public PersistenceContextInjectionSource(final PersistenceContextType type, final Map properties, final ServiceName puServiceName, final DeploymentUnit deploymentUnit, final String scopedPuName, final String injectionTypeName, final PersistenceUnitMetadata pu) {
+ public PersistenceContextInjectionSource(final PersistenceContextType type, final SynchronizationType synchronizationType , final Map properties, final ServiceName puServiceName, final DeploymentUnit deploymentUnit, final String scopedPuName, final String injectionTypeName, final PersistenceUnitMetadata pu) {
this.type = type;
- injectable = new PersistenceContextJndiInjectable(puServiceName, deploymentUnit, this.type, properties, scopedPuName, injectionTypeName, pu);
+ injectable = new PersistenceContextJndiInjectable(puServiceName, deploymentUnit, this.type, synchronizationType , properties, scopedPuName, injectionTypeName, pu);
this.puServiceName = puServiceName;
}
@@ -113,6 +114,7 @@ private static final class PersistenceContextJndiInjectable implements ManagedRe
private final ServiceName puServiceName;
private final DeploymentUnit deploymentUnit;
private final PersistenceContextType type;
+ private final SynchronizationType synchronizationType;
private final Map properties;
private final String unitName;
private final String injectionTypeName;
@@ -124,6 +126,7 @@ public PersistenceContextJndiInjectable(
final ServiceName puServiceName,
final DeploymentUnit deploymentUnit,
final PersistenceContextType type,
+ SynchronizationType synchronizationType,
final Map properties,
final String unitName,
final String injectionTypeName,
@@ -136,6 +139,7 @@ public PersistenceContextJndiInjectable(
this.unitName = unitName;
this.injectionTypeName = injectionTypeName;
this.pu = pu;
+ this.synchronizationType = synchronizationType;
}
@Override
@@ -146,7 +150,7 @@ public ManagedReference getReference() {
boolean standardEntityManager = ENTITY_MANAGER_CLASS.equals(injectionTypeName);
if (type.equals(PersistenceContextType.TRANSACTION)) {
- entityManager = new TransactionScopedEntityManager(unitName, properties, emf);
+ entityManager = new TransactionScopedEntityManager(unitName, properties, emf, synchronizationType);
if (JPA_LOGGER.isDebugEnabled())
JPA_LOGGER.debugf("created new TransactionScopedEntityManager for unit name=%s", unitName);
} else {
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/injectors/PersistenceUnitInjectionSource.java b/jpa/core/src/main/java/org/jboss/as/jpa/injectors/PersistenceUnitInjectionSource.java
index 2fe0d1ad8589..4b8d027bfc95 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/injectors/PersistenceUnitInjectionSource.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/injectors/PersistenceUnitInjectionSource.java
@@ -23,9 +23,7 @@
package org.jboss.as.jpa.injectors;
-//import org.hibernate.ejb.EntityManagerFactoryImpl;
-
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -34,7 +32,6 @@
import org.jboss.as.ee.component.InjectionSource;
import org.jboss.as.jpa.service.PersistenceUnitServiceImpl;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.naming.ManagedReference;
import org.jboss.as.naming.ManagedReferenceFactory;
import org.jboss.as.naming.ValueManagedReference;
@@ -45,6 +42,7 @@
import org.jboss.msc.service.ServiceBuilder;
import org.jboss.msc.service.ServiceName;
import org.jboss.msc.value.ImmediateValue;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Represents the PersistenceUnit injected into a component.
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/management/DynamicManagementStatisticsResource.java b/jpa/core/src/main/java/org/jboss/as/jpa/management/DynamicManagementStatisticsResource.java
new file mode 100644
index 000000000000..7efbd2a3eb44
--- /dev/null
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/management/DynamicManagementStatisticsResource.java
@@ -0,0 +1,214 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.jpa.management;
+
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.registry.PlaceholderResource;
+import org.jboss.as.controller.registry.Resource;
+import org.jboss.dmr.ModelNode;
+import org.jipijapa.management.spi.Statistics;
+
+/**
+ * Resource representing a JPA PersistenceUnit (from a persistence.xml) deployment.
+ *
+ * @author Brian Stansberry (c) 2011 Red Hat Inc.
+ * @author Scott Marlow
+ */
+public class DynamicManagementStatisticsResource extends PlaceholderResource.PlaceholderResourceEntry {
+
+ private final String puName;
+ private final ModelNode model = new ModelNode();
+ private final Statistics statistics;
+ private final String identificationLabel;
+ private final EntityManagerFactoryLookup entityManagerFactoryLookup;
+
+ public DynamicManagementStatisticsResource(
+ final Statistics statistics,
+ final String puName,
+ final String identificationLabel,
+ final EntityManagerFactoryLookup entityManagerFactoryLookup) {
+ super(identificationLabel, puName);
+ this.puName = puName;
+ this.statistics = statistics;
+ this.identificationLabel = identificationLabel;
+ this.entityManagerFactoryLookup = entityManagerFactoryLookup;
+ }
+
+ @Override
+ public ModelNode getModel() {
+ return model;
+ }
+
+ @Override
+ public boolean isModelDefined() {
+ return model.isDefined();
+ }
+
+ @Override
+ public boolean hasChild(PathElement element) {
+ Statistics statistics = getStatistics();
+ // if element key matches, check if element value also matches
+ if (statistics.getChildrenNames().contains(element.getKey())) {
+ Statistics childStatistics = statistics.getChild(element.getKey());
+ return childStatistics != null && childStatistics.getDynamicChildrenNames(entityManagerFactoryLookup, PathWrapper.path(puName)).contains(element.getValue());
+ } else {
+ return super.hasChild(element);
+ }
+ }
+
+ @Override
+ public Resource getChild(PathElement element) {
+
+ Statistics statistics = getStatistics();
+ if (statistics.getChildrenNames().contains(element.getKey())) {
+ Statistics childStatistics = statistics.getChild(element.getKey());
+ return childStatistics != null && childStatistics.getDynamicChildrenNames(entityManagerFactoryLookup, PathWrapper.path(puName)).contains(element.getValue())
+ ? PlaceholderResource.INSTANCE : null;
+ } else {
+ return super.getChild(element);
+ }
+ }
+
+ @Override
+ public Resource requireChild(PathElement element) {
+ Statistics statistics = getStatistics();
+ if (statistics.getChildrenNames().contains(element.getKey())) {
+ Statistics childStatistics = statistics.getChild(element.getKey());
+ if (childStatistics != null && childStatistics.getDynamicChildrenNames(entityManagerFactoryLookup, PathWrapper.path(puName)).contains(element.getValue())) {
+ return PlaceholderResource.INSTANCE;
+ }
+ throw new NoSuchResourceException(element);
+ } else {
+ return super.requireChild(element);
+ }
+ }
+
+ @Override
+ public boolean hasChildren(String childType) {
+ Statistics statistics = getStatistics();
+ if (statistics.getChildrenNames().contains(childType)) {
+ Statistics childStatistics = statistics.getChild(childType);
+ return childStatistics != null && childStatistics.getNames().size() > 0;
+ } else {
+ return super.hasChildren(childType);
+ }
+ }
+
+ @Override
+ public Resource navigate(PathAddress address) {
+ Statistics statistics = getStatistics();
+ if (address.size() > 0 && statistics.getChildrenNames().contains(address.getElement(0).getKey())) {
+ if (address.size() > 1) {
+ throw new NoSuchResourceException(address.getElement(1));
+ }
+ return PlaceholderResource.INSTANCE;
+ } else {
+ return super.navigate(address);
+ }
+ }
+
+ @Override
+ public Set getChildTypes() {
+ Set result = new HashSet(super.getChildTypes());
+ Statistics statistics = getStatistics();
+ result.addAll(statistics.getChildrenNames());
+ return result;
+ }
+
+ @Override
+ public Set getChildrenNames(String childType) {
+ Statistics statistics = getStatistics();
+ if (statistics.getChildrenNames().contains(childType)) {
+ Statistics childStatistics = statistics.getChild(childType);
+ Setresult = new HashSet();
+ for(String name:childStatistics.getDynamicChildrenNames(entityManagerFactoryLookup, PathWrapper.path(puName))) {
+ result.add(name);
+ }
+ return result;
+ } else {
+ return super.getChildrenNames(childType);
+ }
+ }
+
+ @Override
+ public Set getChildren(String childType) {
+
+ Statistics statistics = getStatistics();
+ if (statistics.getChildrenNames().contains(childType)) {
+ Set result = new HashSet();
+ Statistics childStatistics = statistics.getChild(childType);
+ for (String name : childStatistics.getDynamicChildrenNames(entityManagerFactoryLookup, PathWrapper.path(puName))) {
+ result.add(new PlaceholderResource.PlaceholderResourceEntry(childType, name));
+ }
+ return result;
+ } else {
+ return super.getChildren(childType);
+ }
+
+ }
+
+ @Override
+ public void registerChild(PathElement address, Resource resource) {
+ Statistics statistics = getStatistics();
+ if (statistics.getChildrenNames().contains(address.getKey())) {
+ throw MESSAGES.resourcesOfTypeCannotBeRegistered(address.getKey());
+ } else {
+ super.registerChild(address, resource);
+ }
+ }
+
+ @Override
+ public Resource removeChild(PathElement address) {
+ Statistics statistics = getStatistics();
+ if (statistics.getChildrenNames().contains(address.getKey())) {
+ throw MESSAGES.resourcesOfTypeCannotBeRemoved(address.getKey());
+ } else {
+ return super.removeChild(address);
+ }
+ }
+
+ @Override
+ public boolean isRuntime() {
+ return false;
+ }
+
+ @Override
+ public boolean isProxy() {
+ return false;
+ }
+
+ @Override
+ public DynamicManagementStatisticsResource clone() {
+ return new DynamicManagementStatisticsResource(statistics, puName, identificationLabel, entityManagerFactoryLookup);
+ }
+
+ private Statistics getStatistics() {
+ return statistics;
+ }
+}
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/container/EntityManagerUtil.java b/jpa/core/src/main/java/org/jboss/as/jpa/management/EntityManagerFactoryLookup.java
similarity index 64%
rename from jpa/core/src/main/java/org/jboss/as/jpa/container/EntityManagerUtil.java
rename to jpa/core/src/main/java/org/jboss/as/jpa/management/EntityManagerFactoryLookup.java
index e92c8b1bdbea..ab59abb691ac 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/container/EntityManagerUtil.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/management/EntityManagerFactoryLookup.java
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
+ * Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -20,29 +20,23 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.jpa.container;
+package org.jboss.as.jpa.management;
-import java.util.Map;
-
-import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
+import org.jboss.as.jpa.subsystem.PersistenceUnitRegistryImpl;
+import org.jipijapa.management.spi.EntityManagerFactoryAccess;
+
/**
- * EntityManager utilities
+ * EntityManagerFactoryLookup
*
* @author Scott Marlow
*/
-public class EntityManagerUtil {
-
- public static EntityManager createEntityManager(
- EntityManagerFactory emf, Map properties) {
+public class EntityManagerFactoryLookup implements EntityManagerFactoryAccess {
- EntityManager result;
- if (properties != null && properties.size() > 0)
- result = emf.createEntityManager(properties);
- else
- result = emf.createEntityManager();
- return result;
+ @Override
+ public EntityManagerFactory entityManagerFactory(final String scopedPersistenceUnitName) {
+ return PersistenceUnitRegistryImpl.INSTANCE.getPersistenceUnitService(scopedPersistenceUnitName).getEntityManagerFactory();
}
}
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/management/ManagementResourceDefinition.java b/jpa/core/src/main/java/org/jboss/as/jpa/management/ManagementResourceDefinition.java
new file mode 100644
index 000000000000..3a80f997e4ce
--- /dev/null
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/management/ManagementResourceDefinition.java
@@ -0,0 +1,261 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.jpa.management;
+
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADDRESS;
+
+import org.jboss.as.controller.AbstractRuntimeOnlyHandler;
+import org.jboss.as.controller.AttributeDefinition;
+import org.jboss.as.controller.OperationContext;
+import org.jboss.as.controller.OperationFailedException;
+import org.jboss.as.controller.OperationStepHandler;
+import org.jboss.as.controller.PathAddress;
+import org.jboss.as.controller.PathElement;
+import org.jboss.as.controller.SimpleAttributeDefinitionBuilder;
+import org.jboss.as.controller.SimpleOperationDefinition;
+import org.jboss.as.controller.SimpleResourceDefinition;
+import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
+import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
+import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
+import org.jboss.as.controller.registry.AttributeAccess;
+import org.jboss.as.controller.registry.ManagementResourceRegistration;
+import org.jboss.dmr.ModelNode;
+import org.jboss.dmr.ModelType;
+import org.jipijapa.management.spi.Statistics;
+
+
+/**
+* ManagementResourceDefinition
+*
+* @author Scott Marlow
+*/
+public class ManagementResourceDefinition extends SimpleResourceDefinition {
+
+ private final Statistics statistics;
+ private final EntityManagerFactoryLookup entityManagerFactoryLookup;
+ private final ResourceDescriptionResolver descriptionResolver;
+
+ public ManagementResourceDefinition(
+ final PathElement pathElement,
+ final ResourceDescriptionResolver descriptionResolver,
+ final Statistics statistics,
+ final EntityManagerFactoryLookup entityManagerFactoryLookup) {
+ super(pathElement, descriptionResolver);
+ this.statistics = statistics;
+ this.entityManagerFactoryLookup = entityManagerFactoryLookup;
+ this.descriptionResolver = descriptionResolver;
+ }
+
+ private ModelType getModelType(Class type) {
+
+ if(Integer.class.equals(type)) {
+ return ModelType.INT;
+ }
+ else if(Long.class.equals(type)) {
+ return ModelType.LONG;
+ }
+ else if(String.class.equals(type)) {
+ return ModelType.STRING;
+ }
+ else if(Boolean.class.equals(type)) {
+ return ModelType.BOOLEAN;
+ }
+ return ModelType.OBJECT;
+ }
+
+ @Override
+ public void registerChildren(ManagementResourceRegistration resourceRegistration) {
+ super.registerChildren(resourceRegistration);
+
+ for( final String sublevelChildName : statistics.getChildrenNames()) {
+ Statistics sublevelStatistics = statistics.getChild(sublevelChildName);
+ ResourceDescriptionResolver sublevelResourceDescriptionResolver = new StandardResourceDescriptionResolver(
+ sublevelChildName, sublevelStatistics.getResourceBundleName(), sublevelStatistics.getClass().getClassLoader());
+ resourceRegistration.registerSubModel(
+ new ManagementResourceDefinition(PathElement.pathElement(sublevelChildName), sublevelResourceDescriptionResolver, sublevelStatistics, entityManagerFactoryLookup));
+
+ }
+ }
+
+ @Override
+ public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
+ super.registerAttributes(resourceRegistration);
+
+ for(final String statisticName: statistics.getNames()) {
+ final ModelType modelType = getModelType(statistics.getType(statisticName));
+ AttributeDefinition attributeDefinition =
+ new SimpleAttributeDefinitionBuilder(statisticName, modelType, true)
+ .setXmlName(statisticName)
+ .setAllowExpression(true)
+ .setFlags(AttributeAccess.Flag.STORAGE_RUNTIME)
+ .build();
+
+ if (statistics.isAttribute(statisticName)) {
+ OperationStepHandler readHandler =
+ new AbstractMetricsHandler() {
+ @Override
+ void handle(final ModelNode response, OperationContext context, final ModelNode operation) {
+ Object result = statistics.getValue(
+ statisticName,
+ entityManagerFactoryLookup,
+ StatisticNameLookup.statisticNameLookup(statisticName),
+ Path.path(PathAddress.pathAddress(operation.get(ADDRESS))));
+ if (result != null) {
+ setResponse(response, result, modelType);
+ }
+ }
+ };
+
+ // handle writeable attributes
+ if (statistics.isWriteable(statisticName)) {
+ OperationStepHandler writeHandler =
+ new AbstractMetricsHandler() {
+ @Override
+ void handle(final ModelNode response, OperationContext context, final ModelNode operation) {
+
+ Object oldSetting = statistics.getValue(
+ statisticName,
+ entityManagerFactoryLookup,
+ StatisticNameLookup.statisticNameLookup(statisticName),
+ Path.path(PathAddress.pathAddress(operation.get(ADDRESS))));
+ {
+ final ModelNode value = operation.get(ModelDescriptionConstants.VALUE).resolve();
+
+ if (Boolean.class.equals(statistics.getType(statisticName))) {
+ statistics.setValue(
+ statisticName,
+ value.asBoolean(),
+ entityManagerFactoryLookup,
+ StatisticNameLookup.statisticNameLookup(statisticName),
+ Path.path(PathAddress.pathAddress(operation.get(ADDRESS))));
+ } else if(Integer.class.equals(statistics.getType(statisticName))) {
+ statistics.setValue(
+ statisticName,
+ value.asInt(),
+ entityManagerFactoryLookup,
+ StatisticNameLookup.statisticNameLookup(statisticName),
+ Path.path(PathAddress.pathAddress(operation.get(ADDRESS))));
+ } else if(Long.class.equals(statistics.getType(statisticName))) {
+ statistics.setValue(
+ statisticName,
+ value.asLong(),
+ entityManagerFactoryLookup,
+ StatisticNameLookup.statisticNameLookup(statisticName),
+ Path.path(PathAddress.pathAddress(operation.get(ADDRESS))));
+ } else {
+ statistics.setValue(
+ statisticName,
+ value.asString(),
+ entityManagerFactoryLookup,
+ StatisticNameLookup.statisticNameLookup(statisticName),
+ Path.path(PathAddress.pathAddress(operation.get(ADDRESS))));
+ }
+
+ }
+ final Object rollBackValue = oldSetting;
+ context.completeStep(new OperationContext.RollbackHandler() {
+ @Override
+ public void handleRollback(OperationContext context, ModelNode operation) {
+ statistics.setValue(
+ statisticName,
+ rollBackValue,
+ entityManagerFactoryLookup,
+ StatisticNameLookup.statisticNameLookup(statisticName),
+ Path.path(PathAddress.pathAddress(operation.get(ADDRESS))));
+ }
+ });
+ }
+ };
+ resourceRegistration.registerReadWriteAttribute(attributeDefinition, readHandler, writeHandler);
+
+ }
+ else {
+ resourceRegistration.registerMetric(attributeDefinition, readHandler);
+ }
+ }
+ }
+ }
+
+ private void setResponse(ModelNode response, Object result, ModelType modelType) {
+ if (ModelType.INT.equals(modelType)) {
+ response.set( ((Integer)result).intValue()); // TODO: JIPI-9 switch to value wrapper
+ }
+ else if (ModelType.LONG.equals(modelType)) {
+ response.set( ((Long)result).longValue()); // TODO: JIPI-9 switch to value wrapper
+ }
+ else if (ModelType.BOOLEAN.equals(modelType)) {
+ response.set( ((Boolean)result).booleanValue()); // TODO: JIPI-9 switch to value wrapper
+ }
+ else {
+ response.set(result.toString()); // ModelType.STRING
+ }
+ }
+
+ @Override
+ public void registerOperations(ManagementResourceRegistration resourceRegistration) {
+ super.registerOperations(resourceRegistration);
+
+ for(final String statisticName: statistics.getNames()) {
+ final ModelType modelType = getModelType(statistics.getType(statisticName));
+ if(statistics.isOperation(statisticName)) {
+ AttributeDefinition attributeDefinition =
+ new SimpleAttributeDefinitionBuilder(statisticName, modelType, true)
+ .setXmlName(statisticName)
+ .setAllowExpression(true)
+ .setFlags(AttributeAccess.Flag.STORAGE_RUNTIME)
+ .build();
+
+ OperationStepHandler operationHandler =
+ new AbstractMetricsHandler() {
+ @Override
+ void handle(final ModelNode response, OperationContext context, final ModelNode operation) {
+ Object result = statistics.getValue(
+ statisticName, entityManagerFactoryLookup,
+ StatisticNameLookup.statisticNameLookup(statisticName),
+ Path.path(PathAddress.pathAddress(operation.get(ADDRESS))));
+ if (result != null) {
+ setResponse(response, result, modelType);
+ }
+ }
+ };
+
+ SimpleOperationDefinition definition =
+ new SimpleOperationDefinition(statisticName, descriptionResolver, attributeDefinition);
+ resourceRegistration.registerOperationHandler(definition, operationHandler);
+ }
+ }
+ }
+
+ private abstract static class AbstractMetricsHandler extends AbstractRuntimeOnlyHandler {
+
+ abstract void handle(final ModelNode response, final OperationContext context, final ModelNode operation);
+
+ @Override
+ protected void executeRuntimeStep(final OperationContext context, final ModelNode operation) throws
+ OperationFailedException {
+ handle(context.getResult(), context, operation);
+ context.stepCompleted();
+ }
+ }
+
+}
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/management/Path.java b/jpa/core/src/main/java/org/jboss/as/jpa/management/Path.java
new file mode 100644
index 000000000000..dff3ea0da81c
--- /dev/null
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/management/Path.java
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, Red Hat, Inc., and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.as.jpa.management;
+
+import java.util.ArrayList;
+
+import org.jboss.as.controller.PathElement;
+import org.jipijapa.management.spi.PathAddress;
+
+/**
+ * Path to a statistic value
+ *
+ * @author Scott Marlow
+ */
+public class Path implements PathAddress {
+ private final ArrayList pathElements = new ArrayList<>();
+
+ public Path(org.jboss.as.controller.PathAddress pathAddress) {
+
+ for (int looper = 0; looper < pathAddress.size(); looper++) {
+ pathElements.add(pathAddress.getElement(looper));
+ }
+ }
+
+ public static Path path(org.jboss.as.controller.PathAddress pathAddress) {
+ return new Path(pathAddress);
+ }
+ @Override
+ public int size() {
+ return pathElements.size();
+ }
+
+ @Override
+ public String getValue(String name) {
+ for ( PathElement pathElement : pathElements) {
+ if (pathElement.getKey().equals(name)) {
+ return pathElement.getValue();
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public String getValue(int index) {
+ return pathElements.get(index).getValue();
+ }
+}
diff --git a/jpa/spi/src/main/java/org/jboss/as/jpa/spi/PersistenceUnitService.java b/jpa/core/src/main/java/org/jboss/as/jpa/management/PathWrapper.java
similarity index 58%
rename from jpa/spi/src/main/java/org/jboss/as/jpa/spi/PersistenceUnitService.java
rename to jpa/core/src/main/java/org/jboss/as/jpa/management/PathWrapper.java
index 0fdcc1dc2af5..636ceff7dac0 100644
--- a/jpa/spi/src/main/java/org/jboss/as/jpa/spi/PersistenceUnitService.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/management/PathWrapper.java
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
+ * Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -20,28 +20,37 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.jpa.spi;
+package org.jboss.as.jpa.management;
-import javax.persistence.EntityManagerFactory;
+import org.jipijapa.management.spi.PathAddress;
/**
- * Persistence unit service
+ * Path wrapper for a static String value
*
* @author Scott Marlow
*/
-public interface PersistenceUnitService {
- /**
- * get the entity manager factory that represents the persistence unit service. This corresponds to a
- * persistence unit definition in a persistence.xml
- *
- * @return EntityManagerFactory or {@code null} if this service has not been started or has been stopped
- */
- EntityManagerFactory getEntityManagerFactory();
+public class PathWrapper implements PathAddress {
+ private final String value;
- /**
- * Gets the scoped name of this persistence unit.
- *
- * @return the name
- */
- String getScopedPersistenceUnitName();
+ public PathWrapper(String value) {
+ this.value = value;
+ }
+
+ public static PathWrapper path(String value) {
+ return new PathWrapper(value);
+ }
+ @Override
+ public int size() {
+ return 1;
+ }
+
+ @Override
+ public String getValue(String name) {
+ return value;
+ }
+
+ @Override
+ public String getValue(int index) {
+ return value;
+ }
}
diff --git a/jpa/spi/src/main/java/org/jboss/as/jpa/spi/JtaManager.java b/jpa/core/src/main/java/org/jboss/as/jpa/management/StatisticNameLookup.java
similarity index 65%
rename from jpa/spi/src/main/java/org/jboss/as/jpa/spi/JtaManager.java
rename to jpa/core/src/main/java/org/jboss/as/jpa/management/StatisticNameLookup.java
index 84861bc17352..c1a18a5a50c4 100644
--- a/jpa/spi/src/main/java/org/jboss/as/jpa/spi/JtaManager.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/management/StatisticNameLookup.java
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2011, Red Hat, Inc., and individual contributors
+ * Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -20,19 +20,29 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.jpa.spi;
+package org.jboss.as.jpa.management;
-import javax.transaction.TransactionManager;
-import javax.transaction.TransactionSynchronizationRegistry;
+import org.jipijapa.management.spi.StatisticName;
/**
- * Provides access to TSR + TM
+ * StatisticNameLookup
*
* @author Scott Marlow
*/
-public interface JtaManager {
+public class StatisticNameLookup implements StatisticName {
- TransactionSynchronizationRegistry getSynchronizationRegistry();
+ private final String name;
- TransactionManager locateTransactionManager();
+ public StatisticNameLookup(String name) {
+ this.name = name;
+ }
+
+ public static StatisticNameLookup statisticNameLookup(String name) {
+ return new StatisticNameLookup(name);
+ }
+
+ @Override
+ public String getName() {
+ return name;
+ }
}
diff --git a/jpa/spi/src/main/java/org/jboss/as/jpa/JpaLogger.java b/jpa/core/src/main/java/org/jboss/as/jpa/messages/JpaLogger.java
similarity index 91%
rename from jpa/spi/src/main/java/org/jboss/as/jpa/JpaLogger.java
rename to jpa/core/src/main/java/org/jboss/as/jpa/messages/JpaLogger.java
index 3d46146b2db0..9f6c9d76df4c 100644
--- a/jpa/spi/src/main/java/org/jboss/as/jpa/JpaLogger.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/messages/JpaLogger.java
@@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.jpa;
+package org.jboss.as.jpa.messages;
import static org.jboss.logging.Logger.Level.ERROR;
import static org.jboss.logging.Logger.Level.INFO;
@@ -102,9 +102,9 @@ public interface JpaLogger extends BasicLogger {
*
* @param cause the cause of the error.
*/
- @LogMessage(level = ERROR)
- @Message(id = 11404, value = "Could not load default persistence provider adaptor module. Management attributes will not be registered for the adaptor")
- void errorPreloadingDefaultProviderAdaptor(@Cause Throwable cause);
+ //@LogMessage(level = ERROR)
+ //@Message(id = 11404, value = "Could not load default persistence provider adaptor module. Management attributes will not be registered for the adaptor")
+ //void errorPreloadingDefaultProviderAdaptor(@Cause Throwable cause);
/**
* Logs an error message indicating an exception occurred while preloading the default persistence provider module.
@@ -144,8 +144,8 @@ public interface JpaLogger extends BasicLogger {
* @param cause the cause of the error.
* @param className the entity class name.
*/
- @LogMessage(level = WARN)
- @Message(id = 11408, value = "Could not load entity class '%s', ignoring this error and continuing with application deployment")
- void cannotLoadEntityClass(@Cause Throwable cause, String className);
+ //@LogMessage(level = WARN)
+ //@Message(id = 11408, value = "Could not load entity class '%s', ignoring this error and continuing with application deployment")
+ //void cannotLoadEntityClass(@Cause Throwable cause, String className);
}
diff --git a/jpa/spi/src/main/java/org/jboss/as/jpa/JpaMessages.java b/jpa/core/src/main/java/org/jboss/as/jpa/messages/JpaMessages.java
similarity index 85%
rename from jpa/spi/src/main/java/org/jboss/as/jpa/JpaMessages.java
rename to jpa/core/src/main/java/org/jboss/as/jpa/messages/JpaMessages.java
index d7c713bce450..2cd0513e7ff8 100644
--- a/jpa/spi/src/main/java/org/jboss/as/jpa/JpaMessages.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/messages/JpaMessages.java
@@ -20,20 +20,17 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.jpa;
+package org.jboss.as.jpa.messages;
-import java.io.File;
import java.net.URLConnection;
import javax.ejb.EJBException;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceException;
import javax.persistence.TransactionRequiredException;
-import javax.xml.stream.XMLStreamException;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
-import org.jboss.invocation.InterceptorContext;
import org.jboss.jandex.MethodInfo;
import org.jboss.logging.annotations.Cause;
import org.jboss.logging.annotations.Message;
@@ -71,8 +68,8 @@ public interface JpaMessages {
*
* @return an {@link IllegalArgumentException} for the error.
*/
- @Message(id = 11421, value = "Cannot change input stream reference.")
- IllegalArgumentException cannotChangeInputStream();
+ //@Message(id = 11421, value = "Cannot change input stream reference.")
+ //IllegalArgumentException cannotChangeInputStream();
/**
* Creates an exception indicating the entity manager cannot be closed when it is managed by the container.
@@ -89,8 +86,8 @@ public interface JpaMessages {
* @param entityManagerTypeName the entity manager type name.
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11423, value = "Can only close SFSB XPC entity manager that are instances of ExtendedEntityManager %s")
- RuntimeException cannotCloseNonExtendedEntityManager(String entityManagerTypeName);
+ //@Message(id = 11423, value = "Can only close SFSB XPC entity manager that are instances of ExtendedEntityManager %s")
+ //RuntimeException cannotCloseNonExtendedEntityManager(String entityManagerTypeName);
/**
* Creates an exception indicating the transactional entity manager cannot be closed when it is managed by the
@@ -151,8 +148,8 @@ public interface JpaMessages {
* @param unitName the unit name.
* @return a {@link DeploymentUnitProcessingException} for the error.
*/
- @Message(id = 11429, value = "Cannot inject RESOURCE_LOCAL entity manager %s using ")
- DeploymentUnitProcessingException cannotInjectResourceLocalEntityManager(String unitName);
+ //@Message(id = 11429, value = "Cannot inject RESOURCE_LOCAL entity manager %s using ")
+ //DeploymentUnitProcessingException cannotInjectResourceLocalEntityManager(String unitName);
/**
* Creates an exception indicating the persistence provider adapter module, represented by the {@code adapterModule}
@@ -163,8 +160,8 @@ public interface JpaMessages {
* @param persistenceProviderClass the persistence provider class.
* @return a {@link DeploymentUnitProcessingException} for the error.
*/
- @Message(id = 11430, value = "Persistence provider adapter module (%s) load error (class %s)")
- DeploymentUnitProcessingException cannotLoadAdapterModule(@Cause Throwable cause, String adapterModule, String persistenceProviderClass);
+ //@Message(id = 11430, value = "Persistence provider adapter module (%s) load error (class %s)")
+ //DeploymentUnitProcessingException cannotLoadAdapterModule(@Cause Throwable cause, String adapterModule, String persistenceProviderClass);
/**
* Creates an exception indicating the entity class could not be loaded with the
@@ -174,8 +171,8 @@ public interface JpaMessages {
* @param className the entity class name.
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11431, value = "Could not load entity class '%s' with PersistenceUnitInfo.getClassLoader()")
- RuntimeException cannotLoadEntityClass(@Cause Throwable cause, String className);
+ //@Message(id = 11431, value = "Could not load entity class '%s' with PersistenceUnitInfo.getClassLoader()")
+ //RuntimeException cannotLoadEntityClass(@Cause Throwable cause, String className);
/**
* Creates an exception indicating the {@code injectionTypeName} could not be loaded from the JPA modules class
@@ -299,8 +296,8 @@ public interface JpaMessages {
* @param parameterName the parameter name.
* @return an {@link IllegalArgumentException} for the error.
*/
- @Message(id = 11442, value = "Parameter %s is empty")
- IllegalArgumentException emptyParameter(String parameterName);
+ //@Message(id = 11442, value = "Parameter %s is empty")
+ //IllegalArgumentException emptyParameter(String parameterName);
/**
* Creates an exception indicating there was an error when trying to get the transaction associated with the
@@ -363,8 +360,8 @@ public interface JpaMessages {
*
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11450, value = "File %s not found")
- RuntimeException fileNotFound(File file);
+ //@Message(id = 11450, value = "File %s not found")
+ //RuntimeException fileNotFound(File file);
/**
* Creates an exception indicating the persistence unit name contains an invalid character.
@@ -383,8 +380,8 @@ public interface JpaMessages {
* @param name the scope name that was supplied.
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11452, value = "Scoped persistence name should be \"%s\" but was %s")
- RuntimeException invalidScopeName(String validName, String name);
+ //@Message(id = 11452, value = "Scoped persistence name should be \"%s\" but was %s")
+ //RuntimeException invalidScopeName(String validName, String name);
/**
* Creates an exception indicating the inability to integrate the module, represented by the {@code integrationName}
@@ -397,16 +394,16 @@ public interface JpaMessages {
@Message(id = 11453, value = "Could not add %s integration module to deployment, did not get expected JarUrlConnection, got %s")
RuntimeException invalidUrlConnection(String integrationName, URLConnection connection);
- @Message(id = 11454, value = "Could not load %s")
- XMLStreamException errorLoadingJBossJPAFile(@Cause Throwable cause, String path);
+ //@Message(id = 11454, value = "Could not load %s")
+ //XMLStreamException errorLoadingJBossJPAFile(@Cause Throwable cause, String path);
/**
* Creates an exception indicating the persistence unit metadata likely because thread local was not set.
*
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11455, value = "Missing PersistenceUnitMetadata (thread local wasn't set)")
- RuntimeException missingPersistenceUnitMetadata();
+ //@Message(id = 11455, value = "Missing PersistenceUnitMetadata (thread local wasn't set)")
+ //RuntimeException missingPersistenceUnitMetadata();
/**
* Creates an exception indicating the persistence provider adapter module, represented by the {@code adapterModule}
@@ -424,8 +421,8 @@ public interface JpaMessages {
* @param sessionBean the stateful session bean.
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11457, value = "More than one thread is invoking stateful session bean '%s' at the same time")
- RuntimeException multipleThreadsInvokingSfsb(Object sessionBean);
+ //@Message(id = 11457, value = "More than one thread is invoking stateful session bean '%s' at the same time")
+ //RuntimeException multipleThreadsInvokingSfsb(Object sessionBean);
/**
* Creates an exception indicating more than one thread is using the entity manager instance at the same time.
@@ -433,8 +430,8 @@ public interface JpaMessages {
* @param entityManager the entity manager.
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11458, value = "More than one thread is using EntityManager instance '%s' at the same time")
- RuntimeException multipleThreadsUsingEntityManager(EntityManager entityManager);
+ //@Message(id = 11458, value = "More than one thread is using EntityManager instance '%s' at the same time")
+ //RuntimeException multipleThreadsUsingEntityManager(EntityManager entityManager);
/**
* Creates an exception indicating the {@code name} was not set in the {@link org.jboss.invocation.InterceptorContext}.
@@ -443,16 +440,16 @@ public interface JpaMessages {
* @param context the context.
* @return an {@link IllegalArgumentException} for the error.
*/
- @Message(id = 11459, value = "%s not set in InterceptorContext: %s")
- IllegalArgumentException notSetInInterceptorContext(String name, InterceptorContext context);
+ //@Message(id = 11459, value = "%s not set in InterceptorContext: %s")
+ //IllegalArgumentException notSetInInterceptorContext(String name, InterceptorContext context);
/**
* Creates an exception indicating the method is not yet implemented.
*
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11460, value = "Not yet implemented")
- RuntimeException notYetImplemented();
+ //@Message(id = 11460, value = "Not yet implemented")
+ //RuntimeException notYetImplemented();
/**
* Creates an exception indicating the {@code description} is {@code null}.
@@ -470,8 +467,8 @@ public interface JpaMessages {
* @param varName the variable name.
* @return an {@link IllegalArgumentException} for the error.
*/
- @Message(id = 11462, value = "Parameter %s is null")
- IllegalArgumentException nullVar(String varName);
+ //@Message(id = 11462, value = "Parameter %s is null")
+ //IllegalArgumentException nullVar(String varName);
/**
* A message indicating the object for the class ({@code cls} has been defined and is not {@code null}.
@@ -480,8 +477,8 @@ public interface JpaMessages {
* @param previous the previously defined object.
* @return the message.
*/
- @Message(id = 11463, value = "Previous object for class %s is %s instead of null")
- String objectAlreadyDefined(Class> cls, Object previous);
+ //@Message(id = 11463, value = "Previous object for class %s is %s instead of null")
+ //String objectAlreadyDefined(Class> cls, Object previous);
/**
* Creates an exception indicating the parameter must be a ExtendedEntityManager
@@ -489,8 +486,8 @@ public interface JpaMessages {
* @param gotClass
* @return a {@link RuntimeException} for the error.
*/
- @Message(id = 11465, value = "Internal error, expected parameter of type ExtendedEntityManager but instead got %s")
- RuntimeException parameterMustBeExtendedEntityManager(String gotClass);
+ //@Message(id = 11465, value = "Internal error, expected parameter of type ExtendedEntityManager but instead got %s")
+ //RuntimeException parameterMustBeExtendedEntityManager(String gotClass);
/**
* Creates an exception indicating the persistence provider could not be found.
@@ -567,6 +564,27 @@ public interface JpaMessages {
RuntimeException referenceCountedEntityManagerNegativeCount(int referenceCount, String scopedPuName);
+ /**
+ * Can't use a new unsynchronization persistence context when transaction already has a synchronized persistence context.
+ *
+ * @param puScopedName the persistence unit name.
+ * @return an {@link javax.ejb.EJBException} for the error.
+ */
+ @Message(id = 11473, value =
+ "JTA transaction already has a 'SynchronizationType.UNSYNCHRONIZED' persistence context (EntityManager) joined to it " +
+ "but a component with a 'SynchronizationType.SYNCHRONIZED' is now being used. " +
+ "Change the calling component code to join the persistence context (EntityManager) to the transaction or "+
+ "change the called component code to also use 'SynchronizationType.UNSYNCHRONIZED'. "+
+ "See JPA spec 2.1 section 7.6.4.1. " +
+ "Scoped persistence unit name=%s.")
+ EJBException badSynchronizationTypeCombination(String puScopedName);
+
+ @Message(id = 11474, value = "Resources of type %s cannot be registered")
+ UnsupportedOperationException resourcesOfTypeCannotBeRegistered(String key);
+
+ @Message(id = 11475, value = "Resources of type %s cannot be removed")
+ UnsupportedOperationException resourcesOfTypeCannotBeRemoved(String key);
+
/**
* Don't add any message ids higher than 11499 (will need a new chunk).
*/
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/persistenceprovider/PersistenceProviderResolverImpl.java b/jpa/core/src/main/java/org/jboss/as/jpa/persistenceprovider/PersistenceProviderResolverImpl.java
index 88fab3b7477f..8ba9cd662a00 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/persistenceprovider/PersistenceProviderResolverImpl.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/persistenceprovider/PersistenceProviderResolverImpl.java
@@ -22,7 +22,7 @@
package org.jboss.as.jpa.persistenceprovider;
-import static org.jboss.as.jpa.JpaLogger.ROOT_LOGGER;
+import static org.jboss.as.jpa.messages.JpaLogger.ROOT_LOGGER;
import java.util.ArrayList;
import java.util.HashMap;
@@ -34,7 +34,7 @@
import javax.persistence.spi.PersistenceProvider;
import javax.persistence.spi.PersistenceProviderResolver;
-import org.jboss.as.jpa.JpaMessages;
+import org.jboss.as.jpa.messages.JpaMessages;
import org.jboss.modules.ModuleClassLoader;
import org.wildfly.security.manager.WildFlySecurityManager;
diff --git a/jpa/spi/src/main/java/org/jboss/as/jpa/spi/TempClassLoaderFactory.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/CacheDeploymentHelper.java
similarity index 59%
rename from jpa/spi/src/main/java/org/jboss/as/jpa/spi/TempClassLoaderFactory.java
rename to jpa/core/src/main/java/org/jboss/as/jpa/processor/CacheDeploymentHelper.java
index 33502bb9f1aa..2d88040537bc 100644
--- a/jpa/spi/src/main/java/org/jboss/as/jpa/spi/TempClassLoaderFactory.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/CacheDeploymentHelper.java
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2010, Red Hat, Inc., and individual contributors
+ * Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -20,20 +20,29 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.jboss.as.jpa.spi;
+package org.jboss.as.jpa.processor;
+
+import org.jboss.as.jpa.processor.secondLevelCache.CacheDeploymentListener;
+import org.jipijapa.core.EventListenerRegistration;
/**
- * Factory for creating temporary classloaders used by persistence providers.
+ * CacheDeploymentHelper
*
- * @author Antti Laisi
+ * @author Scott Marlow
*/
-public interface TempClassLoaderFactory {
+public class CacheDeploymentHelper {
+
+ private volatile CacheDeploymentListener listener;
- /**
- * Creates a temporary classloader with the same scope and classpath as the persistence unit classloader.
- *
- * @see javax.persistence.spi.PersistenceUnitInfo#getNewTempClassLoader()
- */
- ClassLoader createNewTempClassLoader();
+ public void register() {
+ listener = new CacheDeploymentListener();
+ EventListenerRegistration.add(listener);
+ }
+ public void unregister() {
+ if (listener != null) {
+ EventListenerRegistration.remove(listener);
+ listener = null;
+ }
+ }
}
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAAnnotationProcessor.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAAnnotationProcessor.java
index 3acda8703344..1f30773ea310 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAAnnotationProcessor.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAAnnotationProcessor.java
@@ -22,7 +22,7 @@
package org.jboss.as.jpa.processor;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.util.HashMap;
import java.util.List;
@@ -34,6 +34,7 @@
import javax.persistence.PersistenceContexts;
import javax.persistence.PersistenceUnit;
import javax.persistence.PersistenceUnits;
+import javax.persistence.SynchronizationType;
import javax.persistence.spi.PersistenceUnitTransactionType;
import org.jboss.as.ee.component.Attachments;
@@ -51,7 +52,6 @@
import org.jboss.as.jpa.injectors.PersistenceContextInjectionSource;
import org.jboss.as.jpa.injectors.PersistenceUnitInjectionSource;
import org.jboss.as.jpa.service.PersistenceUnitServiceImpl;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
@@ -66,6 +66,7 @@
import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.MethodInfo;
import org.jboss.msc.service.ServiceName;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Handle PersistenceContext and PersistenceUnit annotations.
@@ -301,6 +302,11 @@ private InjectionSource getBindingSource(final DeploymentUnit deploymentUnit, fi
PersistenceContextType type = (pcType == null || PersistenceContextType.TRANSACTION.name().equals(pcType.asString()))
? PersistenceContextType.TRANSACTION : PersistenceContextType.EXTENDED;
+ AnnotationValue stType = annotation.value("synchronizationType");
+ SynchronizationType synchronizationType =
+ (stType == null || SynchronizationType.SYNCHRONIZED.name().equals(stType.asString()))?
+ SynchronizationType.SYNCHRONIZED: SynchronizationType.UNSYNCHRONIZED;
+
Map properties;
AnnotationValue value = annotation.value("properties");
AnnotationInstance[] props = value != null ? value.asNestedArray() : null;
@@ -313,7 +319,7 @@ private InjectionSource getBindingSource(final DeploymentUnit deploymentUnit, fi
properties = null;
}
- return new PersistenceContextInjectionSource(type, properties, puServiceName, deploymentUnit, scopedPuName, injectionTypeName, pu);
+ return new PersistenceContextInjectionSource(type, synchronizationType , properties, puServiceName, deploymentUnit, scopedPuName, injectionTypeName, pu);
} else {
return new PersistenceUnitInjectionSource(puServiceName, deploymentUnit, injectionTypeName, pu);
}
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAClassFileTransformerProcessor.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAClassFileTransformerProcessor.java
index b78821f7318f..d55a54dd01d3 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAClassFileTransformerProcessor.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAClassFileTransformerProcessor.java
@@ -25,7 +25,6 @@
import org.jboss.as.jpa.classloader.JPADelegatingClassFileTransformer;
import org.jboss.as.jpa.config.Configuration;
import org.jboss.as.jpa.config.PersistenceUnitMetadataHolder;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
@@ -33,6 +32,7 @@
import org.jboss.as.server.deployment.DeploymentUtils;
import org.jboss.as.server.deployment.module.DelegatingClassFileTransformer;
import org.jboss.as.server.deployment.module.ResourceRoot;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Deployment processor which ensures the persistence provider ClassFileTransformer are used.
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPADependencyProcessor.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPADependencyProcessor.java
index 62cd06280a6e..cfce51fc3b6e 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPADependencyProcessor.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPADependencyProcessor.java
@@ -22,8 +22,8 @@
package org.jboss.as.jpa.processor;
-import static org.jboss.as.jpa.JpaLogger.ROOT_LOGGER;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.ROOT_LOGGER;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.io.IOException;
import java.net.JarURLConnection;
@@ -37,7 +37,6 @@
import org.jboss.as.jpa.config.Configuration;
import org.jboss.as.jpa.config.PersistenceUnitMetadataHolder;
import org.jboss.as.jpa.config.PersistenceUnitsInApplication;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
@@ -53,6 +52,7 @@
import org.jboss.modules.ModuleLoader;
import org.jboss.modules.ResourceLoaderSpec;
import org.jboss.modules.ResourceLoaders;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Deployment processor which adds a module dependencies for modules needed for JPA deployments.
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAInterceptorProcessor.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAInterceptorProcessor.java
index 2d6d6f96ba85..8f669dbd417c 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAInterceptorProcessor.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/JPAInterceptorProcessor.java
@@ -38,7 +38,7 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
-import static org.jboss.as.jpa.JpaLogger.JPA_LOGGER;
+import static org.jboss.as.jpa.messages.JpaLogger.JPA_LOGGER;
/**
* @author Stuart Douglas
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceProviderAdaptorLoader.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceProviderAdaptorLoader.java
index 2230e1c555e8..265611ad6d58 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceProviderAdaptorLoader.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceProviderAdaptorLoader.java
@@ -22,24 +22,21 @@
package org.jboss.as.jpa.processor;
-import static org.jboss.as.jpa.JpaLogger.JPA_LOGGER;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.JPA_LOGGER;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.util.Map;
import java.util.ServiceLoader;
-import org.jboss.as.jpa.spi.JtaManager;
-import org.jboss.as.jpa.spi.ManagementAdaptor;
-import org.jboss.as.jpa.spi.PersistenceProviderAdaptor;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.jpa.transaction.JtaManagerImpl;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleIdentifier;
import org.jboss.modules.ModuleLoadException;
import org.jboss.modules.ModuleLoader;
-import org.jboss.msc.service.ServiceBuilder;
-import org.jboss.msc.service.ServiceRegistry;
-import org.jboss.msc.service.ServiceTarget;
+import org.jipijapa.plugin.spi.JtaManager;
+import org.jipijapa.plugin.spi.ManagementAdaptor;
+import org.jipijapa.plugin.spi.PersistenceProviderAdaptor;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
/**
* Loads persistence provider adaptors
@@ -59,7 +56,7 @@ public void addProviderProperties(Map properties, PersistenceUnitMetadata pu) {
}
@Override
- public void addProviderDependencies(ServiceRegistry registry, ServiceTarget target, ServiceBuilder> builder, PersistenceUnitMetadata pu) {
+ public void addProviderDependencies(PersistenceUnitMetadata pu) {
}
@Override
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceProviderHandler.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceProviderHandler.java
index d1f2f168da57..bd00fd6b62c7 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceProviderHandler.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceProviderHandler.java
@@ -22,7 +22,7 @@
package org.jboss.as.jpa.processor;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
@@ -34,7 +34,6 @@
import org.jboss.as.jpa.config.PersistenceProviderDeploymentHolder;
import org.jboss.as.jpa.persistenceprovider.PersistenceProviderResolverImpl;
-import org.jboss.as.jpa.spi.PersistenceProviderAdaptor;
import org.jboss.as.jpa.transaction.JtaManagerImpl;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
@@ -44,6 +43,7 @@
import org.jboss.as.server.deployment.ServicesAttachment;
import org.jboss.modules.Module;
import org.jboss.modules.ModuleClassLoader;
+import org.jipijapa.plugin.spi.PersistenceProviderAdaptor;
/**
* Deploy JPA Persistence providers that are found in the application deployment.
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceRefProcessor.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceRefProcessor.java
index 61be7875b2f4..cea408dd0ab9 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceRefProcessor.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceRefProcessor.java
@@ -30,6 +30,7 @@
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.PersistenceContextType;
+import javax.persistence.SynchronizationType;
import org.jboss.as.ee.component.BindingConfiguration;
import org.jboss.as.ee.component.ComponentDescription;
@@ -43,7 +44,6 @@
import org.jboss.as.jpa.injectors.PersistenceContextInjectionSource;
import org.jboss.as.jpa.injectors.PersistenceUnitInjectionSource;
import org.jboss.as.jpa.service.PersistenceUnitServiceImpl;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.JPADeploymentMarker;
@@ -57,8 +57,9 @@
import org.jboss.metadata.javaee.spec.PropertyMetaData;
import org.jboss.metadata.javaee.spec.RemoteEnvironment;
import org.jboss.msc.service.ServiceName;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
/**
* Deployment processor responsible for processing persistence unit / context references from deployment descriptors.
@@ -180,7 +181,12 @@ private List getPersistenceContextRefs(DeploymentUnit depl
}
}
PersistenceContextType type = puRef.getPersistenceContextType() == null ? PersistenceContextType.TRANSACTION : puRef.getPersistenceContextType();
- InjectionSource pcBindingSource = this.getPersistenceContextBindingSource(deploymentUnit, persistenceUnitName, type, map);
+ // create a EE 7 branch of
+ SynchronizationType synchronizationType = SynchronizationType.SYNCHRONIZED;
+// (puRef.()== null || SynchronizationType.SYNCHRONIZED.name().equals(stType.asString()))?
+// SynchronizationType.SYNCHRONIZED: SynchronizationType.UNSYNCHRONIZED;
+
+ InjectionSource pcBindingSource = this.getPersistenceContextBindingSource(deploymentUnit, persistenceUnitName, type, synchronizationType, map);
bindingConfiguration = new BindingConfiguration(name, pcBindingSource);
}
bindingConfigurations.add(bindingConfiguration);
@@ -205,12 +211,17 @@ private InjectionSource getPersistenceUnitBindingSource(final DeploymentUnit dep
return new PersistenceUnitInjectionSource(puServiceName, deploymentUnit, EntityManagerFactory.class.getName(), pu);
}
- private InjectionSource getPersistenceContextBindingSource(final DeploymentUnit deploymentUnit, final String unitName, PersistenceContextType type, Map properties) throws
+ private InjectionSource getPersistenceContextBindingSource(
+ final DeploymentUnit deploymentUnit,
+ final String unitName,
+ PersistenceContextType type,
+ SynchronizationType synchronizationType,
+ Map properties) throws
DeploymentUnitProcessingException {
PersistenceUnitMetadata pu = getPersistenceUnit(deploymentUnit, unitName);
String scopedPuName = pu.getScopedPersistenceUnitName();
ServiceName puServiceName = getPuServiceName(scopedPuName);
- return new PersistenceContextInjectionSource(type, properties, puServiceName, deploymentUnit, scopedPuName, EntityManager.class.getName(), pu);
+ return new PersistenceContextInjectionSource(type, synchronizationType, properties, puServiceName, deploymentUnit, scopedPuName, EntityManager.class.getName(), pu);
}
private PersistenceUnitMetadata getPersistenceUnit(final DeploymentUnit deploymentUnit, final String puName)
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceUnitParseProcessor.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceUnitParseProcessor.java
index cce5f8537897..fd608707ffe8 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceUnitParseProcessor.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceUnitParseProcessor.java
@@ -28,7 +28,6 @@
import org.jboss.as.jpa.config.PersistenceUnitMetadataHolder;
import org.jboss.as.jpa.config.PersistenceUnitsInApplication;
import org.jboss.as.jpa.puparser.PersistenceUnitXmlParser;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
@@ -40,6 +39,7 @@
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.metadata.parser.util.NoopXMLResolver;
import org.jboss.vfs.VirtualFile;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
@@ -53,8 +53,8 @@
import java.util.Locale;
import java.util.Map;
-import static org.jboss.as.jpa.JpaLogger.JPA_LOGGER;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.JPA_LOGGER;
+import static org.jboss.as.jpa.messages.JpaMessages.MESSAGES;
/**
* Handle parsing of Persistence unit persistence.xml files
diff --git a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceUnitServiceHandler.java b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceUnitServiceHandler.java
index 8dfd266d2c1d..bdb134402b26 100644
--- a/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceUnitServiceHandler.java
+++ b/jpa/core/src/main/java/org/jboss/as/jpa/processor/PersistenceUnitServiceHandler.java
@@ -33,6 +33,8 @@
import java.util.Locale;
import java.util.Map;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.persistence.SynchronizationType;
import javax.persistence.ValidationMode;
import javax.persistence.spi.PersistenceProvider;
import javax.persistence.spi.PersistenceProviderResolverHolder;
@@ -47,18 +49,17 @@
import org.jboss.as.ee.component.EEModuleDescription;
import org.jboss.as.ee.structure.DeploymentType;
import org.jboss.as.ee.structure.DeploymentTypeMarker;
+import org.jboss.as.ee.weld.WeldDeploymentMarker;
import org.jboss.as.jpa.config.Configuration;
import org.jboss.as.jpa.config.PersistenceProviderDeploymentHolder;
import org.jboss.as.jpa.config.PersistenceUnitMetadataHolder;
import org.jboss.as.jpa.container.TransactionScopedEntityManager;
import org.jboss.as.jpa.interceptor.WebNonTxEmCloserAction;
+import org.jboss.as.jpa.messages.JpaMessages;
import org.jboss.as.jpa.persistenceprovider.PersistenceProviderLoader;
+import org.jboss.as.jpa.processor.secondLevelCache.CacheDeploymentListener;
import org.jboss.as.jpa.service.JPAService;
import org.jboss.as.jpa.service.PersistenceUnitServiceImpl;
-import org.jboss.as.jpa.spi.ManagementAdaptor;
-import org.jboss.as.jpa.spi.PersistenceProviderAdaptor;
-import org.jboss.as.jpa.spi.PersistenceUnitMetadata;
-import org.jboss.as.jpa.spi.PersistenceUnitService;
import org.jboss.as.jpa.subsystem.PersistenceUnitRegistryImpl;
import org.jboss.as.jpa.validator.SerializableValidatorFactory;
import org.jboss.as.naming.ManagedReference;
@@ -92,10 +93,13 @@
import org.jboss.msc.service.ServiceRegistryException;
import org.jboss.msc.service.ServiceTarget;
import org.jboss.msc.value.ImmediateValue;
+import org.jipijapa.plugin.spi.ManagementAdaptor;
+import org.jipijapa.plugin.spi.PersistenceProviderAdaptor;
+import org.jipijapa.plugin.spi.PersistenceUnitMetadata;
+import org.jipijapa.plugin.spi.PersistenceUnitService;
-import static org.jboss.as.jpa.JpaLogger.JPA_LOGGER;
-import static org.jboss.as.jpa.JpaLogger.ROOT_LOGGER;
-import static org.jboss.as.jpa.JpaMessages.MESSAGES;
+import static org.jboss.as.jpa.messages.JpaLogger.JPA_LOGGER;
+import static org.jboss.as.jpa.messages.JpaLogger.ROOT_LOGGER;
import static org.jboss.as.server.Services.addServerExecutorDependency;
/**
@@ -107,6 +111,7 @@ public class PersistenceUnitServiceHandler {
private static final String ENTITYMANAGERFACTORY_JNDI_PROPERTY = "jboss.entity.manager.factory.jndi.name";
private static final String ENTITYMANAGER_JNDI_PROPERTY = "jboss.entity.manager.jndi.name";
+ public static final ServiceName BEANMANAGER_NAME = ServiceName.of("beanmanager");
private static final AttachmentKey