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 2017/10/01 13:08:44 UTC
[isis] 11/12: ISIS-1726: generalizes the logic that searches for
@PersistenceCapable entities, to also take into account meta-annotations.
This is an automated email from the ASF dual-hosted git repository.
danhaywood pushed a commit to branch dev/2.0.0/ISIS-1276-dn-5-1
in repository https://gitbox.apache.org/repos/asf/isis.git
commit a5419e9f7cdbb8f71a06b02bf58427b84436c3d9
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Sep 19 22:59:43 2017 +0100
ISIS-1726: generalizes the logic that searches for @PersistenceCapable entities, to also take into account meta-annotations.
---
.../IsisComponentProvider.java | 37 ++++++++++++++++------
1 file changed, 28 insertions(+), 9 deletions(-)
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 6616d68..6f599ed 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
@@ -19,17 +19,19 @@
package org.apache.isis.core.runtime.systemusinginstallers;
+import java.lang.annotation.Annotation;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import javax.annotation.Nullable;
import javax.jdo.annotations.PersistenceCapable;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
-import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
@@ -141,21 +143,20 @@ public abstract class IsisComponentProvider {
final Reflections reflections = new Reflections(packages);
final Set<Class<?>> domainServiceTypes = reflections.getTypesAnnotatedWith(DomainService.class);
- final Set<Class<?>> persistenceCapableTypes = reflections.getTypesAnnotatedWith(PersistenceCapable.class);
+ final Set<Class<?>> persistenceCapableTypes = findPersistenceCapableTypes(reflections);
final Set<Class<? extends FixtureScript>> fixtureScriptTypes = reflections.getSubTypesOf(FixtureScript.class);
final Set<Class<?>> mixinTypes = Sets.newHashSet();
mixinTypes.addAll(reflections.getTypesAnnotatedWith(Mixin.class));
final Set<Class<?>> domainObjectTypes = reflections.getTypesAnnotatedWith(DomainObject.class);
mixinTypes.addAll(
- Lists.newArrayList(Iterables.filter(domainObjectTypes, new Predicate<Class<?>>() {
- @Override
- public boolean apply(@Nullable final Class<?> input) {
- if(input == null) { return false; }
- final DomainObject annotation = input.getAnnotation(DomainObject.class);
- return annotation.nature() == Nature.MIXIN;
+ domainObjectTypes.stream().filter(input -> {
+ if (input == null) {
+ return false;
}
- }))
+ final DomainObject annotation = input.getAnnotation(DomainObject.class);
+ return annotation.nature() == Nature.MIXIN;
+ }).collect(Collectors.toList())
);
registry.setDomainServiceTypes(domainServiceTypes);
@@ -164,6 +165,24 @@ public abstract class IsisComponentProvider {
registry.setMixinTypes(mixinTypes);
}
+ private Set<Class<?>> findPersistenceCapableTypes(final Reflections reflections) {
+
+ 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;
+ }
private void specifyServicesAndRegisteredEntitiesUsing(final AppManifest appManifest) {
final Iterable<String> packageNames = modulePackageNamesFrom(appManifest);
--
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.