You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/04/23 20:21:51 UTC
tomee git commit: ensure auto scanning is working for
@PersistenceUnitDefinition
Repository: tomee
Updated Branches:
refs/heads/master 1e2a12520 -> 13ab7d8ba
ensure auto scanning is working for @PersistenceUnitDefinition
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/13ab7d8b
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/13ab7d8b
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/13ab7d8b
Branch: refs/heads/master
Commit: 13ab7d8ba2ed9de94ee44e331ed4ce8487f511af
Parents: 1e2a125
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Thu Apr 23 20:20:51 2015 +0200
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Thu Apr 23 20:20:57 2015 +0200
----------------------------------------------------------------------
.../openejb/config/AnnotationDeployer.java | 81 +++++++++++---------
.../openejb/config/ConfigurationDeployer.java | 6 ++
2 files changed, 49 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/13ab7d8b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
index b87ed1e..1419953 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
@@ -1531,44 +1531,7 @@ public class AnnotationDeployer implements DynamicDeployer {
addJaxRsProviders(finder, ejbModule.getAppModule().getJaxRsProviders(), Provider.class);
}
- if (ejbModule.getAppModule() != null) {
- for (final PersistenceModule pm : ejbModule.getAppModule().getPersistenceModules()) {
- for (final org.apache.openejb.jee.jpa.unit.PersistenceUnit pu : pm.getPersistence().getPersistenceUnit()) {
- if ((pu.isExcludeUnlistedClasses() == null || !pu.isExcludeUnlistedClasses())
- && "true".equalsIgnoreCase(pu.getProperties().getProperty(OPENEJB_JPA_AUTO_SCAN))) {
- final String packageName = pu.getProperties().getProperty(OPENEJB_JPA_AUTO_SCAN_PACKAGE);
- String[] packageNames = null;
- if (packageName != null) {
- packageNames = packageName.split(",");
- }
-
- // no need of meta currently since JPA providers doesn't support it
- final List<Class<?>> classes = new ArrayList<Class<?>>();
- classes.addAll(finder.findAnnotatedClasses(Entity.class));
- classes.addAll(finder.findAnnotatedClasses(Embeddable.class));
- classes.addAll(finder.findAnnotatedClasses(MappedSuperclass.class));
- final List<String> existingClasses = pu.getClazz();
- for (final Class<?> clazz : classes) {
- final String name = clazz.getName();
- if (existingClasses.contains(name)) {
- continue;
- }
-
- if (packageNames == null) {
- pu.getClazz().add(name);
- } else {
- for (final String pack : packageNames) {
- if (name.startsWith(pack)) {
- pu.getClazz().add(name);
- }
- }
- }
- }
- pu.setScanned(true);
- }
- }
- }
- }
+ autoJpa(ejbModule);
return ejbModule;
}
@@ -1904,6 +1867,48 @@ public class AnnotationDeployer implements DynamicDeployer {
}
+ public static void autoJpa(final EjbModule ejbModule) {
+ final IAnnotationFinder finder = ejbModule.getFinder();
+ if (ejbModule.getAppModule() != null) {
+ for (final PersistenceModule pm : ejbModule.getAppModule().getPersistenceModules()) {
+ for (final org.apache.openejb.jee.jpa.unit.PersistenceUnit pu : pm.getPersistence().getPersistenceUnit()) {
+ if ((pu.isExcludeUnlistedClasses() == null || !pu.isExcludeUnlistedClasses())
+ && "true".equalsIgnoreCase(pu.getProperties().getProperty(OPENEJB_JPA_AUTO_SCAN))) {
+ final String packageName = pu.getProperties().getProperty(OPENEJB_JPA_AUTO_SCAN_PACKAGE);
+ String[] packageNames = null;
+ if (packageName != null) {
+ packageNames = packageName.split(",");
+ }
+
+ // no need of meta currently since JPA providers doesn't support it
+ final List<Class<?>> classes = new ArrayList<Class<?>>();
+ classes.addAll(finder.findAnnotatedClasses(Entity.class));
+ classes.addAll(finder.findAnnotatedClasses(Embeddable.class));
+ classes.addAll(finder.findAnnotatedClasses(MappedSuperclass.class));
+ final List<String> existingClasses = pu.getClazz();
+ for (final Class<?> clazz : classes) {
+ final String name = clazz.getName();
+ if (existingClasses.contains(name)) {
+ continue;
+ }
+
+ if (packageNames == null) {
+ pu.getClazz().add(name);
+ } else {
+ for (final String pack : packageNames) {
+ if (name.startsWith(pack)) {
+ pu.getClazz().add(name);
+ }
+ }
+ }
+ }
+ pu.setScanned(true);
+ }
+ }
+ }
+ }
+ }
+
public static class ProcessAnnotatedBeans implements DynamicDeployer {
public static final String STRICT_INTERFACE_DECLARATION = "openejb.strict.interface.declaration";
http://git-wip-us.apache.org/repos/asf/tomee/blob/13ab7d8b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java
index 637e1bb..dbe7b81 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationDeployer.java
@@ -34,14 +34,20 @@ public class ConfigurationDeployer implements DynamicDeployer {
continue;
}
+ boolean scan = false;
for (final Class<?> configClass : module.getFinder().findAnnotatedClasses(PersistenceUnitDefinition.class)) {
configureJpa(appModule, configClass.getAnnotation(PersistenceUnitDefinition.class));
+ scan = true;
}
for (final Class<?> configClass : module.getFinder().findAnnotatedClasses(PersistenceUnitDefinitions.class)) {
for (final PersistenceUnitDefinition persistenceUnitDefinition : configClass.getAnnotation(PersistenceUnitDefinitions.class).value()) {
configureJpa(appModule, persistenceUnitDefinition);
+ scan = true;
}
}
+ if (scan) {
+ AnnotationDeployer.autoJpa(module); // we pass after annotation deployer so need to fill it ourself
+ }
}
return appModule;
}