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 2017/10/16 20:34:49 UTC

[isis] 04/04: ISIS-1742: tinkering with IsisInjectModule and IsisComponentProviderUsingInstallers, just to separate out the responsibilities a little better.

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

danhaywood pushed a commit to branch dev/2.0.0/ISIS-1742-remove-deprecations
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 7ac769c51050ad4255733200cfee909f8e069bb9
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Oct 16 21:33:57 2017 +0100

    ISIS-1742: tinkering with IsisInjectModule and IsisComponentProviderUsingInstallers, just to separate out the responsibilities a little better.
---
 .../isis/core/runtime/runner/IsisInjectModule.java | 57 +++++++++++++++++++---
 .../IsisComponentProviderUsingInstallers.java      | 23 ++-------
 .../isis/core/webapp/IsisWebAppBootstrapper.java   |  7 ---
 3 files changed, 54 insertions(+), 33 deletions(-)

diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/runner/IsisInjectModule.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/runner/IsisInjectModule.java
index f317dc5..c07c33e 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/runner/IsisInjectModule.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/runner/IsisInjectModule.java
@@ -30,10 +30,13 @@ import org.apache.isis.applib.AppManifest;
 import org.apache.isis.applib.fixturescripts.FixtureScript;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.config.IsisConfigurationDefault;
+import org.apache.isis.core.commons.factory.InstanceUtil;
 import org.apache.isis.core.metamodel.deployment.DeploymentCategory;
 import org.apache.isis.core.metamodel.services.ServicesInjector;
-import org.apache.isis.core.runtime.system.session.IsisSessionFactoryBuilder;
+import org.apache.isis.core.runtime.system.SystemConstants;
 import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
