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 2020/01/09 12:35:32 UTC
[isis] branch master updated (d766bbd -> 00943ba)
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git.
from d766bbd ISIS-2259: docs for extensions etc
new ba625ff ISIS-2158: bring IsisCDIBeanScanInterceptor up to speed with Spring
new 00943ba ISIS-2158: service interfaces not necessarily need an archetype annot.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../applib/services/metrics/MetricsService.java | 6 ---
.../jee_support/IsisCDIBeanScanInterceptor.java | 56 +++++++++-------------
2 files changed, 23 insertions(+), 39 deletions(-)
[isis] 01/02: ISIS-2158: bring IsisCDIBeanScanInterceptor up to
speed with Spring
Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
commit ba625ff5e471facd95fb36656928f8ad16033fce
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Jan 9 13:34:36 2020 +0100
ISIS-2158: bring IsisCDIBeanScanInterceptor up to speed with Spring
---
.../jee_support/IsisCDIBeanScanInterceptor.java | 56 +++++++++-------------
1 file changed, 23 insertions(+), 33 deletions(-)
diff --git a/incubator/extensions/core/microprofile/src/main/java/org/apache/isis/runtime/jee_support/IsisCDIBeanScanInterceptor.java b/incubator/extensions/core/microprofile/src/main/java/org/apache/isis/runtime/jee_support/IsisCDIBeanScanInterceptor.java
index 4e3d607..5f4af06 100644
--- a/incubator/extensions/core/microprofile/src/main/java/org/apache/isis/runtime/jee_support/IsisCDIBeanScanInterceptor.java
+++ b/incubator/extensions/core/microprofile/src/main/java/org/apache/isis/runtime/jee_support/IsisCDIBeanScanInterceptor.java
@@ -18,7 +18,6 @@
*/
package org.apache.isis.runtime.jee_support;
-import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;
@@ -28,9 +27,11 @@ import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import org.apache.isis.applib.annotation.DomainService;
+import org.springframework.stereotype.Component;
+
import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer;
-import org.apache.isis.applib.services.metrics.MetricsService;
+import org.apache.isis.commons.internal.collections._Lists;
+import org.apache.isis.commons.internal.reflection._Annotations;
import lombok.val;
import lombok.extern.log4j.Log4j2;
@@ -38,7 +39,7 @@ import lombok.extern.log4j.Log4j2;
/**
*
* A CDI inject extension @see <a href="https://docs.jboss.org/weld/reference/latest/en-US/html/extend.html">weld</a>,
- * that lets CDI ignore certain Beans we declare tabu.
+ * that lets CDI ignore certain Beans we declare vetoed.
* <p>
* This extension is registered as a service provider by creating a file named
* {@code META-INF/services/javax.enterprise.inject.spi.Extension},
@@ -46,7 +47,7 @@ import lombok.extern.log4j.Log4j2;
* </p>
*
* <p>
- * Beans declared tabu are managed (meaning instantiation and dependency injection)
+ * Beans declared vetoed are managed (meaning instantiation and dependency injection)
* by Isis itself. All other Beans are allowed to be managed by CDI.
* </p>
*
@@ -59,13 +60,11 @@ public final class IsisCDIBeanScanInterceptor implements Extension {
* Declaration of Beans that are managed by Isis and should be ignored by CDI.
* (in addition to those that have the @DomainService annotation)
*/
- private static final List<Predicate<Class<?>>> vetos = new ArrayList<>();
- {
- vetos.add(MetricsService.class::equals);
- vetos.add(ExceptionRecognizer.class::isAssignableFrom);
- vetos.add(type->type.getName().startsWith("org.springframework."));
- vetos.add(type->type.getName().startsWith("org.apache.isis."));
- }
+ private static final List<Predicate<Class<?>>> vetoTests = _Lists.of(
+ ExceptionRecognizer.class::isAssignableFrom,
+ type->type.getName().startsWith("org.springframework."),
+ type->type.getName().startsWith("org.apache.isis."),
+ type->_Annotations.isPresent(type, Component.class));
void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event) {
log.info("beginning the scanning process");
@@ -73,26 +72,19 @@ public final class IsisCDIBeanScanInterceptor implements Extension {
<T> void processAnnotatedType(@Observes ProcessAnnotatedType<T> event) {
- final Class<?> clazz = event.getAnnotatedType().getJavaClass();
- final String className = clazz.getName();
+ final Class<?> type = event.getAnnotatedType().getJavaClass();
+ final String className = type.getName();
- val isTabu = isVetoed(clazz, event);
- if(isTabu) {
+ val isVetoed = isVetoed(type);
+ if(isVetoed) {
event.veto();
}
if(log.isDebugEnabled()) {
- val logScope = className.startsWith("org.apache.isis.") ||
- className.startsWith("domainapp.");
- if(logScope) {
- log.debug("processing annotated type %s", className);
- }
-
- if(isTabu) {
- log.debug("veto type: " + className);
- event.veto();
+ if(isVetoed) {
+ log.debug("vetoing type: {}", className);
} else {
- log.debug("allowing type: " + className);
+ log.debug("allowing type: {}", className);
}
}
@@ -104,14 +96,12 @@ public final class IsisCDIBeanScanInterceptor implements Extension {
// -- HELPER
- private boolean isVetoed(Class<?> clazz, ProcessAnnotatedType<?> event) {
-
- if(event.getAnnotatedType().isAnnotationPresent(DomainService.class)) {
- return true;
- }
- for(Predicate<Class<?>> isVetoed : vetos) {
- if(isVetoed.test(clazz))
+ private boolean isVetoed(Class<?> type) {
+
+ for(val vetoTest : vetoTests) {
+ if(vetoTest.test(type)) {
return true;
+ }
}
return false;
}
[isis] 02/02: ISIS-2158: service interfaces not necessarily need an
archetype annot.
Posted by ah...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 00943ba19689e652cc6bca55d91378d3cd7e2cf3
Author: Andi Huber <ah...@apache.org>
AuthorDate: Thu Jan 9 13:35:22 2020 +0100
ISIS-2158: service interfaces not necessarily need an archetype annot.
---
.../org/apache/isis/applib/services/metrics/MetricsService.java | 6 ------
1 file changed, 6 deletions(-)
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/metrics/MetricsService.java b/core/applib/src/main/java/org/apache/isis/applib/services/metrics/MetricsService.java
index d66966f..f25c57f 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/metrics/MetricsService.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/metrics/MetricsService.java
@@ -18,13 +18,9 @@
*/
package org.apache.isis.applib.services.metrics;
-import javax.enterprise.context.RequestScoped;
-
-import org.apache.isis.applib.annotation.Programmatic;
import org.apache.isis.applib.services.iactn.InteractionContext;
import org.apache.isis.schema.ixn.v1.MemberExecutionDto;
-@RequestScoped
public interface MetricsService {
/**
@@ -38,7 +34,6 @@ public interface MetricsService {
* Is captured within {@link MemberExecutionDto#getMetrics()} (accessible from {@link InteractionContext#getInteraction()}).
* </p>
*/
- @Programmatic
int numberObjectsLoaded();
/**
@@ -53,7 +48,6 @@ public interface MetricsService {
* Is captured within {@link MemberExecutionDto#getMetrics()} (accessible from {@link InteractionContext#getInteraction()}).
* </p>
*/
- @Programmatic
int numberObjectsDirtied();