tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1411765 - in /openejb/trunk/openejb/container/openejb-core/src: main/java/org/apache/openejb/config/AnnotationDeployer.java test/java/org/apache/openejb/config/EntitiesScanningPackageLimitedTest.java
Date Tue, 20 Nov 2012 17:47:51 GMT
Author: rmannibucau
Date: Tue Nov 20 17:47:50 2012
New Revision: 1411765

URL: http://svn.apache.org/viewvc?rev=1411765&view=rev
Log:
TOMEE-596 limit package scanning for jpa entities

Added:
    openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningPackageLimitedTest.java
      - copied, changed from r1411568, openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningTest.java
Modified:
    openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java

Modified: openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java?rev=1411765&r1=1411764&r2=1411765&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
Tue Nov 20 17:47:50 2012
@@ -244,6 +244,7 @@ public class AnnotationDeployer implemen
     public static final Logger startupLogger = Logger.getInstance(LogCategory.OPENEJB_STARTUP_CONFIG,
"org.apache.openejb.util.resources");
 
     public static final String OPENEJB_JPA_AUTO_SCAN = "openejb.jpa.auto-scan";
+    public static final String OPENEJB_JPA_AUTO_SCAN_PACKAGE = "openejb.jpa.auto-scan.package";
 
     private static final ThreadLocal<DeploymentModule> currentModule = new ThreadLocal<DeploymentModule>();
     private static final Set<String> lookupMissing = new HashSet<String>(2);
@@ -1497,12 +1498,14 @@ public class AnnotationDeployer implemen
                     for (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);
+
                             // no need of meta currently since JPA providers doesn't support
it
                             final List<Class<?>> classes = finder.findAnnotatedClasses(Entity.class);
                             final List<String> existingClasses = pu.getClazz();
                             for (Class<?> clazz : classes) {
                                 final String name = clazz.getName();
-                                if (!existingClasses.contains(name)) {
+                                if ((packageName == null || name.startsWith(packageName))
&& !existingClasses.contains(name)) {
                                     pu.getClazz().add(name);
                                 }
                             }

Copied: openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningPackageLimitedTest.java
(from r1411568, openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningTest.java)
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningPackageLimitedTest.java?p2=openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningPackageLimitedTest.java&p1=openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningTest.java&r1=1411568&r2=1411765&rev=1411765&view=diff
==============================================================================
--- openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningTest.java
(original)
+++ openejb/trunk/openejb/container/openejb-core/src/test/java/org/apache/openejb/config/EntitiesScanningPackageLimitedTest.java
Tue Nov 20 17:47:50 2012
@@ -35,7 +35,7 @@ import java.util.Properties;
 import static junit.framework.Assert.assertEquals;
 
 @RunWith(ApplicationComposer.class)
-public class EntitiesScanningTest {
+public class EntitiesScanningPackageLimitedTest {
 
     @Module
     public Class<?>[] app() throws Exception {
@@ -45,9 +45,9 @@ public class EntitiesScanningTest {
     @Configuration
     public Properties config() {
         final Properties p = new Properties();
-        p.put("cczczczedc", "new://Resource?type=DataSource");
-        p.put("cczczczedc.JdbcDriver", "org.hsqldb.jdbcDriver");
-        p.put("cczczczedc.JdbcUrl", "jdbc:hsqldb:mem:cczccdzcz");
+        p.put("cczczczedc2", "new://Resource?type=DataSource");
+        p.put("cczczczedc2.JdbcDriver", "org.hsqldb.jdbcDriver");
+        p.put("cczczczedc2.JdbcUrl", "jdbc:hsqldb:mem:cczccdzcz2");
         return p;
     }
 
@@ -57,6 +57,7 @@ public class EntitiesScanningTest {
         unit.setProperty("openjpa.jdbc.SynchronizeMappings", "buildSchema(ForeignKeys=true)");
         unit.getProperties().setProperty("openjpa.RuntimeUnenhancedClasses", "supported");
         unit.getProperties().setProperty("openejb.jpa.auto-scan", "true");
+        unit.getProperties().setProperty("openejb.jpa.auto-scan.package", "com.doesnt.exist");
 
         final Persistence persistence = new Persistence(unit);
         persistence.setVersion("2.0");
@@ -88,8 +89,6 @@ public class EntitiesScanningTest {
     @Test
     public void check() throws Exception {
         final ReloadableEntityManagerFactory remf = ((ReloadableEntityManagerFactory) emf);
-        assertEquals(1, remf.getManagedClasses().size());
-        assertEquals(SomeSimpleEntity.class.getName(), remf.getManagedClasses().iterator().next());
-        assertEquals(true, remf.getExcludeUnlistedClasses());
+        assertEquals(0, remf.getManagedClasses().size());
     }
 }



Mime
View raw message