This is an automated email from the ASF dual-hosted git repository.

ahuber pushed a commit to branch dev/2.0.0-M2
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 63e1e8670553b56de3d44decf8bdb5e2e6637606
Author: Dan Haywood <d...@haywood-associates.co.uk>
AuthorDate: Tue Sep 19 22:55:48 2017 +0100

    ISIS-1725: requires that an AppManifest is supplied (used to obtain list of 
entities).
---
 .../persistence/PersistenceSessionFactory.java     |  2 +-
 .../objectstore/jdo/service/RegisterEntities.java  | 83 ++++------------------
 2 files changed, 15 insertions(+), 70 deletions(-)

diff --git 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
index 095fbee..92f950d 100644
--- 
a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
+++ 
b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
@@ -93,7 +93,7 @@ public class PersistenceSessionFactory implements 
ApplicationScopedComponent, Fi
             final Map<String, String> datanucleusProps = 
dataNucleusConfig.asMap();
             addDataNucleusPropertiesIfRequired(datanucleusProps);
 
-            final RegisterEntities registerEntities = new 
RegisterEntities(configuration.asMap(), specificationLoader);
+            final RegisterEntities registerEntities = new 
RegisterEntities(specificationLoader);
             final Set<String> classesToBePersisted = 
registerEntities.getEntityTypes();
 
             applicationComponents = new 
DataNucleusApplicationComponents(jdoObjectstoreConfig, specificationLoader,
diff --git 
a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/service/RegisterEntities.java
 
b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/service/RegisterEntities.java
index 7cbb48b..1908dfe 100644
--- 
a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/service/RegisterEntities.java
+++ 
b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/service/RegisterEntities.java
@@ -18,33 +18,30 @@
  */
 package org.apache.isis.objectstore.jdo.service;
 
-import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import javax.jdo.annotations.PersistenceCapable;
 
-import org.apache.isis.applib.AppManifest;
-import org.apache.isis.applib.internal.reflection._Reflect;
-import org.apache.isis.applib.internal.reflection._Reflect.Discovery;
-import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
 import com.google.common.base.Joiner;
-import com.google.common.base.Splitter;
-import com.google.common.base.Strings;
-import com.google.common.collect.Iterables;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.isis.applib.AppManifest;
+import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
+
 public class RegisterEntities {
 
     @SuppressWarnings("unused")
     private final static Logger LOG = 
LoggerFactory.getLogger(RegisterEntities.class);
-    
+
+    /**
+     * @deprecated - no longer used; instead an AppManifest must be specified.
+     */
+    @Deprecated
     public final static String PACKAGE_PREFIX_KEY = 
"isis.persistor.datanucleus.RegisterEntities.packagePrefix";
 
     // //////////////////////////////////////
@@ -59,13 +56,13 @@ public class RegisterEntities {
     }
     //endregion
 
-    public RegisterEntities(final Map<String, String> configuration, final 
SpecificationLoader specificationLoader) {
+    public RegisterEntities(final SpecificationLoader specificationLoader) {
         this.specificationLoader = specificationLoader;
 
         Set<Class<?>> persistenceCapableTypes = 
AppManifest.Registry.instance().getPersistenceCapableTypes();
 
         if(persistenceCapableTypes == null) {
-            persistenceCapableTypes = 
searchForPersistenceCapables(configuration);
+            throw new IllegalStateException("AppManifest is required");
         }
 
         final List<String> classNamesNotEnhanced = Lists.newArrayList();
@@ -85,52 +82,11 @@ public class RegisterEntities {
         }
     }
 
-    /**
-     * only called if no appManifest
-     */
-    Set<Class<?>> searchForPersistenceCapables(final Map<String, String> 
configuration) {
-
-        final String packagePrefixes = lookupPackagePrefixes(configuration);
-
-        final Set<Class<?>> persistenceCapableTypes = Sets.newLinkedHashSet();
-        final List<String> domPackages = parseDomPackages(packagePrefixes);
-        for (final String packageName : domPackages) {
-               
-               final Discovery dicovery = _Reflect.discover(packageName);
-               
-            final Set<Class<?>> entityTypesInPackage =
-                       
dicovery.getTypesAnnotatedWith(PersistenceCapable.class);
-
-            if(entityTypesInPackage.isEmpty()) {
-                throw new IllegalArgumentException(String.format(
-                        "Bad configuration.\n\nCould not locate any 
@PersistenceCapable entities in package '%s'\n" +
-                                "Check value of '%s' key in 
WEB-INF/*.properties\n",
-                        packageName,
-                        PACKAGE_PREFIX_KEY));
-            }
-            persistenceCapableTypes.addAll(entityTypesInPackage);
-        }
-        return persistenceCapableTypes;
-    }
-
-    private String lookupPackagePrefixes(final Map<String, String> 
configuration) {
-        final String packagePrefixes = configuration.get(PACKAGE_PREFIX_KEY);
-        if(Strings.isNullOrEmpty(packagePrefixes)) {
-            throw new IllegalArgumentException(String.format(
-                    "Could not locate '%s' key in property files - aborting",
-                    PACKAGE_PREFIX_KEY));
-        }
-        return packagePrefixes;
-    }
-
-    private static List<String> parseDomPackages(String packagePrefixes) {
-        return 
Collections.unmodifiableList(Lists.newArrayList(Iterables.transform(Splitter.on(",").split(packagePrefixes),
 trim())));
-    }
 
     private static boolean ignore(final Class<?> entityType) {
         try {
             if(entityType.isAnonymousClass() || entityType.isLocalClass() || 
entityType.isMemberClass() ||
-               entityType.isInterface()) {
+               entityType.isInterface() || entityType.isAnnotation()) {
                 return true;
             }
             final PersistenceCapable persistenceCapable = 
entityType.getAnnotation(PersistenceCapable.class);
@@ -140,20 +96,9 @@ public class RegisterEntities {
         }
     }
 
-    private static Function<String,String> trim() {
-        return new Function<String,String>(){
-            @Override
-            public String apply(String input) {
-                return input.trim();
-            }
-        };
-    }
-
-    // //////////////////////////////////////
 
     SpecificationLoader getSpecificationLoader() {
         return specificationLoader;
     }
 
-
 }

-- 
To stop receiving notification emails like this one, please contact
ahu...@apache.org.

Reply via email to