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/12/09 18:01:45 UTC
[isis] branch master updated: ISIS-2158: adds @Servive annotated
classes to the meta-model
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
The following commit(s) were added to refs/heads/master by this push:
new db6d766 ISIS-2158: adds @Servive annotated classes to the meta-model
db6d766 is described below
commit db6d76640ae9d68c1962e0ce336f2ebc7af0b273
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Dec 9 19:01:38 2019 +0100
ISIS-2158: adds @Servive annotated classes to the meta-model
---
.../applib/services/registry/ServiceRegistry.java | 10 ---
.../isis/config/beans/IsisBeanTypeRegistry.java | 90 +++++++++-------------
.../config/beans/IsisComponentScanInterceptor.java | 19 +----
.../services/registry/ServiceRegistryDefault.java | 12 ++-
.../specloader/SpecificationLoaderDefault.java | 7 +-
.../specimpl/ObjectSpecificationAbstract.java | 6 ++
.../specimpl/dflt/ObjectSpecificationDefault.java | 3 +-
.../ixn/InteractionDtoServiceInternalDefault.java | 18 ++---
8 files changed, 65 insertions(+), 100 deletions(-)
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/registry/ServiceRegistry.java b/core/applib/src/main/java/org/apache/isis/applib/services/registry/ServiceRegistry.java
index e0549e4..43ed4a4 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/registry/ServiceRegistry.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/registry/ServiceRegistry.java
@@ -130,16 +130,6 @@ public interface ServiceRegistry {
.orElseThrow(()->
new NoSuchElementException("Could not locate service of type '" + serviceClass + "'"));
}
-
-//XXX too slow
-// /**
-// * @param requiredType
-// * @return whether the requiredType can be resolved to a container managed bean
-// */
-// public default boolean isResolvableBean(Class<?> requiredType) {
-// return streamRegisteredBeans()
-// .anyMatch(bean->bean.getBeanClass().isAssignableFrom(requiredType));
-// }
// -- PRIORITY ANNOTATION HANDLING
diff --git a/core/config/src/main/java/org/apache/isis/config/beans/IsisBeanTypeRegistry.java b/core/config/src/main/java/org/apache/isis/config/beans/IsisBeanTypeRegistry.java
index 45a5f35..be2ceba 100644
--- a/core/config/src/main/java/org/apache/isis/config/beans/IsisBeanTypeRegistry.java
+++ b/core/config/src/main/java/org/apache/isis/config/beans/IsisBeanTypeRegistry.java
@@ -30,6 +30,7 @@ import java.util.Set;
import javax.enterprise.inject.Vetoed;
import org.springframework.stereotype.Component;
+import org.springframework.stereotype.Service;
import org.apache.isis.applib.annotation.DomainObject;
import org.apache.isis.applib.annotation.DomainService;
@@ -66,7 +67,7 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
// -- DISTINCT CATEGORIES OF BEAN SORTS
- @Getter private final Map<Class<?>, String> managedBeanNamesByType = new HashMap<>();
+ private final Map<Class<?>, String> managedBeanNamesByType = new HashMap<>();
@Getter private final Set<Class<?>> entityTypes = new HashSet<>();
@Getter private final Set<Class<?>> mixinTypes = new HashSet<>();
@Getter private final Set<Class<?>> viewModelTypes = new HashSet<>();
@@ -82,48 +83,11 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
@Override
public void close() {
-// if(!_Spring.isContextAvailable()) {
-// // this instance needs to survive a _Context.clear() call when Spring's context
-// // gets passed over to Isis
-// return;
-// }
-
managedBeanNamesByType.clear();
introspectableTypes.clear();
allCategorySets.forEach(Set::clear);
}
- // -- INBOX
-
- public void addIntrospectableType(BeanSort sort, TypeMetaData typeMeta) {
- val type = typeMeta.getUnderlyingClass();
- synchronized (introspectableTypes) {
- introspectableTypes.put(type, sort);
-
- switch (sort) {
- case MANAGED_BEAN:
- managedBeanNamesByType.put(type, typeMeta.getEffectiveBeanName());
- return;
- case MIXIN:
- mixinTypes.add(type);
- return;
- case ENTITY:
- entityTypes.add(type);
- return;
- case VIEW_MODEL:
- viewModelTypes.add(type);
- return;
-
- //XXX skip introspection for these
- case COLLECTION:
- case VALUE:
- case UNKNOWN:
- break;
- }
-
- }
- }
-
public Map<Class<?>, BeanSort> snapshotIntrospectableTypes() {
final Map<Class<?>, BeanSort> defensiveCopy;
@@ -165,7 +129,9 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
}
val isManagedBeanToBeInspected = beanSort.isManagedBean()
- && findNearestAnnotation(type, DomainService.class).isPresent();
+ && (findNearestAnnotation(type, DomainService.class).isPresent()
+ || findNearestAnnotation(type, Service.class).isPresent()
+ );
val isManagedObjectToBeInspected = !beanSort.isManagedBean()
&& !beanSort.isUnknown();
@@ -181,14 +147,12 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
beanSort.name());
}
}
-
-
-
}
/**
- * If given type is available for injection, returns the <em>Managed Bean's</em> name (id) as
+ * If given type is part of the meta-model and is available for injection,
+ * returns the <em>Managed Bean's</em> name (id) as
* recognized by the IoC container, {@code null} otherwise;
* @param type
* @return
@@ -201,9 +165,9 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
}
/**
- * Whether given type is available for injection. Is a <em>Managed Bean</em>.
+ * Whether given type is part of the meta-model and is available for injection
+ * (is a <em>Managed Bean</em>).
* @param type
- * @return
*/
public boolean isManagedBean(Class<?> type) {
return getManagedBeanNameForType(type)!=null;
@@ -211,7 +175,35 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
// -- HELPER
- // the SpecLoader does a better job at this
+ private void addIntrospectableType(BeanSort sort, TypeMetaData typeMeta) {
+ val type = typeMeta.getUnderlyingClass();
+ synchronized (introspectableTypes) {
+ introspectableTypes.put(type, sort);
+
+ switch (sort) {
+ case MANAGED_BEAN:
+ managedBeanNamesByType.put(type, typeMeta.getEffectiveBeanName());
+ return;
+ case MIXIN:
+ mixinTypes.add(type);
+ return;
+ case ENTITY:
+ entityTypes.add(type);
+ return;
+ case VIEW_MODEL:
+ viewModelTypes.add(type);
+ return;
+
+ // skip introspection for these
+ case COLLECTION:
+ case VALUE:
+ case UNKNOWN:
+ return;
+ }
+
+ }
+ }
+
private BeanSort quickClassify(Class<?> type) {
requires(type, "type");
@@ -273,12 +265,6 @@ public final class IsisBeanTypeRegistry implements IsisComponentScanInterceptor,
}
}
-//XXX RequestScoped is just a qualifier, don't decide on that
-//
-// if(findNearestAnnotation(type, RequestScoped.class).isPresent()) {
-// return BeanSort.MANAGED_BEAN;
-// }
-
if(findNearestAnnotation(type, Component.class).isPresent()) {
return BeanSort.MANAGED_BEAN;
}
diff --git a/core/config/src/main/java/org/apache/isis/config/beans/IsisComponentScanInterceptor.java b/core/config/src/main/java/org/apache/isis/config/beans/IsisComponentScanInterceptor.java
index 1267fbd..c292caa 100644
--- a/core/config/src/main/java/org/apache/isis/config/beans/IsisComponentScanInterceptor.java
+++ b/core/config/src/main/java/org/apache/isis/config/beans/IsisComponentScanInterceptor.java
@@ -29,7 +29,7 @@ import org.springframework.stereotype.Component;
public interface IsisComponentScanInterceptor {
/**
- * Allows for the given type-meta to by modified before bean-definition registration
+ * Allows for the given type-meta to be modified before bean-definition registration
* is finalized by the IoC, immediately after the type-scan phase.
* Aspects to be modified:
* <br>- Whether given {@link Component} annotated or meta-annotated type should be made
@@ -41,22 +41,5 @@ public interface IsisComponentScanInterceptor {
* discovered types into a type registry
*/
void intercept(TypeMetaData type);
-
-// /**
-// * If given type is available for injection, returns the <em>Managed Bean's</em> name (id) as
-// * recognized by the IoC container, {@code null} otherwise;
-// * @param type
-// * @return
-// */
-// String getManagedBeanNameForType(Class<?> type);
-//
-// /**
-// * Whether given type is available for injection. Is a <em>Managed Bean</em>.
-// * @param type
-// * @return
-// */
-// default boolean isManagedBean(Class<?> type) {
-// return getManagedBeanNameForType(type)!=null;
-// }
}
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/services/registry/ServiceRegistryDefault.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/services/registry/ServiceRegistryDefault.java
index 652a80a..05c8eff 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/services/registry/ServiceRegistryDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/services/registry/ServiceRegistryDefault.java
@@ -21,13 +21,17 @@ package org.apache.isis.metamodel.services.registry;
import java.lang.annotation.Annotation;
import java.util.Map;
-import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
import javax.inject.Inject;
import javax.inject.Named;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Service;
+
import org.apache.isis.applib.annotation.OrderPrecedence;
import org.apache.isis.applib.services.registry.ServiceRegistry;
import org.apache.isis.commons.collections.Can;
@@ -38,12 +42,7 @@ import org.apache.isis.commons.internal.environment.IsisSystemEnvironment;
import org.apache.isis.commons.internal.ioc.ManagedBeanAdapter;
import org.apache.isis.commons.internal.ioc.spring._Spring;
import org.apache.isis.config.beans.IsisBeanTypeRegistryHolder;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Primary;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Service;
-import lombok.extern.log4j.Log4j2;
import lombok.val;
@Service
@@ -51,7 +50,6 @@ import lombok.val;
@Order(OrderPrecedence.MIDPOINT)
@Primary
@Qualifier("Default")
-@Log4j2
public final class ServiceRegistryDefault implements ServiceRegistry {
// enforces provisioning order (this is a depends-on relationship)
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 51a810e..498f9f1 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
@@ -297,7 +297,9 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
}
@Override @Nullable
- public ObjectSpecification loadSpecification(@Nullable final Class<?> type, final IntrospectionState upTo) {
+ public ObjectSpecification loadSpecification(
+ @Nullable final Class<?> type,
+ final IntrospectionState upTo) {
if(type==null) {
return null;
@@ -383,7 +385,8 @@ public class SpecificationLoaderDefault implements SpecificationLoader {
metaModelContext,
facetProcessor,
managedBeanNameIfAny,
- postProcessor, classSubstitutor);
+ postProcessor,
+ classSubstitutor);
}
return objectSpec;
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java
index 4738f87..25e7e6b 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/specimpl/ObjectSpecificationAbstract.java
@@ -39,6 +39,7 @@ import org.apache.isis.commons.internal.collections._Multimaps;
import org.apache.isis.commons.internal.collections._Multimaps.ListMultimap;
import org.apache.isis.commons.internal.collections._Sets;
import org.apache.isis.commons.internal.collections._Streams;
+import org.apache.isis.commons.internal.exceptions._Exceptions;
import org.apache.isis.commons.internal.ioc.BeanSort;
import org.apache.isis.commons.internal.ioc.ManagedBeanAdapter;
import org.apache.isis.config.beans.IsisBeanTypeRegistryHolder;
@@ -772,6 +773,11 @@ public abstract class ObjectSpecificationAbstract extends FacetHolderImpl implem
val serviceClass = serviceBean.getBeanClass();
val specification = getSpecificationLoader().loadSpecification(serviceClass,
IntrospectionState.TYPE_AND_MEMBERS_INTROSPECTED);
+
+ if(specification==null) {
+ throw _Exceptions.unrecoverableFormatted("failed to load specification for service %s", serviceClass);
+ }
+
if (specification == this) {
return;
}
diff --git a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
index f7d7807..f19762b 100644
--- a/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
+++ b/core/metamodel/src/main/java/org/apache/isis/metamodel/specloader/specimpl/dflt/ObjectSpecificationDefault.java
@@ -132,7 +132,8 @@ public class ObjectSpecificationDefault extends ObjectSpecificationAbstract impl
}
val domainServiceFacet = getFacet(DomainServiceFacet.class);
- val isServiceWithNatureOfDomain = domainServiceFacet != null && domainServiceFacet.getNatureOfService() == NatureOfService.DOMAIN;
+ val isServiceWithNatureOfDomain = domainServiceFacet != null
+ && domainServiceFacet.getNatureOfService() == NatureOfService.DOMAIN;
if (isServiceWithNatureOfDomain) {
if (log.isDebugEnabled()) {
log.debug("skipping type hierarchy introspection for domain service with natureOfService = DOMAIN {}", getFullIdentifier());
diff --git a/core/runtime-services/src/main/java/org/apache/isis/runtime/services/ixn/InteractionDtoServiceInternalDefault.java b/core/runtime-services/src/main/java/org/apache/isis/runtime/services/ixn/InteractionDtoServiceInternalDefault.java
index 973af39..8a48058 100644
--- a/core/runtime-services/src/main/java/org/apache/isis/runtime/services/ixn/InteractionDtoServiceInternalDefault.java
+++ b/core/runtime-services/src/main/java/org/apache/isis/runtime/services/ixn/InteractionDtoServiceInternalDefault.java
@@ -19,19 +19,24 @@
package org.apache.isis.runtime.services.ixn;
-import lombok.extern.log4j.Log4j2;
-
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.context.annotation.Primary;
+import org.springframework.core.annotation.Order;
+import org.springframework.stereotype.Service;
+
import org.apache.isis.applib.annotation.OrderPrecedence;
import org.apache.isis.applib.services.bookmark.Bookmark;
import org.apache.isis.applib.services.bookmark.BookmarkService;
import org.apache.isis.applib.services.iactn.Interaction;
import org.apache.isis.applib.services.iactn.InteractionContext;
import org.apache.isis.applib.services.user.UserService;
+import org.apache.isis.applib.util.schema.CommandDtoUtils;
+import org.apache.isis.applib.util.schema.InteractionDtoUtils;
import org.apache.isis.metamodel.services.command.CommandDtoServiceInternal;
import org.apache.isis.metamodel.services.ixn.InteractionDtoServiceInternal;
import org.apache.isis.metamodel.spec.ManagedObject;
@@ -44,22 +49,15 @@ import org.apache.isis.schema.cmd.v1.PropertyDto;
import org.apache.isis.schema.common.v1.ValueWithTypeDto;
import org.apache.isis.schema.ixn.v1.ActionInvocationDto;
import org.apache.isis.schema.ixn.v1.PropertyEditDto;
-import org.apache.isis.applib.util.schema.CommandDtoUtils;
-import org.apache.isis.applib.util.schema.InteractionDtoUtils;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.context.annotation.Primary;
-import org.springframework.core.annotation.Order;
-import org.springframework.stereotype.Service;
@Service
@Named("isisRuntimeServices.InteractionDtoServiceInternalDefault")
@Order(OrderPrecedence.MIDPOINT)
@Primary
@Qualifier("Default")
-@Log4j2
public class InteractionDtoServiceInternalDefault implements InteractionDtoServiceInternal {
- @Inject CommandDtoServiceInternal commandDtoServiceInternal;
+ @Inject private CommandDtoServiceInternal commandDtoServiceInternal;
@Inject private BookmarkService bookmarkService;
@Inject private InteractionContext interactionContext;
@Inject private UserService userService;