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 2019/10/10 12:56:40 UTC
[isis] branch v2 updated: ISIS-2158: polishing the
SpecificationLoaderDefault
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git
The following commit(s) were added to refs/heads/v2 by this push:
new c0b679f ISIS-2158: polishing the SpecificationLoaderDefault
c0b679f is described below
commit c0b679fb92a5e74fbfefc0ef21a48d88ed24fa0a
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Oct 10 14:56:31 2019 +0200
ISIS-2158: polishing the SpecificationLoaderDefault
---
.../isis/config/registry/IsisBeanTypeRegistry.java | 24 +------
.../specloader/SpecificationLoaderDefault.java | 81 ++++++----------------
.../SpecificationLoaderDefault_debug.java | 79 +++++++++++++++++++++
.../jdo/metamodel/JdoProgrammingModelPlugin.java | 2 +-
4 files changed, 105 insertions(+), 81 deletions(-)
diff --git a/core/config/src/main/java/org/apache/isis/config/registry/IsisBeanTypeRegistry.java b/core/config/src/main/java/org/apache/isis/config/registry/IsisBeanTypeRegistry.java
index 9b73b0d..cc8e8d4 100644
--- a/core/config/src/main/java/org/apache/isis/config/registry/IsisBeanTypeRegistry.java
+++ b/core/config/src/main/java/org/apache/isis/config/registry/IsisBeanTypeRegistry.java
@@ -290,6 +290,8 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
return BeanSort.MANAGED_BEAN;
}
+//XXX RequestScoped is just a qualifier, don't decide on that
+//
// if(findNearestAnnotation(type, RequestScoped.class).isPresent()) {
// return BeanSort.MANAGED_BEAN;
// }
@@ -306,26 +308,4 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
}
-
-
-
-
-
- // if we ever want to ever implement an alternative solution to the autoclose hack above ...
- // public IsisBeanTypeRegistry copy() {
- //
- // val copy = new IsisBeanTypeRegistry();
- //
- // val it1 = this.allTypeSets.iterator();
- // val it2 = copy.allTypeSets.iterator();
- //
- // it1.forEachRemaining(src->{
- // val dst = it2.next();
- // dst.addAll((Collection) src);
- // });
- //
- // return copy;
- // }
-
-
}
\ No newline at end of file
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault.java
index 10b9efc..bdd055a 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault.java
@@ -19,9 +19,7 @@
package org.apache.isis.metamodel.specloader;
import java.util.Collection;
-import java.util.List;
import java.util.function.Consumer;
-import java.util.stream.Collectors;
import javax.annotation.Nullable;
import javax.annotation.PostConstruct;
@@ -131,27 +129,26 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
facetProcessor.init();
postProcessor.init();
- // need to completely load services and mixins (synchronously)
- log.info("Categorizing types (directly) from scan result", IntrospectionState.NOT_INTROSPECTED);
-
val typeRegistry = IsisBeanTypeRegistry.current();
- val specificationsFromRegistry = _Lists.<ObjectSpecification>newArrayList();
+ val scannedSpecs = _Lists.<ObjectSpecification>newArrayList();
val domainServiceSpecs = _Lists.<ObjectSpecification>newArrayList();
- val mixinSpecs = _Lists.<ObjectSpecification>newArrayList();
+ val domainObjectSpecs = _Lists.<ObjectSpecification>newArrayList();
CommonDtoUtils.VALUE_TYPES.forEach(type->{
val spec = loadSpecification(type, IntrospectionState.NOT_INTROSPECTED);
- if(spec!=null) specificationsFromRegistry.add(spec);
+ if(spec!=null) scannedSpecs.add(spec);
});
+ log.info(" - categorizing types from class-path scan");
+
typeRegistry.streamAndClearInbox().forEach(entry->{
val type = entry.getKey();
val sort = entry.getValue();
val spec = loadSpecification(type, IntrospectionState.NOT_INTROSPECTED);
- if(spec!=null) specificationsFromRegistry.add(spec);
+ if(spec!=null) scannedSpecs.add(spec);
switch (sort) {
case MANAGED_BEAN:
@@ -160,14 +157,15 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
return;
case MIXIN:
typeRegistry.getMixinTypes().add(type);
- mixinSpecs.add(spec);
+ domainObjectSpecs.add(spec);
return;
case ENTITY:
typeRegistry.getEntityTypes().add(type);
- mixinSpecs.add(spec); //XXX why?
+ domainObjectSpecs.add(spec);
return;
case VIEW_MODEL:
typeRegistry.getViewModelTypes().add(type);
+ domainObjectSpecs.add(spec);
return;
default:
@@ -177,27 +175,30 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
});
val stopWatch = _Timing.now();
- val cachedSpecifications = cache.snapshotSpecs();
+
- logBefore(specificationsFromRegistry, cachedSpecifications);
+ SpecificationLoaderDefault_debug.logBefore(log, cache, scannedSpecs);
- log.info("Categorizing types referenced from scan result");
- introspect(specificationsFromRegistry, IntrospectionState.TYPE_INTROSPECTED);
+ log.info(" - introspecting {} type hierarchies", scannedSpecs.size());
+ introspect(scannedSpecs, IntrospectionState.TYPE_INTROSPECTED);
- log.info("Introspecting domain services");
+ log.info(" - introspecting {} domain services", domainServiceSpecs.size());
introspect(domainServiceSpecs, IntrospectionState.TYPE_AND_MEMBERS_INTROSPECTED);
- log.info("Introspecting mixins");
- introspect(mixinSpecs, IntrospectionState.TYPE_AND_MEMBERS_INTROSPECTED);
+ log.info(" - introspecting {} mixins", typeRegistry.getMixinTypes().size());
+ log.info(" - introspecting {} entities", typeRegistry.getEntityTypes().size());
+ log.info(" - introspecting {} view models", typeRegistry.getViewModelTypes().size());
+ introspect(domainObjectSpecs, IntrospectionState.TYPE_AND_MEMBERS_INTROSPECTED);
- logAfter(cachedSpecifications);
+ SpecificationLoaderDefault_debug.logAfter(log, cache, scannedSpecs);
if(isFullIntrospect()) {
- log.info("Introspecting all types eagerly (FullIntrospect=true)");
- introspect(cachedSpecifications, IntrospectionState.TYPE_AND_MEMBERS_INTROSPECTED);
+ val snapshot = cache.snapshotSpecs();
+ log.info(" - introspecting all {} types eagerly (FullIntrospect=true)", snapshot.size());
+ introspect(snapshot, IntrospectionState.TYPE_AND_MEMBERS_INTROSPECTED);
}
- log.info("Running remaining validators");
+ log.info(" - running remaining validators");
_Blackhole.consume(getValidationResult()); // as a side effect memoizes the validation result
stopWatch.stop();
@@ -343,41 +344,6 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
return objectSpec;
}
- private void logBefore(
- final List<? extends ObjectSpecification> specificationsFromRegistry,
- final Collection<? extends ObjectSpecification> cachedSpecifications) {
- if(!log.isDebugEnabled()) {
- return;
- }
- log.debug(String.format(
- "specificationsFromRegistry.size = %d ; cachedSpecifications.size = %d",
- specificationsFromRegistry.size(), cachedSpecifications.size()));
-
- List<ObjectSpecification> registryNotCached = specificationsFromRegistry.stream()
- .filter(spec -> !cachedSpecifications.contains(spec))
- .collect(Collectors.toList());
- List<ObjectSpecification> cachedNotRegistry = cachedSpecifications.stream()
- .filter(spec -> !specificationsFromRegistry.contains(spec))
- .collect(Collectors.toList());
-
- log.debug(String.format(
- "registryNotCached.size = %d ; cachedNotRegistry.size = %d",
- registryNotCached.size(), cachedNotRegistry.size()));
- }
-
- private void logAfter(final Collection<? extends ObjectSpecification> cachedSpecifications) {
- if(!log.isDebugEnabled()) {
- return;
- }
-
- val cachedSpecificationsAfter = cache.snapshotSpecs();
- List<ObjectSpecification> cachedAfterNotBefore = cachedSpecificationsAfter.stream()
- .filter(spec -> !cachedSpecifications.contains(spec))
- .collect(Collectors.toList());
- log.debug(String.format("cachedSpecificationsAfter.size = %d ; cachedAfterNotBefore.size = %d",
- cachedSpecificationsAfter.size(), cachedAfterNotBefore.size()));
- }
-
private void introspect(
final Collection<ObjectSpecification> specs,
final IntrospectionState upTo) {
@@ -400,7 +366,6 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
}
-
private void invalidateCache(final Class<?> cls) {
val substitutedType = classSubstitutor.getClass(cls);
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault_debug.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault_debug.java
new file mode 100644
index 0000000..c5b079c
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/SpecificationLoaderDefault_debug.java
@@ -0,0 +1,79 @@
+/*
+ * 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.metamodel.specloader;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import org.apache.logging.log4j.Logger;
+
+import org.apache.isis.metamodel.spec.ObjectSpecification;
+
+import lombok.val;
+
+final class SpecificationLoaderDefault_debug {
+
+ static void logBefore(
+ Logger log,
+ SpecificationCacheDefault<ObjectSpecification> cache,
+ List<? extends ObjectSpecification> scanned) {
+
+ if(!log.isDebugEnabled()) {
+ return;
+ }
+
+ val cached = cache.snapshotSpecs();
+
+ log.debug(String.format(
+ "scanned.size = %d ; cached.size = %d",
+ scanned.size(), cached.size()));
+
+ val registryNotCached = scanned.stream()
+ .filter(spec -> !cached.contains(spec))
+ .collect(Collectors.toList());
+ val cachedNotRegistry = cached.stream()
+ .filter(spec -> !scanned.contains(spec))
+ .collect(Collectors.toList());
+
+ log.debug(String.format(
+ "registryNotCached.size = %d ; cachedNotRegistry.size = %d",
+ registryNotCached.size(), cachedNotRegistry.size()));
+ }
+
+ static void logAfter(
+ Logger log,
+ SpecificationCacheDefault<ObjectSpecification> cache,
+ Collection<? extends ObjectSpecification> scanned) {
+
+ if(!log.isDebugEnabled()) {
+ return;
+ }
+
+ val cached = cache.snapshotSpecs();
+ val cachedAfterNotBefore = cached.stream()
+ .filter(spec -> !scanned.contains(spec))
+ .collect(Collectors.toList());
+
+ log.debug(String.format(
+ "cachedSpecificationsAfter.size = %d ; cachedAfterNotBefore.size = %d",
+ cached.size(), cachedAfterNotBefore.size()));
+ }
+
+}
diff --git a/core/plugins/jdo/common/src/main/java/org/apache/isis/jdo/metamodel/JdoProgrammingModelPlugin.java b/core/plugins/jdo/common/src/main/java/org/apache/isis/jdo/metamodel/JdoProgrammingModelPlugin.java
index b714d1e..656c6a4 100644
--- a/core/plugins/jdo/common/src/main/java/org/apache/isis/jdo/metamodel/JdoProgrammingModelPlugin.java
+++ b/core/plugins/jdo/common/src/main/java/org/apache/isis/jdo/metamodel/JdoProgrammingModelPlugin.java
@@ -220,7 +220,7 @@ public class JdoProgrammingModelPlugin implements MetaModelRefiner {
private void addValidatorToCheckModuleExtent() {
- final Map<String, List<String>> domainObjectClassNamesByPackage = _Maps.newTreeMap();
+ final Map<String, List<String>> domainObjectClassNamesByPackage = _Maps.newConcurrentHashMap();
MetaModelValidatorVisiting.SummarizingVisitor visitor = new MetaModelValidatorVisiting.SummarizingVisitor(){