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 2016/06/16 10:42:41 UTC

[50/50] [abbrv] isis git commit: ISIS-1443: deals with subclass domain services

ISIS-1443: deals with subclass domain services

whereby the superclass is also a domain service but is only loaded
implicitly by walking the type hierarchy.  This commit ensures that
if that superclass is annotated with @DomainService then it will
correctly be created with a service ObjectSpec


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/3dffc2d9
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/3dffc2d9
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/3dffc2d9

Branch: refs/heads/master
Commit: 3dffc2d96e240982d16131d57d34fc8f54d1292c
Parents: 90828ab
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Jun 16 11:29:53 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Jun 16 11:29:53 2016 +0100

----------------------------------------------------------------------
 .../isis/core/metamodel/specloader/SpecificationLoader.java  | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/3dffc2d9/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/SpecificationLoader.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/SpecificationLoader.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/SpecificationLoader.java
index bc745fe..d5791d1 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/SpecificationLoader.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/SpecificationLoader.java
@@ -315,7 +315,13 @@ public class SpecificationLoader implements ApplicationScopedComponent {
     }
 
     private ObjectSpecification internalLoadSpecification(final Class<?> type) {
-        return internalLoadSpecification(type, null);
+        // superclasses tend to be loaded via this method, implicitly.
+        // what can happen is that a subclass domain service, eg a fake one such as FakeLocationLookupService
+        // can be registered first prior to the "real" implementation.  As belt-n-braces, if that superclass is
+        // annotated using @DomainService, then we ensure its own spec is created correctly as a service spec.
+        final DomainService domainServiceIfAny = type.getAnnotation(DomainService.class);
+        final NatureOfService natureOfServiceIfAny = domainServiceIfAny != null ? domainServiceIfAny.nature() : null;
+        return internalLoadSpecification(type, natureOfServiceIfAny);
     }
 
     private ObjectSpecification internalLoadSpecification(final Class<?> type, final NatureOfService nature) {