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 2018/10/20 09:37:10 UTC

[isis] 03/03: ISIS-2014: further trivial additions, updates to javadoc

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch v2
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 06451946c87c23e854f432bde3c492cfcf75030d
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Sat Oct 20 10:36:46 2018 +0100

    ISIS-2014: further trivial additions, updates to javadoc
---
 .../isis/applib/fixturescripts/FixtureScript.java  | 49 ++++++++++++++-----
 .../applib/services/wrapper/WrapperFactory.java    | 18 +++++++
 .../integtestsupport/IntegrationTestAbstract3.java | 56 ++++++++++++----------
 .../core/runtime/headless/HeadlessAbstract.java    | 36 +++++++++-----
 .../isis/core/wrapper/WrapperFactoryDefault.java   | 18 +++----
 5 files changed, 119 insertions(+), 58 deletions(-)

diff --git a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
index 4e9cd09..f32dc3b 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/fixturescripts/FixtureScript.java
@@ -515,6 +515,14 @@ implements InstallableFixture {
             executeChildren(callingFixtureScript, personaWithBuilderScript);
         }
 
+        @Programmatic
+        public <T, F extends BuilderScriptAbstract<T, F>> T executeChildT(
+                final FixtureScript callingFixtureScript,
+                final PersonaWithBuilderScript<T, F> personaWithBuilderScript) {
+            final F f = executeChildT(callingFixtureScript, personaWithBuilderScript.builder());
+            return f.getObject();
+        }
+
         /**
          * Executes a child {@link FixtureScript fixture script}, injecting services into it first, and (for any results
          * that are {@link org.apache.isis.applib.fixturescripts.FixtureScript.ExecutionContext#addResult(FixtureScript, Object)} added),
@@ -930,46 +938,63 @@ implements InstallableFixture {
     }
 
     /**
-     * Wraps domain object
+     * Convenience method, simply delegates to {@link WrapperFactory#wrap(Object)}.
      */