+import org.apache.isis.core.runtime.system.session.IsisSessionFactoryBuilder;
+import org.apache.isis.core.runtime.systemusinginstallers.IsisComponentProvider;
 import org.apache.isis.core.runtime.systemusinginstallers.IsisComponentProviderUsingInstallers;
 
 public class IsisInjectModule extends AbstractModule {
@@ -83,18 +86,29 @@ public class IsisInjectModule extends AbstractModule {
 
     /**
      * Allows the {@link AppManifest} to be programmatically bound in.
+     *
+     * <p>
+     *     For example, this can be done in override of
+     *     <code>IsisWicketApplication#newIsisWicketModule</code>.
+     * </p>
      */
     @Override
     protected void configure() {
         bind(AppManifest.class).toInstance(APP_MANIFEST_NOOP);
     }
 
+    /**
+     * Simply as provided in the constructor.
+     */
     @Provides
     @Singleton
     protected IsisConfiguration provideConfiguration() {
         return isisConfiguration;
     }
 
+    /**
+     * Simply as provided in the constructor.
+     */
     @Provides
     @Singleton
     protected DeploymentCategory provideDeploymentCategory() {
@@ -104,14 +118,16 @@ public class IsisInjectModule extends AbstractModule {
     @Provides
     @com.google.inject.Inject
     @Singleton
-    protected IsisSessionFactory provideIsisSessionFactory(final AppManifest appManifestIfAny) {
+    protected IsisSessionFactory provideIsisSessionFactory(
+                    final AppManifest appManifestIfExplicitlyBound) {
 
-        final AppManifest appManifest = appManifestIfAny != APP_MANIFEST_NOOP ? appManifestIfAny : null;
+        final AppManifest appManifestToUse = determineAppManifest(appManifestIfExplicitlyBound);
 
-        final IsisComponentProviderUsingInstallers componentProvider =
-                new IsisComponentProviderUsingInstallers(appManifest, isisConfiguration);
+        final IsisComponentProvider componentProvider =
+                new IsisComponentProviderUsingInstallers(appManifestToUse, isisConfiguration);
 
-        final IsisSessionFactoryBuilder builder = new IsisSessionFactoryBuilder(componentProvider, deploymentCategory);
+        final IsisSessionFactoryBuilder builder =
+                new IsisSessionFactoryBuilder(componentProvider, deploymentCategory);
 
         // as a side-effect, if the metamodel turns out to be invalid, then
         // this will push the MetaModelInvalidException into IsisContext.
@@ -125,4 +141,33 @@ public class IsisInjectModule extends AbstractModule {
         return isisSessionFactory.getServicesInjector();
     }
 
+
+    private AppManifest determineAppManifest(final AppManifest appManifestIfExplicitlyBound) {
+        final AppManifest appManifest =
+                appManifestIfExplicitlyBound != APP_MANIFEST_NOOP
+                        ? appManifestIfExplicitlyBound
+                        : null;
+
+        return appManifestFrom(appManifest, isisConfiguration);
+    }
+
+
+    /**
+     * If an {@link AppManifest} was explicitly provided (eg from the Guice <tt>IsisWicketModule</tt> when running
+     * unde the Wicket viewer) then use that; otherwise read the <tt>isis.properties</tt> config file and look
+     * for an <tt>isis.appManifest</tt> entry instead.
+     */
+    private static AppManifest appManifestFrom(
+            final AppManifest appManifestFromConstructor,
+            final IsisConfiguration configuration) {
+        if(appManifestFromConstructor != null) {
+            return appManifestFromConstructor;
+        }
+        final String appManifestFromConfiguration = configuration.getString(SystemConstants.APP_MANIFEST_KEY);
+        return appManifestFromConfiguration != null
+                ? InstanceUtil.createInstance(appManifestFromConfiguration, AppManifest.class)
+                : null;
+    }
+
+
 }
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java
index 66edd6a..4568434 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderUsingInstallers.java
@@ -49,14 +49,14 @@ public class IsisComponentProviderUsingInstallers extends IsisComponentProvider
     //region > constructors
 
     public IsisComponentProviderUsingInstallers(
-            final AppManifest appManifestIfAny,
+            final AppManifest appManifest,
             final IsisConfiguration configuration) {
-        this(appManifestFrom(appManifestIfAny, configuration),
+        this(appManifest,
                 (IsisConfigurationDefault) configuration, // REVIEW: HACKY
                 new InstallerLookup(configuration));
     }
 
-    private IsisComponentProviderUsingInstallers(
+    public IsisComponentProviderUsingInstallers(
             final AppManifest appManifest,
             final IsisConfigurationDefault configuration,
             final InstallerLookup installerLookup) {
@@ -77,23 +77,6 @@ public class IsisComponentProviderUsingInstallers extends IsisComponentProvider
 
     //region > constructor helpers (factories)
 
-    /**
-     * If an {@link AppManifest} was explicitly provided (eg from the Guice <tt>IsisWicketModule</tt> when running
-     * unde the Wicket viewer) then use that; otherwise read the <tt>isis.properties</tt> config file and look
-     * for an <tt>isis.appManifest</tt> entry instead.
-     */
-    private static AppManifest appManifestFrom(
-            final AppManifest appManifestFromConstructor,
-            final IsisConfiguration configuration) {
-        if(appManifestFromConstructor != null) {
-            return appManifestFromConstructor;
-        }
-        final String appManifestFromConfiguration = configuration.getString(SystemConstants.APP_MANIFEST_KEY);
-        return appManifestFromConfiguration != null
-                ? InstanceUtil.createInstance(appManifestFromConfiguration, AppManifest.class)
-                : null;
-    }
-
     private static AuthenticationManager lookupAuthenticationManager(
             final AppManifest appManifest, final InstallerLookup installerLookup,
             final IsisConfigurationDefault configuration) {
diff --git a/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppBootstrapper.java b/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppBootstrapper.java
index 9123aea..6696ebe 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppBootstrapper.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/webapp/IsisWebAppBootstrapper.java
@@ -152,13 +152,6 @@ public class IsisWebAppBootstrapper implements ServletContextListener {
 
     }
 
-    private Injector createGuiceInjector(
-            final IsisConfigurationDefault isisConfiguration,
-            final DeploymentCategory deploymentCategory) {
-        final IsisInjectModule isisModule = new IsisInjectModule(deploymentCategory, isisConfiguration);
-        return Guice.createInjector(isisModule);
-    }
-
     /**
      * Checks {@link IsisConfigurationBuilder configuration} for
      * {@value SystemConstants#DEPLOYMENT_TYPE_KEY}, (that is, from the command

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.