You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/02/21 09:13:42 UTC
[isis] 30/34: ISIS-1841 clean up Internal API after rebase/merge
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 9a1839c54ee16be9bd053ea7d03c5d76e257767f
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Feb 19 14:58:04 2018 +0100
ISIS-1841 clean up Internal API after rebase/merge
refactor persistence capable type finding into its own package private
helper class
---
.../isis/applib/internal/reflection/_Reflect.java | 5 +-
.../internal/reflection/_Reflect_Discovery.java | 25 +--------
.../IsisComponentProvider.java | 2 +-
.../PersistenceCapableTypeFinder.java | 65 ++++++++++++++++++++++
4 files changed, 68 insertions(+), 29 deletions(-)
diff --git a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
index e0b213d..20d63e5 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect.java
@@ -23,11 +23,10 @@ import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Set;
+import org.apache.isis.applib.internal.context._Context;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.util.ClasspathHelper;
-import org.apache.isis.applib.internal.context._Context;
-
/**
* <h1>- internal use only -</h1>
* <p>
@@ -56,8 +55,6 @@ public final class _Reflect {
//TODO missing java-doc
public <T> Set<Class<? extends T>> getSubTypesOf(Class<T> type);
- public Set<Class<?>> findPersistenceCapableTypes();
-
}
//TODO missing java-doc
diff --git a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
index 5db08e5..fe7db50 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/internal/reflection/_Reflect_Discovery.java
@@ -8,15 +8,11 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import javax.jdo.annotations.PersistenceCapable;
import javax.validation.constraints.NotNull;
-import com.google.common.collect.Sets;
-
-import org.reflections.Reflections;
-
import org.apache.isis.applib.internal.base._NullSafe;
import org.apache.isis.applib.internal.reflection._Reflect.Discovery;
+import org.reflections.Reflections;
/**
*
@@ -84,24 +80,5 @@ class _Reflect_Discovery implements _Reflect.Discovery {
.filter(_NullSafe::isPresent);
}
- public Set<Class<?>> findPersistenceCapableTypes() {
-
- Set<Class<?>> pcSet = Sets.newLinkedHashSet();
-
- Set<Class<?>> persistenceCapables = reflections.getTypesAnnotatedWith(PersistenceCapable.class);
- persistenceCapables.stream()
- .filter(x -> !x.isAnnotation())
- .forEach(pcSet::add);
-
- Stream<Class<? extends Annotation>> pcMetaAnnotStream =
- (Stream)persistenceCapables.stream().filter(x -> x.isAnnotation());
- pcMetaAnnotStream.map(metaAnnot -> reflections.getTypesAnnotatedWith(metaAnnot).stream())
- .flatMap(x -> x)
- .filter(x -> !x.isAnnotation())
- .forEach(pcSet::add);
-
- return pcSet;
- }
-
}
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
index 7d9322b..941c6e8 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProvider.java
@@ -137,7 +137,7 @@ public abstract class IsisComponentProvider {
final Discovery discovery = _Reflect.discover(moduleAndFrameworkPackages);
final Set<Class<?>> domainServiceTypes = discovery.getTypesAnnotatedWith(DomainService.class);
- final Set<Class<?>> persistenceCapableTypes = discovery.findPersistenceCapableTypes();
+ final Set<Class<?>> persistenceCapableTypes = PersistenceCapableTypeFinder.find(discovery);
final Set<Class<? extends FixtureScript>> fixtureScriptTypes = discovery.getSubTypesOf(FixtureScript.class);
final Set<Class<?>> mixinTypes = Sets.newHashSet();
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/PersistenceCapableTypeFinder.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/PersistenceCapableTypeFinder.java
new file mode 100644
index 0000000..1fbf533
--- /dev/null
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/PersistenceCapableTypeFinder.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.isis.core.runtime.systemusinginstallers;
+
+import java.lang.annotation.Annotation;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.jdo.annotations.PersistenceCapable;
+
+import org.apache.isis.applib.internal.reflection._Reflect.Discovery;
+
+/**
+ *
+ * Package private helper class. Finds PersistenceCapable types.
+ *
+ */
+class PersistenceCapableTypeFinder {
+
+ @SuppressWarnings("unchecked")
+ static Set<Class<?>> find(Discovery discovery) {
+
+ final Set<Class<?>> types = new LinkedHashSet<>();
+
+ discovery.getTypesAnnotatedWith(PersistenceCapable.class).stream()
+ .forEach(type->{
+
+ if(type.isAnnotation()) {
+
+ // We have an annotation, that is annotated with @PersistenceCapable,
+ // this requires special treatment:
+ // Search for any classes annotated with this (meta-)annotation.
+
+ discovery.getTypesAnnotatedWith((Class<? extends Annotation>) type).stream()
+ .filter(x->!x.isAnnotation())
+ .forEach(types::add);
+
+ } else {
+
+ types.add(type);
+
+ }
+ });
+
+ return types;
+ }
+
+}
--
To stop receiving notification emails like this one, please contact
ahuber@apache.org.