-    protected <T> T w(final T domainObject) {
-        return wrapperFactory.w(domainObject);
+    protected <T> T wrap(final T domainObject) {
+        return wrapperFactory.wrap(domainObject);
     }
 
     /**
-     * Wraps domain object
+     * Convenience method, synonym for {@link #wrap(Object)}.
      */
-    protected <T> T wrap(final T domainObject) {
-        return wrapperFactory.wrap(domainObject);
+    protected <T> T w(final T domainObject) {
+        return wrap(domainObject);
     }
 
+    /**
+     * Convenience method, simply delegates to {@link WrapperFactory#wrap(Object, WrapperFactory.ExecutionMode)}.
+     */
     protected <T> T wrap(final T domainObject, final WrapperFactory.ExecutionMode executionMode) {
         return wrapperFactory.wrap(domainObject, executionMode);
     }
 
     /**
-     * Unwraps domain object (no-arg if already wrapped).
+     * Convenience method, simply delegates to {@link WrapperFactory#unwrap(Object)}.
      */
     protected <T> T unwrap(final T possibleWrappedDomainObject) {
         return wrapperFactory.unwrap(possibleWrappedDomainObject);
     }
 
     /**
-     * Convenience method
+     * Convenience method, simply delegates to {@link FactoryService#mixin(Class, Object)}.
+     */
+    protected <T> T mixin(final Class<T> mixinClass, final Object mixedIn) {
+        return factoryService.mixin(mixinClass, mixedIn);
+    }
+
+    /**
+     * Convenience method, synonym for {@link #mixin(Class, Object)}.
      */
     protected <T> T m(final Class<T> mixinClass, final Object mixedIn) {
         return factoryService.m(mixinClass, mixedIn);
     }
 
     /**
-     * Convenience method
+     * Convenience method, {@link #wrap(Object) wraps} a {@link #mixin(Class, Object) mixin}.
      */
-    protected <T> T mixin(final Class<T> mixinClass, final Object mixedIn) {
-        return factoryService.mixin(mixinClass, mixedIn);
+    protected <T> T wrapMixin(final Class<T> mixinClass, final Object mixedIn) {
+        return wrap(mixin(mixinClass, mixedIn));
+    }
+
+    /**
+     * Convenience method, synonym for {@link #wrapMixin(Class, Object)}.
+     */
+    protected <T> T wm(final Class<T> mixinClass, final Object mixedIn) {
+        return wrapMixin(mixinClass, mixedIn);
     }
 
     /**
-     * Convenience method
+     * Convenience method, simply delegates to {@link TransactionService#nextTransaction()}.
      */
     protected void nextTransaction() {
         transactionService.nextTransaction();
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java b/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java
index 1714099..e38d253 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/wrapper/WrapperFactory.java
@@ -121,6 +121,11 @@ public interface WrapperFactory {
 
         @Override
         public <T> T wm(final Class<T> mixinClass, final Object mixedIn) {
+            return wrapMixin(mixinClass, mixedIn);
+        }
+
+        @Override
+        public <T> T wrapMixin(final Class<T> mixinClass, final Object mixedIn) {
             return wrap(factoryService.m(mixinClass, mixedIn));
         }
 
@@ -179,12 +184,25 @@ public interface WrapperFactory {
     @Programmatic
     <T> T wrap(T domainObject);
 
+    /**
+     * Alias for {@link #wrap(Object)}.
+     */
     @Programmatic
     <T> T w(T domainObject);
 
+    /**
+     * Alias for {@link #wrapMixin(Class, Object)}
+     */
+    @Programmatic
     <T> T wm(Class<T> mixinClass, Object mixedIn);
 
     /**
+     * {@link #wrap(Object) wraps} a {@link FactoryService#mixin(Class, Object) mixin}.
+     */
+    @Programmatic
+    <T> T wrapMixin(Class<T> mixinClass, Object mixedIn);
+
+    /**
      * Convenience method for {@link #wrap(Object, ExecutionMode)} with {@link ExecutionMode#NO_EXECUTE},
      * to make this feature more discoverable.
      */
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract3.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract3.java
index e01c722..0696388 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract3.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract3.java
@@ -29,6 +29,7 @@ import org.slf4j.event.Level;
 
 import org.apache.isis.applib.AppManifest;
 import org.apache.isis.applib.Module;
+import org.apache.isis.applib.services.xactn.TransactionService;
 import org.apache.isis.core.runtime.headless.HeadlessTransactionSupport;
 import org.apache.isis.core.runtime.headless.HeadlessWithBootstrappingAbstract;
 import org.apache.isis.core.runtime.headless.IsisSystem;
@@ -116,54 +117,57 @@ public abstract class IntegrationTestAbstract3 extends HeadlessWithBootstrapping
     }
 
 
-    public interface Step {
-        void step();
-    }
     public interface StepT<T> {
-        T step();
-    }
-
-    protected void given(Step step) throws Exception {
-        step.step();
-        transactionService.flushTransaction();
+        T execute() throws Exception;
     }
 
-    protected void givenS(Step step) throws Exception {
-        step.step();
-        sessionManagementService.nextSession();
+    public interface StepV {
+        void execute() throws Exception;
     }
 
-    protected <T> T givenT(StepT<T> step) throws Exception {
-        final T stepReturn = step.step();
+    protected <T> T given(StepT<T> step) throws Exception {
+        final T stepReturn = step.execute();
         transactionService.flushTransaction();
         return stepReturn;
     }
 
-    protected void when(Step step) throws Exception {
-        step.step();
+    /**
+     * As {@link #given(StepT)}, but for an operation that returns <code>void</code>.
+     */
+    protected void givenV(StepV step) throws Exception {
+        step.execute();
         transactionService.flushTransaction();
     }
 
-    protected <T> T whenT(StepT<T> step) throws Exception {
-        final T stepReturn = step.step();
+    /**
+     * {@link StepT#execute() Execute}s the step, then {@link TransactionService#flushTransaction() flush}es the transaction.
+     */
+    protected <T> T when(StepT<T> step) throws Exception {
+        final T stepReturn = step.execute();
         transactionService.flushTransaction();
         return stepReturn;
     }
 
-    protected void whenS(Step step) throws Exception {
-        step.step();
+    /**
+     * As {@link #when(StepT)}, but for an operation that returns <code>void</code>.
+     */
+    protected void whenV(StepV step) throws Exception {
+        step.execute();
         transactionService.flushTransaction();
-        sessionManagementService.nextSession();
     }
 
-    protected void then(Step step) throws Exception {
-        step.step();
+    protected <T> T then(StepT<T> step) throws Exception {
+        final T stepReturn = step.execute();
+        transactionService.flushTransaction();
+        return stepReturn;
     }
 
-    protected <T> T thenT(StepT<T> step) throws Exception {
-        final T stepReturn = step.step();
+    /**
+     * As {@link #then(StepT)}, but for an operation that returns <code>void</code>.
+     */
+    protected void thenV(StepV step) throws Exception {
+        step.execute();
         transactionService.flushTransaction();
-        return stepReturn;
     }
 
 
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/HeadlessAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/HeadlessAbstract.java
index 0093320..c8770d1 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/HeadlessAbstract.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/headless/HeadlessAbstract.java
@@ -63,35 +63,47 @@ public abstract class HeadlessAbstract {
 
 
     /**
-     * For convenience of subclasses, remove some boilerplate
+     * Convenience method, simply delegates to {@link WrapperFactory#wrap(Object)}
      */
-    protected <T> T w(final T obj) {
-        return wrapperFactory.w(obj);
-    }
     protected <T> T wrap(final T obj) {
         return wrapperFactory.wrap(obj);
     }
-    protected <T> T wm(final T obj) {
-        return wrapperFactory.w(obj);
+
+    /**
+     * Convenience method, synonym of {@link #wrap(Object)}
+     */
+    protected <T> T w(final T obj) {
+        return wrap(obj);
     }
-    protected <T> T wm(final Class<T> mixinClass, final Object mixedIn) {
-        return wrapperFactory.wm(mixinClass, mixedIn);
+
+    /**
+     * Convenience method, simply delegates to {@link WrapperFactory#wrapMixin(Class, Object)}.
+     */
+    protected <T> T wrapMixin(final Class<T> mixinClass, final Object mixedIn) {
+        return wrapperFactory.wrapMixin(mixinClass, mixedIn);
     }
 
     /**
-     * For convenience of subclasses, remove some boilerplate
+     * Convenience method, synonym for {@link #wrapMixin(Class, Object)}.
      */
-    protected <T> T m(final Class<T> mixinClass, final Object mixedIn) {
-        return factoryService.m(mixinClass, mixedIn);
+    protected <T> T wm(final Class<T> mixinClass, final Object mixedIn) {
+        return wrapMixin(mixinClass, mixedIn);
     }
 
     /**
-     * For convenience of subclasses, remove some boilerplate
+     * Convenience method, simply delegates to {@link FactoryService#mixin(Class, Object)}.
      */
     protected <T> T mixin(final Class<T> mixinClass, final Object mixedIn) {
         return factoryService.mixin(mixinClass, mixedIn);
     }
 
+    /**
+     * Convenience method, synonym for {@link #mixin(Class, Object)}.
+     */
+    protected <T> T m(final Class<T> mixinClass, final Object mixedIn) {
+        return factoryService.m(mixinClass, mixedIn);
+    }
+
 
     /**
      * To use instead of {@link #getFixtureClock()}'s {@link FixtureClock#setDate(int, int, int)} ()}.
diff --git a/core/runtime/src/main/java/org/apache/isis/core/wrapper/WrapperFactoryDefault.java b/core/runtime/src/main/java/org/apache/isis/core/wrapper/WrapperFactoryDefault.java
index 4afc231..b56e470 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/wrapper/WrapperFactoryDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/wrapper/WrapperFactoryDefault.java
@@ -224,12 +224,14 @@ public class WrapperFactoryDefault implements WrapperFactory {
     // wrap and unwrap
     // /////////////////////////////////////////////////////////////
 
-    @Inject
-    FactoryService factoryService;
     public <T> T wm(final Class<T> mixinClass, final Object mixedIn) {
         return w(factoryService.m(mixinClass, mixedIn));
     }
 
+    public <T> T wrapMixin(final Class<T> mixinClass, final Object mixedIn) {
+        return w(factoryService.m(mixinClass, mixedIn));
+    }
+
     @Override
     public <T> T w(final T domainObject) {
         return wrap(domainObject, ExecutionMode.EXECUTE);
@@ -316,16 +318,16 @@ public class WrapperFactoryDefault implements WrapperFactory {
     }
 
 
-    @javax.inject.Inject
+    @Inject
     AuthenticationSessionProvider authenticationSessionProvider;
 
-    //    @javax.inject.Inject
-    //    SpecificationLoader specificationLoader;
-
-    @javax.inject.Inject
+    @Inject
     PersistenceSessionServiceInternal persistenceSessionServiceInternal;
 
-    @javax.inject.Inject
+    @Inject
     IsisSessionFactory isisSessionFactory;
 
+    @Inject
+    FactoryService factoryService;
+
 }