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/05/13 18:32:31 UTC
[isis] 01/02: ISIS-2112: cleaning up the IsisConfiguration Interface
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch 2112_SpringBoot
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 29e79519a1767d05f006ebc78bc646803ae41a1f
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon May 13 19:04:55 2019 +0200
ISIS-2112: cleaning up the IsisConfiguration Interface
Task-Url: https://issues.apache.org/jira/browse/ISIS-2112
---
.../apache/isis/config/ConfigurationConstants.java | 7 +-
.../org/apache/isis/config/IsisConfiguration.java | 74 ++++------------------
.../specloader/specimpl/FacetedMethodsBuilder.java | 47 +++++++-------
3 files changed, 40 insertions(+), 88 deletions(-)
diff --git a/core/config/src/main/java/org/apache/isis/config/ConfigurationConstants.java b/core/config/src/main/java/org/apache/isis/config/ConfigurationConstants.java
index 7acb3aa..d8f48c2 100644
--- a/core/config/src/main/java/org/apache/isis/config/ConfigurationConstants.java
+++ b/core/config/src/main/java/org/apache/isis/config/ConfigurationConstants.java
@@ -35,10 +35,15 @@ public final class ConfigurationConstants {
public static final String DEFAULT_CONFIG_DIRECTORY = "config";
public static final String WEBINF_DIRECTORY = "WEB-INF";
public static final String WEBINF_FULL_DIRECTORY = "src/main/webapp/" + WEBINF_DIRECTORY;
-
+
public static final String DEFAULT_CONFIG_FILE = "isis.properties";
public static final String WEB_CONFIG_FILE = "web.properties";
+ public static final class Keys {
+ public static final String EXPLICIT_ANNOTATIONS_FOR_ACTIONS =
+ ROOT + "reflector.explicitAnnotations.action";
+ }
+
public static final List<String> PROTECTED_KEYS =
_Lists.of("password", "apiKey", "authToken");
diff --git a/core/config/src/main/java/org/apache/isis/config/IsisConfiguration.java b/core/config/src/main/java/org/apache/isis/config/IsisConfiguration.java
index 7903692..9917ef0 100644
--- a/core/config/src/main/java/org/apache/isis/config/IsisConfiguration.java
+++ b/core/config/src/main/java/org/apache/isis/config/IsisConfiguration.java
@@ -28,7 +28,8 @@ import java.util.Map;
* system.
*/
public interface IsisConfiguration {
-
+
+//TODO[2112] remove comment
// /**
// * How to handle the case when the configuration already contains the key being added.
// */
@@ -46,36 +47,7 @@ public interface IsisConfiguration {
// */
// EXCEPTION
// }
-
- // -- BUILDERS
-
-// /**
-// *
-// * @param topModule
-// * @param additionalPropertyResources
-// * @return
-// * @since 2.0.0-M2
-// */
-// static IsisConfiguration buildFromModuleTree(Module topModule, PropertyResource ... additionalPropertyResources) {
-// clear();
-// acceptBuilder(builder->{
-// stream(additionalPropertyResources)
-// .forEach(builder::addPropertyResource);
-// builder.addTopModule(topModule);
-// });
-// return getConfiguration();
-// }
-
-// /**
-// * @since 2.0.0-M2
-// */
-// static IsisConfiguration buildFromAppManifest(AppManifest appManifest) {
-// clear();
-// acceptBuilder(builder->{
-// builder.addAppManifest(appManifest);
-// });
-// return getConfiguration();
-// }
+
// -- VERSION
@@ -85,11 +57,11 @@ public interface IsisConfiguration {
// --
-// /**
-// * @since 2.0.0-M2
-// */
-// public AppManifest getAppManifest();
-
+ /**
+ * Creates a copy of this instance, that is a new IsisConfiguration populated
+ * with a copy of the underlying key/value pairs.
+ *
+ */
IsisConfiguration copy();
/**
@@ -222,35 +194,11 @@ public interface IsisConfiguration {
boolean isEmpty();
-// /**
-// * Iterates over the property names of this configuration.
-// */
-// Iterator<String> iterator();
-//
-// Iterable<String> asIterable();
-//
-// int size();
-//
-// /**
-// * The {@link ResourceStreamSource} that was used to build this
-// * configuration.
-// */
-// ResourceStreamSource getResourceStreamSource();
-// /**
-// * A mutable copy of the current set of properties (name/values) held in this configuration.
-// */
-// Map<String, String> asMap();
-
+ /**
+ * A mutable copy of the current set of properties (name/values) held in this configuration.
+ */
Map<String, String> copyToMap();
-
- // -- SHORTCUTS
-
- default boolean explicitAnnotationsForActions() {
- return getBoolean("isis.reflector.explicitAnnotations.action");
- }
-
-
}
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
index 994d778..ca1ced6 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/specimpl/FacetedMethodsBuilder.java
@@ -29,6 +29,7 @@ import java.util.Set;
import org.apache.isis.applib.annotation.Action;
import org.apache.isis.commons.internal.collections._Lists;
import org.apache.isis.commons.internal.collections._Sets;
+import org.apache.isis.config.ConfigurationConstants;
import org.apache.isis.config.internal._Config;
import org.apache.isis.core.commons.exceptions.IsisException;
import org.apache.isis.core.commons.lang.ListExtensions;
@@ -50,25 +51,21 @@ import org.apache.isis.core.metamodel.specloader.SpecificationLoader;
import org.apache.isis.core.metamodel.specloader.classsubstitutor.ClassSubstitutor;
import org.apache.isis.core.metamodel.specloader.facetprocessor.FacetProcessor;
import org.apache.isis.core.metamodel.specloader.traverser.SpecificationTraverser;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import lombok.val;
+import lombok.extern.slf4j.Slf4j;
+@Slf4j
public class FacetedMethodsBuilder {
- private static final Logger LOG = LoggerFactory.getLogger(FacetedMethodsBuilder.class);
-
private static final String GET_PREFIX = "get";
private static final String IS_PREFIX = "is";
private static final class FacetedMethodsMethodRemover implements MethodRemover {
- private final Class<?> introspectedClass;
private final List<Method> methods;
private FacetedMethodsMethodRemover(final Class<?> introspectedClass, final List<Method> methods) {
- this.introspectedClass = introspectedClass;
this.methods = methods;
}
@@ -149,8 +146,8 @@ public class FacetedMethodsBuilder {
public FacetedMethodsBuilder(
final ObjectSpecificationAbstract spec,
final FacetedMethodsBuilderContext facetedMethodsBuilderContext) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("creating JavaIntrospector for {}", spec.getFullIdentifier());
+ if (log.isDebugEnabled()) {
+ log.debug("creating JavaIntrospector for {}", spec.getFullIdentifier());
}
this.spec = spec;
@@ -162,7 +159,9 @@ public class FacetedMethodsBuilder {
this.facetProcessor = facetedMethodsBuilderContext.facetProcessor;
this.specificationLoader = facetedMethodsBuilderContext.specificationLoader;
- this.explicitAnnotationsForActions = _Config.getConfiguration().explicitAnnotationsForActions();
+ this.explicitAnnotationsForActions = _Config.getConfiguration()
+ .getBoolean(ConfigurationConstants.Keys.EXPLICIT_ANNOTATIONS_FOR_ACTIONS);
+
}
// ////////////////////////////////////////////////////////////////////////////
@@ -179,14 +178,14 @@ public class FacetedMethodsBuilder {
public void introspectObjectSpecId() {
- if (LOG.isInfoEnabled()) {
- LOG.info("introspecting {}: objectSpecId", getClassName());
+ if (log.isInfoEnabled()) {
+ log.info("introspecting {}: objectSpecId", getClassName());
}
getFacetProcessor().processObjectSpecId(introspectedClass, spec);
}
public void introspectClass() {
- if (LOG.isInfoEnabled()) {
- LOG.info("introspecting {}: class-level details", getClassName());
+ if (log.isInfoEnabled()) {
+ log.info("introspecting {}: class-level details", getClassName());
}
// process facets at object level
@@ -229,8 +228,8 @@ public class FacetedMethodsBuilder {
}
private List<FacetedMethod> createAssociationFacetedMethods() {
- if (LOG.isDebugEnabled()) {
- LOG.debug("introspecting {}: properties and collections", getClassName());
+ if (log.isDebugEnabled()) {
+ log.debug("introspecting {}: properties and collections", getClassName());
}
final Set<Method> associationCandidateMethods = getFacetProcessor().findAssociationCandidateAccessors(methods, new HashSet<Method>());
@@ -278,8 +277,8 @@ public class FacetedMethodsBuilder {
final List<Method> accessorMethods,
final List<FacetedMethod> facetMethodsToAppendto) {
for (final Method accessorMethod : accessorMethods) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(" identified accessor method representing collection: {}", accessorMethod);
+ if (log.isDebugEnabled()) {
+ log.debug(" identified accessor method representing collection: {}", accessorMethod);
}
// create property and add facets
@@ -308,7 +307,7 @@ public class FacetedMethodsBuilder {
final List<FacetedMethod> facetedMethodsToAppendto) throws MetaModelException {
for (final Method accessorMethod : accessorMethods) {
- LOG.debug(" identified accessor method representing property: {}", accessorMethod);
+ log.debug(" identified accessor method representing property: {}", accessorMethod);
final Class<?> returnType = accessorMethod.getReturnType();
@@ -357,8 +356,8 @@ public class FacetedMethodsBuilder {
*/
private List<FacetedMethod> findActionFacetedMethods(
final MethodScope methodScope) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("introspecting {}: actions", getClassName());
+ if (log.isDebugEnabled()) {
+ log.debug("introspecting {}: actions", getClassName());
}
final List<FacetedMethod> actionFacetedMethods1 = findActionFacetedMethods(methodScope, RecognisedHelpersStrategy.SKIP);
final List<FacetedMethod> actionFacetedMethods2 = findActionFacetedMethods(methodScope, RecognisedHelpersStrategy.DONT_SKIP);
@@ -369,8 +368,8 @@ public class FacetedMethodsBuilder {
final MethodScope methodScope,
final RecognisedHelpersStrategy recognisedHelpersStrategy) {
- if (LOG.isDebugEnabled()) {
- LOG.debug(" looking for action methods");
+ if (log.isDebugEnabled()) {
+ log.debug(" looking for action methods");
}
final List<FacetedMethod> actionFacetedMethods = _Lists.newArrayList();
@@ -466,7 +465,7 @@ public class FacetedMethodsBuilder {
return false;
}
if (recognisedHelpersStrategy.skip()) {
- LOG.debug(" skipping possible helper method {0}", actionMethod);
+ log.debug(" skipping possible helper method {0}", actionMethod);
return false;
}
}
@@ -476,7 +475,7 @@ public class FacetedMethodsBuilder {
return false;
}
}
- LOG.debug(" identified action {0}", actionMethod);
+ log.debug(" identified action {0}", actionMethod);
return true;
}