You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2014/12/09 00:47:37 UTC

[6/9] isis git commit: ISIS-931: only call Reflections API once when discovering @DomainService classes (specify all URLs as package prefixes).

ISIS-931: only call Reflections API once when discovering @DomainService classes (specify all URLs as package prefixes).


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/6bc189c3
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/6bc189c3
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/6bc189c3

Branch: refs/heads/master
Commit: 6bc189c397c3c9accc912e10aa5b867c6a88cffd
Parents: c923b2a
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Mon Dec 8 09:51:24 2014 +0000
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Mon Dec 8 23:22:06 2014 +0000

----------------------------------------------------------------------
 .../ServicesInstallerFromAnnotation.java        | 34 +++++++++++++-------
 1 file changed, 22 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/6bc189c3/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFromAnnotation.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFromAnnotation.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFromAnnotation.java
index 8b2400b..fc4d3b8 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFromAnnotation.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/ServicesInstallerFromAnnotation.java
@@ -20,13 +20,19 @@
 package org.apache.isis.core.runtime.services;
 
 import java.lang.reflect.Modifier;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
 import java.util.SortedSet;
 import javax.annotation.PreDestroy;
-import com.google.common.base.*;
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.base.Predicate;
+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.Maps;
 import org.reflections.Reflections;
 import org.reflections.vfs.Vfs;
@@ -194,23 +200,27 @@ public class ServicesInstallerFromAnnotation extends InstallerAbstract implement
             SortedMap<String, SortedSet<String>> positionedServices) {
         initIfRequired();
 
-        for (final String packagePrefix : Iterables.transform(Splitter.on(",").split(packagePrefixes), trim())) {
-            Vfs.setDefaultURLTypes(ClassDiscoveryServiceUsingReflections.getUrlTypes());
-            Reflections reflections = new Reflections(packagePrefix);
+        final List<String> packagePrefixList = asList(packagePrefixes);
 
-            final Iterable<Class<?>> classes = Iterables.filter(
-                    reflections.getTypesAnnotatedWith(DomainService.class), instantiatable());
-            for (final Class<?> cls : classes) {
+        Vfs.setDefaultURLTypes(ClassDiscoveryServiceUsingReflections.getUrlTypes());
+        final Reflections reflections = new Reflections(packagePrefixList);
 
-                final DomainService domainService = cls.getAnnotation(DomainService.class);
-                final String order = domainService.menuOrder();
-                final String serviceName = cls.getName();
+        final Iterable<Class<?>> domainServiceClasses = Iterables.filter(
+                reflections.getTypesAnnotatedWith(DomainService.class), instantiatable());
+        for (final Class<?> cls : domainServiceClasses) {
 
-                ServicesInstallerUtils.appendInPosition(positionedServices, order, serviceName);
-            }
+            final DomainService domainService = cls.getAnnotation(DomainService.class);
+            final String order = domainService.menuOrder();
+            final String serviceName = cls.getName();
+
+            ServicesInstallerUtils.appendInPosition(positionedServices, order, serviceName);
         }
     }
 
+    protected ArrayList<String> asList(String packagePrefixes1) {
+        return Lists.newArrayList(Iterables.transform(Splitter.on(",").split(packagePrefixes1), trim()));
+    }
+
 
     // //////////////////////////////////////