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/05/31 06:35:19 UTC

[1/3] isis git commit: ISIS-1335: tiny fixes for docs

Repository: isis
Updated Branches:
  refs/heads/master 29fb00b97 -> a58762198


ISIS-1335: tiny fixes for docs


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

Branch: refs/heads/master
Commit: d0e81bb3dd9088e4d125bbab9b611d584ee8dd49
Parents: 29fb00b
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue May 31 06:22:00 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue May 31 06:22:00 2016 +0100

----------------------------------------------------------------------
 .../src/main/asciidoc/_migration-notes_1.12.0-to-1.13.0.adoc | 8 ++++----
 .../src/main/asciidoc/guides/_rgcfg_configuring-core.adoc    | 8 +++++---
 2 files changed, 9 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/d0e81bb3/adocs/documentation/src/main/asciidoc/_migration-notes_1.12.0-to-1.13.0.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/_migration-notes_1.12.0-to-1.13.0.adoc b/adocs/documentation/src/main/asciidoc/_migration-notes_1.12.0-to-1.13.0.adoc
index b322c16..2864fa4 100644
--- a/adocs/documentation/src/main/asciidoc/_migration-notes_1.12.0-to-1.13.0.adoc
+++ b/adocs/documentation/src/main/asciidoc/_migration-notes_1.12.0-to-1.13.0.adoc
@@ -1,4 +1,4 @@
-[[_migration-notes_1.11.0-to-1.12.0]]
+[[_migration-notes_1.12.0-to-1.13.0]]
 = From v1.12.0 to 1.13.0
 :Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 :_basedir: ../
@@ -23,7 +23,7 @@ Several new configuration settings influence application startup times:
 
 * `isis.services.applicationFeatures.init` +
 +
-This setting can be used to control whether the
+This xref:rgcfg.adoc#_rgcfg_configuring-core_services[setting] can be used to control whether the
 xref:rgsvc.adoc#_rgsvc_api_ApplicationFeatureRepository[`ApplicationFeatureRepository`] domain service lazily or
 eagerly initializes itself based on the framework's internal metamodel. +
 +
@@ -33,7 +33,7 @@ lazily.  The previous behaviour (of eager initialization) can be re-enabled by s
 
 * `isis.services.injector.injectPrefix` and `isis.services.injector.setPrefix` +
 +
-These settings can be used to control the styles of injection of domain services that the framework supports. +
+These xref:rgcfg.adoc#_rgcfg_configuring-core_services[settings] can be used to control the styles of injection of domain services that the framework supports. +
 +
 Prior to `1.13.0` the framework supported the injection of fields using xref:rgant.adoc#_rgant-Inject[`@Inject`], and
 also injection to `set...()` setter methods and also `inject...()` methods.  In `1.13.0` the injection through `@Inject`
@@ -42,7 +42,7 @@ For faster start-up times still, consider disabling injection through `set...()`
 
 * `isis.reflector.facets.ignoreDeprecated` +
 +
-This setting indicates whether to continue to honour or to simply ignore any deprecated annotations and other
+This xref:rgcfg.adoc#_rgcfg_configuring-core_services[setting] indicates whether to continue to honour or to simply ignore any deprecated annotations and other
 semantics that make up the programming model. +
 +
 Be aware that enabling this setting could substantially alter the semantics of your application.  To be safe, we

http://git-wip-us.apache.org/repos/asf/isis/blob/d0e81bb3/adocs/documentation/src/main/asciidoc/guides/_rgcfg_configuring-core.adoc
----------------------------------------------------------------------
diff --git a/adocs/documentation/src/main/asciidoc/guides/_rgcfg_configuring-core.adoc b/adocs/documentation/src/main/asciidoc/guides/_rgcfg_configuring-core.adoc
index a276225..e65b346 100644
--- a/adocs/documentation/src/main/asciidoc/guides/_rgcfg_configuring-core.adoc
+++ b/adocs/documentation/src/main/asciidoc/guides/_rgcfg_configuring-core.adoc
@@ -194,9 +194,11 @@ This property is IGNORED if the xref:rgcfg.adoc#_rgcfg_configuring-components[`i
 `applicationFeatures.init`
 | `lazy`, `eager` +
 (`lazy`)
-|(`1.13.0-SNAPSHOT`) Whether the application features repository (which surfaces the framework's metamodel) should be initialized lazily or eagerly.  +
-+
-Lazily initialization can speed up bootstrapping, useful while developing and running tests.  The default prior to `1.13.0` was eager initialization.
+|(`1.13.0-SNAPSHOT`) Whether the application features repository (which surfaces the framework's metamodel) should be
+initialized lazily or eagerly.  +
+
+Lazy initialization can speed up bootstrapping, useful while developing and running tests.  The default prior to
+`1.13.0` was eager initialization.
 
 
 |`isis.services.` +


[2/3] isis git commit: ISIS-1419: simplified Session management.

Posted by da...@apache.org.
ISIS-1419: simplified Session management.

The exception resulting, I believe, from lack of symmetry in the integ tests: they set up a single session for all tests, but in the shutdown (called by a Runtime hook), create a different session again to perform the @PreDestroy stuff.  In this commit, I've decided to get rid of this shutdown stuff, basically orphaning that initial session (it is never closed down, but then the JVM quits anyway, and this is for an inmemory databases so no real harm).

A subsequent commit will take look to close the session in the teardown of each test.

In detail:
- in IsisContext, change the Map<Thread,IsisSession> into a simple ThreadLocal.  remove the logic to save every IsisSession in this map, and remove the closeAllSessionsInstance().  In IsisSession, remove the id() and sessionOpenTime properties (now unused), and remove closeAll() - was now just the same as close();
- in PersistenceSession, split out calling of __isis_startRequest/__isis_postConstruct and then __isis_preDestroy/__isis_endRequest into two loops, just so easier to move around if need be.  (Currently, calling one after the other, so no functional change here).

Also:
- no longer allow the ProgrammingModel to be overridden (in IsisComponentProviderDefault, IsisComponentProviderDefault2, IsisSystemForTest, IsisMojoAbstract)
- reformatted IsisSystemForTest (comments), also WebRequestCycleForIsis
- ServiceInitializer, introduced constructor for state (rather than pass into validate(...)); updated IsisSystem correspondingly
- removed unused method in DeploymentType


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

Branch: refs/heads/master
Commit: e38eaf7b90841314ae37c5cc4610d838f513492b
Parents: d0e81bb
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue May 31 07:02:00 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue May 31 07:02:00 2016 +0100

----------------------------------------------------------------------
 .../IsisComponentProviderDefault.java           |   5 +-
 .../integtestsupport/IsisSystemForTest.java     | 193 +++++++--------
 .../isis/tool/mavenplugin/IsisMojoAbstract.java |   2 +-
 .../specloader/ServiceInitializer.java          |  36 ++-
 .../specloader/ServiceInitializerTest.java      |  49 +++-
 .../core/runtime/system/DeploymentType.java     |   4 -
 .../isis/core/runtime/system/IsisSystem.java    |  35 +--
 .../runtime/system/context/IsisContext.java     | 234 +++++--------------
 .../system/persistence/PersistenceSession.java  |  49 ++--
 .../runtime/system/session/IsisSession.java     |  59 +----
 .../IsisComponentProviderDefault2.java          |   7 +-
 .../wicket/WebRequestCycleForIsis.java          |  13 +-
 12 files changed, 272 insertions(+), 414 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisComponentProviderDefault.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisComponentProviderDefault.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisComponentProviderDefault.java
index 1720160..c53005e 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisComponentProviderDefault.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisComponentProviderDefault.java
@@ -24,7 +24,6 @@ import java.util.List;
 import org.apache.isis.applib.AppManifest;
 import org.apache.isis.applib.fixtures.InstallableFixture;
 import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
 import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidator;
 import org.apache.isis.core.runtime.system.DeploymentType;
 import org.apache.isis.core.runtime.systemusinginstallers.IsisComponentProviderDefault2;
@@ -37,9 +36,9 @@ public class IsisComponentProviderDefault extends IsisComponentProviderDefault2
             final List<Object> servicesOverride,
             final List<InstallableFixture> fixturesOverride,
             final IsisConfiguration configurationOverride,
-            final ProgrammingModel programmingModelOverride,
             final MetaModelValidator metaModelValidatorOverride) {
-        super(deploymentType, appManifestIfAny, servicesOverride, fixturesOverride, configurationOverride, programmingModelOverride, metaModelValidatorOverride);
+        super(deploymentType, appManifestIfAny, servicesOverride, fixturesOverride, configurationOverride,
+                metaModelValidatorOverride);
 
     }
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
index 4c81c29..1abdc31 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemForTest.java
@@ -75,6 +75,8 @@ import static org.junit.Assert.fail;
  */
 public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServiceProvider {
 
+    //region > Listener, ListenerAdapter
+
     public interface Listener {
 
         void init(IsisConfiguration configuration) throws Exception;
@@ -128,7 +130,9 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
 
     }
 
-    // //////////////////////////////////////
+    //endregion
+
+    //region > getElseNull, get, set
 
     private static ThreadLocal<IsisSystemForTest> ISFT = new ThreadLocal<IsisSystemForTest>();
 
@@ -148,38 +152,15 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
     public static void set(IsisSystemForTest isft) {
         ISFT.set(isft);
     }
+    //endregion
 
-    // //////////////////////////////////////
-
-    private org.apache.log4j.Level level = org.apache.log4j.Level.INFO;
-
-
-    // these fields 'xxxForComponentProvider' are used to initialize the IsisComponentProvider, but shouldn't be used thereafter.
-    private final AppManifest appManifestIfAny;
-    private final IsisConfiguration configurationOverride;
-    private final List<Object> servicesIfAny;
-    private final List<InstallableFixture> fixturesIfAny;
-    private final MetaModelValidator metaModelValidatorOverride;
-    private final ProgrammingModel programmingModelOverride;
-
-    // populated at #setupSystem
-    private IsisComponentProvider componentProvider;
-
-    private IsisSystem isisSystem;
-
-    private final AuthenticationRequest authenticationRequestIfAny;
-    private AuthenticationSession authenticationSession;
-
-    private List <Listener> listeners;
+    //region > Builder
 
-    ////////////////////////////////////////////////////////////
-    // constructor
-    ////////////////////////////////////////////////////////////
 
     public static class Builder {
 
         private AuthenticationRequest authenticationRequest = new AuthenticationRequestNameOnly("tester");
-        
+
         private IsisConfigurationDefault configuration = new IsisConfigurationDefault();
 
         private AppManifest appManifestIfAny;
@@ -189,7 +170,7 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
 
         private final List<Object> services = Lists.newArrayList();
         private final List<InstallableFixture> fixtures = Lists.newArrayList();
-        
+
         private final List <Listener> listeners = Lists.newArrayList();
 
         private org.apache.log4j.Level level;
@@ -212,8 +193,11 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
             return this;
         }
 
+        /**
+         * @deprecated - this is now a no-op because there is now only a single implementation of {@link ProgrammingModel}, so this is redundant.
+         */
+        @Deprecated
         public Builder with(ProgrammingModel programmingModel) {
-            this.programmingModelOverride = programmingModel;
             return this;
         }
 
@@ -270,7 +254,7 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
             this.fixtures.addAll(Arrays.asList(fixtures));
             return this;
         }
-        
+
         public Builder withLoggingAt(org.apache.log4j.Level level) {
             this.level = level;
             return this;
@@ -281,7 +265,7 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
                     new IsisSystemForTest(
                             appManifestIfAny,
                             configuration,
-                            services, fixtures, programmingModelOverride,
+                            services, fixtures,
                             metaModelValidatorOverride,
                             authenticationRequest,
                             listeners);
@@ -328,12 +312,27 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         return new Builder();
     }
 
+    //endregion
+
+    //region > constructor, fields
+
+    // these fields 'xxxForComponentProvider' are used to initialize the IsisComponentProvider, but shouldn't be used thereafter.
+    private final AppManifest appManifestIfAny;
+    private final IsisConfiguration configurationOverride;
+    private final List<Object> servicesIfAny;
+    private final List<InstallableFixture> fixturesIfAny;
+    private final MetaModelValidator metaModelValidatorOverride;
+
+
+    private final AuthenticationRequest authenticationRequestIfAny;
+    private AuthenticationSession authenticationSession;
+
+
     private IsisSystemForTest(
             final AppManifest appManifestIfAny,
             final IsisConfiguration configurationOverride,
             final List<Object> servicesIfAny,
             final List<InstallableFixture> fixturesIfAny,
-            final ProgrammingModel programmingModelOverride,
             final MetaModelValidator metaModelValidatorOverride,
             final AuthenticationRequest authenticationRequestIfAny,
             final List<Listener> listeners) {
@@ -341,15 +340,15 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         this.configurationOverride = configurationOverride;
         this.servicesIfAny = servicesIfAny;
         this.fixturesIfAny = fixturesIfAny;
-        this.programmingModelOverride = programmingModelOverride;
         this.metaModelValidatorOverride = metaModelValidatorOverride;
         this.authenticationRequestIfAny = authenticationRequestIfAny;
         this.listeners = listeners;
     }
 
-    ////////////////////////////////////////////////////////////
-    // level
-    ////////////////////////////////////////////////////////////
+    //endregion
+
+    //region > level
+    private org.apache.log4j.Level level = org.apache.log4j.Level.INFO;
 
     /**
      * The level to use for the root logger if fallback (ie a <tt>logging.properties</tt> file cannot be found).
@@ -362,10 +361,12 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         this.level = level;
     }
 
-    ////////////////////////////////////////////////////////////
-    // setup, teardown
-    ////////////////////////////////////////////////////////////
-    
+    //endregion
+
+    //region > setup (also componentProvider)
+
+    // populated at #setupSystem
+    private IsisComponentProvider componentProvider;
 
     /**
      * Intended to be called from a test's {@link Before} method.
@@ -402,7 +403,6 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
                     servicesIfAny,
                     fixturesIfAny,
                     configurationOverride,
-                    programmingModelOverride,
                     metaModelValidatorOverride
             );
 
@@ -432,7 +432,6 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
             }
         }
 
-
         final AuthenticationManager authenticationManager = IsisContext.getAuthenticationManager();
         authenticationSession = authenticationManager.authenticate(authenticationRequestIfAny);
 
@@ -449,14 +448,6 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         fixturesInstaller.installFixtures();
     }
 
-    private enum FireListeners {
-        FIRE,
-        DONT_FIRE;
-        public boolean shouldFire() {
-            return this == FIRE;
-        }
-    }
-
     public DomainObjectContainer getContainer() {
         for (Object service : IsisContext.getSessionFactory().getServices()) {
             if(service instanceof DomainObjectContainer) {
@@ -466,14 +457,37 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         throw new IllegalStateException("Could not locate DomainObjectContainer");
     }
 
+    //endregion
+
+    //region > isisSystem (populated during setup)
+    private IsisSystem isisSystem;
+
+    /**
+     * The {@link IsisSystem} created during {@link #setUpSystem()}.
+     */
+    public IsisSystem getIsisSystem() {
+        return isisSystem;
+    }
+
+    /**
+     * The {@link AuthenticationSession} created during {@link #setUpSystem()}.
+     */
+    public AuthenticationSession getAuthenticationSession() {
+        return authenticationSession;
+    }
+
+    //endregion
+
+    //region > teardown
+
     /**
      * Intended to be called from a test's {@link After} method.
      */
     public void tearDownSystem() throws Exception {
-        tearDownSystem(FireListeners.FIRE);
+        closeSession(FireListeners.FIRE);
     }
 
-    private void tearDownSystem(final FireListeners fireListeners) throws Exception {
+    private void closeSession(final FireListeners fireListeners) throws Exception {
         if(fireListeners.shouldFire()) {
             firePreTeardownSystem();
         }
@@ -498,6 +512,9 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         firePostBounceSystem();
     }
 
+    //endregion
+
+    //region > openSession, closeSession
     public void openSession() throws Exception {
         openSession(authenticationSession);
 
@@ -511,9 +528,20 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         IsisContext.closeSession();
     }
 
-    ////////////////////////////////////////////////////////////
-    // listeners
-    ////////////////////////////////////////////////////////////
+    //endregion
+
+    //region > listeners
+
+    private List <Listener> listeners;
+
+    private enum FireListeners {
+        FIRE,
+        DONT_FIRE;
+        public boolean shouldFire() {
+            return this == FIRE;
+        }
+    }
+
 
     private void fireInitAndPreSetupSystem(boolean firstTime) throws Exception {
         if(firstTime) {
@@ -555,31 +583,9 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
             listener.postBounceSystem();
         }
     }
+    //endregion
 
-    
-    ////////////////////////////////////////////////////////////
-    // properties
-    ////////////////////////////////////////////////////////////
-
-    /**
-     * The {@link IsisSystem} created during {@link #setUpSystem()}.
-     */
-    public IsisSystem getIsisSystem() {
-        return isisSystem;
-    }
-
-    /**
-     * The {@link AuthenticationSession} created during {@link #setUpSystem()}.
-     */
-    public AuthenticationSession getAuthenticationSession() {
-        return authenticationSession;
-    }
-
-
-
-    ////////////////////////////////////////////////////////////
-    // Convenience for tests
-    ////////////////////////////////////////////////////////////
+    //region > Convenience for tests
 
     public ObjectSpecification loadSpecification(Class<?> cls) {
         return getIsisSystem().getSessionFactory().getSpecificationLoader().loadSpecification(cls);
@@ -641,9 +647,9 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         }
     }
 
-    ////////////////////////////////////////////////////////////
-    // JUnit @Rule integration
-    ////////////////////////////////////////////////////////////
+    //endregion
+
+    //region > JUnit @Rule integration
 
     @Override
     public Statement apply(final Statement base, final Description description) {
@@ -666,8 +672,10 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         };
     }
 
+    //endregion
+
+    //region > beginTran, endTran, commitTran, abortTran
 
-    
     public void beginTran() {
         final IsisTransactionManager transactionManager = getTransactionManager();
         final IsisTransaction transaction = transactionManager.getTransaction();
@@ -791,6 +799,9 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         }
     }
 
+    //endregion
+
+    //region > getService, replaceService
 
     /* (non-Javadoc)
      * @see org.apache.isis.core.integtestsupport.ServiceProvider#getService(java.lang.Class)
@@ -815,11 +826,9 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         servicesInjector.replaceService(originalService, replacementService);
     }
 
+    //endregion
 
-    ////////////////////////////////////////////////////////////
-    // Fixture management 
-    // (for each test, rather than at bootstrap)
-    ////////////////////////////////////////////////////////////
+    //region > Fixture management (for each test, rather than at bootstrap)
 
     /**
      * @deprecated - use {@link org.apache.isis.applib.fixturescripts.FixtureScripts} domain service instead.
@@ -847,11 +856,10 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         }
     }
 
+    //endregion
+
+    //region > Dependencies
 
-    ////////////////////////////////////////////////////////////
-    // Dependencies
-    ////////////////////////////////////////////////////////////
-    
     protected IsisTransactionManager getTransactionManager() {
         return getPersistenceSession().getTransactionManager();
     }
@@ -878,5 +886,6 @@ public class IsisSystemForTest implements org.junit.rules.TestRule, DomainServic
         // no-op
     }
 
-    
+    //endregion
+
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/maven-plugin/src/main/java/org/apache/isis/tool/mavenplugin/IsisMojoAbstract.java
----------------------------------------------------------------------
diff --git a/core/maven-plugin/src/main/java/org/apache/isis/tool/mavenplugin/IsisMojoAbstract.java b/core/maven-plugin/src/main/java/org/apache/isis/tool/mavenplugin/IsisMojoAbstract.java
index a9a3cfd..4ba301f 100644
--- a/core/maven-plugin/src/main/java/org/apache/isis/tool/mavenplugin/IsisMojoAbstract.java
+++ b/core/maven-plugin/src/main/java/org/apache/isis/tool/mavenplugin/IsisMojoAbstract.java
@@ -59,7 +59,7 @@ public abstract class IsisMojoAbstract extends AbstractMojo {
 
         final AppManifest manifest = InstanceUtil.createInstance(this.appManifest, AppManifest.class);
         final IsisComponentProviderDefault2 componentProvider = new IsisComponentProviderDefault2(
-                DeploymentType.UNIT_TESTING, manifest, null, null, null, null, null);
+                DeploymentType.UNIT_TESTING, manifest, null, null, null, null);
 
         final IsisSystem isisSystem = new IsisSystem(componentProvider);
         try {

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ServiceInitializer.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ServiceInitializer.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ServiceInitializer.java
index f3ab09e..e528806 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ServiceInitializer.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/specloader/ServiceInitializer.java
@@ -31,16 +31,23 @@ public class ServiceInitializer {
 
     private final static Logger LOG = LoggerFactory.getLogger(ServiceInitializer.class);
 
-    private Map<String, String> props;
+    private final List<Object> services;
 
-    private Map<Object, Method> postConstructMethodsByService = Maps.newLinkedHashMap(); 
-    private Map<Object, Method> preDestroyMethodsByService = Maps.newLinkedHashMap(); 
+    private final Map<String, String> props;
 
-    // //////////////////////////////////////
+    private Map<Object, Method> postConstructMethodsByService = Maps.newLinkedHashMap(); 
+    private Map<Object, Method> preDestroyMethodsByService = Maps.newLinkedHashMap();
 
-    public void validate(final IsisConfiguration configuration, final List<Object> services) {
-        
+    public ServiceInitializer(
+            final IsisConfiguration configuration,
+            final List<Object> services) {
         this.props = configuration.asMap();
+        this.services = services;
+    }
+
+    //region > validate
+
+    public void validate() {
         
         for (final Object service : services) {
             LOG.debug("checking for @PostConstruct and @PostDestroy methods on " + service.getClass().getName());
@@ -96,11 +103,14 @@ public class ServiceInitializer {
         }
 
     }
+    //endregion
 
-    // //////////////////////////////////////
+    //region > postConstruct
 
     public void postConstruct() {
-        LOG.info("calling @PostConstruct on all domain services");
+        if(LOG.isInfoEnabled()) {
+            LOG.info("calling @PostConstruct on all domain services");
+        }
 
         for (final Map.Entry<Object, Method> entry : postConstructMethodsByService.entrySet()) {
             final Object service = entry.getKey();
@@ -122,8 +132,14 @@ public class ServiceInitializer {
         }
     }
 
+    //endregion
+
+    //region > preDestroy
+
     public void preDestroy() {
-        LOG.info("calling @PreDestroy on all domain services");
+        if(LOG.isInfoEnabled()) {
+            LOG.info("calling @PreDestroy on all domain services");
+        }
         for (final Map.Entry<Object, Method> entry : preDestroyMethodsByService.entrySet()) {
             final Object service = entry.getKey();
             final Method method = entry.getValue();
@@ -141,4 +157,6 @@ public class ServiceInitializer {
         }
     }
 
+    //endregion
+
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ServiceInitializerTest.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ServiceInitializerTest.java b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ServiceInitializerTest.java
index 81c83aa..a9a0b72 100644
--- a/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ServiceInitializerTest.java
+++ b/core/metamodel/src/test/java/org/apache/isis/core/metamodel/specloader/ServiceInitializerTest.java
@@ -18,9 +18,6 @@
  */
 package org.apache.isis.core.metamodel.specloader;
 
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-
 import java.util.List;
 import java.util.Map;
 
@@ -43,6 +40,10 @@ import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
 import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
 
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
 public class ServiceInitializerTest {
 
     @Rule
@@ -60,7 +61,6 @@ public class ServiceInitializerTest {
     
     @Before
     public void setUp() throws Exception {
-        serviceInitializer = new ServiceInitializer();
         props = Maps.<String,String>newHashMap();
         context.checking(new Expectations() {
             {
@@ -102,8 +102,14 @@ public class ServiceInitializerTest {
     public void postConstruct() {
         final DomainServiceWithPostConstruct d1 = new DomainServiceWithPostConstruct();
         final DomainServiceWithPostConstructWithProperties d2 = new DomainServiceWithPostConstructWithProperties();
-        serviceInitializer.validate(configuration, listOf(d1, d2));
+
+        serviceInitializer = new ServiceInitializer(configuration, listOf(d1, d2));
+        serviceInitializer.validate();
+
+        // when
         serviceInitializer.postConstruct();
+
+        // then
         assertThat(d1.called, is(true));
         assertThat(d2.called, is(true));
         assertThat(d2.properties, is(props));
@@ -122,8 +128,14 @@ public class ServiceInitializerTest {
     public void preDestroy() {
         final DomainServiceWithPreDestroy d1 = new DomainServiceWithPreDestroy();
         final DomainServiceWithPreDestroy d2 = new DomainServiceWithPreDestroy();
-        serviceInitializer.validate(configuration, listOf(d1, d2));
+
+        serviceInitializer = new ServiceInitializer(configuration, listOf(d1, d2));
+        serviceInitializer.validate();
+
+        // when
         serviceInitializer.preDestroy();
+
+        // then
         assertThat(d1.called, is(true));
         assertThat(d2.called, is(true));
     }
@@ -146,7 +158,10 @@ public class ServiceInitializerTest {
         expectedException.expectMessage(
                 containsString(
                 "Found more than one @PostConstruct method; service is: org.apache.isis.core.metamodel.specloader.ServiceInitializerTest$DomainServiceWithMultiplePostConstruct, found"));
-        serviceInitializer.validate(configuration, listOf(d1));
+        serviceInitializer = new ServiceInitializer(configuration, listOf(d1));
+
+        // when
+        serviceInitializer.validate();
     }
 
     public static class DomainServiceWithMultiplePreDestroy {
@@ -167,7 +182,10 @@ public class ServiceInitializerTest {
         expectedException.expectMessage(
                 containsString(
                 "Found more than one @PreDestroy method; service is: org.apache.isis.core.metamodel.specloader.ServiceInitializerTest$DomainServiceWithMultiplePreDestroy, found"));
-        serviceInitializer.validate(configuration, listOf(d1));
+        serviceInitializer = new ServiceInitializer(configuration, listOf(d1));
+
+        // when
+        serviceInitializer.validate();
     }
 
     public static class DomainServiceWithPostConstructOneArgWrongType {
@@ -183,7 +201,10 @@ public class ServiceInitializerTest {
         final DomainServiceWithPostConstructOneArgWrongType d1 = new DomainServiceWithPostConstructOneArgWrongType();
         expectedException.expectMessage(
                 "@PostConstruct method must be no-arg or 1-arg accepting java.util.Map; method is: org.apache.isis.core.metamodel.specloader.ServiceInitializerTest$DomainServiceWithPostConstructOneArgWrongType#y");
-        serviceInitializer.validate(configuration, listOf(d1));
+        serviceInitializer = new ServiceInitializer(configuration, listOf(d1));
+
+        // when
+        serviceInitializer.validate();
     }
 
     public static class DomainServiceWithPostConstructTwoArgs {
@@ -199,7 +220,10 @@ public class ServiceInitializerTest {
         final DomainServiceWithPostConstructTwoArgs d1 = new DomainServiceWithPostConstructTwoArgs();
         expectedException.expectMessage(
                 "@PostConstruct method must be no-arg or 1-arg accepting java.util.Map; method is: org.apache.isis.core.metamodel.specloader.ServiceInitializerTest$DomainServiceWithPostConstructTwoArgs#y");
-        serviceInitializer.validate(configuration, listOf(d1));
+        serviceInitializer = new ServiceInitializer(configuration, listOf(d1));
+
+        // when
+        serviceInitializer.validate();
     }
 
     public static class DomainServiceWithPreDestroyOneArgs {
@@ -216,7 +240,10 @@ public class ServiceInitializerTest {
         final DomainServiceWithPreDestroyOneArgs d1 = new DomainServiceWithPreDestroyOneArgs();
         expectedException.expectMessage(
                 "@PreDestroy method must be no-arg; method is: org.apache.isis.core.metamodel.specloader.ServiceInitializerTest$DomainServiceWithPreDestroyOneArgs#y");
-        serviceInitializer.validate(configuration, listOf(d1));
+        serviceInitializer = new ServiceInitializer(configuration, listOf(d1));
+
+        // when
+        serviceInitializer.validate();
     }
 
 

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DeploymentType.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DeploymentType.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DeploymentType.java
index 253ee14..20e011b 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DeploymentType.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DeploymentType.java
@@ -72,10 +72,6 @@ public class DeploymentType {
         IsisContext.createInstance(sessionFactory);
     }
 
-    public boolean shouldMonitor() {
-        return (this == SERVER) && isProduction();
-    }
-
     public DeploymentCategory getDeploymentCategory() {
         return deploymentCategory;
     }

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystem.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystem.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystem.java
index 2cf0654..a19ed6c 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystem.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystem.java
@@ -208,7 +208,12 @@ public class IsisSystem implements ApplicationScopedComponent {
                 persistenceSessionFactory.init();
 
                 // do postConstruct.  We store the initializer to do preDestroy on shutdown
-                this.serviceInitializer = initializeServices();
+
+                // validate
+                this.serviceInitializer = new ServiceInitializer(getConfiguration(), sessionFactory.getServices());
+                serviceInitializer.validate();
+
+                postConstructInSession(this.serviceInitializer);
 
                 installFixturesIfRequired();
 
@@ -234,28 +239,16 @@ public class IsisSystem implements ApplicationScopedComponent {
         return ListExtensions.filtered(Arrays.asList(possibleRefiners), MetaModelRefiner.class);
     }
 
-    /**
-     * @see #shutdownServices(ServiceInitializer)
-     */
-    private ServiceInitializer initializeServices() {
-
-        final List<Object> services = sessionFactory.getServices();
-
-        // validate
-        final ServiceInitializer serviceInitializer = new ServiceInitializer();
-        serviceInitializer.validate(getConfiguration(), services);
-
-        // call @PostConstruct (in a session)
+    private void postConstructInSession(final ServiceInitializer serviceInitializer) {
         IsisContext.openSession(new InitialisationSession());
         try {
             getTransactionManager().startTransaction();
             try {
                 serviceInitializer.postConstruct();
-
-                return serviceInitializer;
+                return;
             } catch(RuntimeException ex) {
                 getTransactionManager().getTransaction().setAbortCause(new IsisTransactionManagerException(ex));
-                return serviceInitializer;
+                return;
             } finally {
                 // will commit or abort
                 getTransactionManager().endTransaction();
@@ -339,22 +332,18 @@ public class IsisSystem implements ApplicationScopedComponent {
     public void shutdown() {
         LOG.info("shutting down system");
 
-        shutdownServices(this.serviceInitializer);
+        preDestroyInSession(this.serviceInitializer);
 
-        IsisContext.closeAllSessions();
     }
 
-    /**
-     * @see #initializeServices()
-     */
-    private void shutdownServices(final ServiceInitializer serviceInitializer) {
+    private void preDestroyInSession(final ServiceInitializer serviceInitializer) {
 
         // may not be set if the metamodel validation failed during initialization
         if (serviceInitializer == null) {
             return;
         }
 
-        // call @PostDestroy (in a session)
+        // call @PreDestroy (in a session)
         IsisContext.openSession(new InitialisationSession());
         try {
             getTransactionManager().startTransaction();

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
index 03ff43d..e308206 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/context/IsisContext.java
@@ -19,9 +19,7 @@
 
 package org.apache.isis.core.runtime.system.context;
 
-import java.util.IdentityHashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.concurrent.Callable;
 
 import org.slf4j.Logger;
@@ -58,22 +56,9 @@ public class IsisContext {
 
     private static final Logger LOG = LoggerFactory.getLogger(IsisContext.class);
 
+    //region > singleton
     private static IsisContext singleton;
 
-    private final IsisSessionFactory sessionFactory;
-    private final SessionClosePolicy sessionClosePolicy;
-
-    private static IsisConfiguration configuration;
-
-    /**
-     * Populated only if the metamodel was found to be invalid
-     */
-    private static MetaModelInvalidException metamodelInvalidException;
-
-    // ///////////////////////////////////////////////////////////
-    // Singleton & Constructor, shutdown
-    // ///////////////////////////////////////////////////////////
-
     /**
      * Returns the singleton providing access to the set of execution contexts.
      */
@@ -95,6 +80,14 @@ public class IsisContext {
         singleton = null;
     }
 
+    //endregion
+
+
+    //region > metaModelInvalidExceptionIfAny (static)
+    /**
+     * Populated only if the metamodel was found to be invalid
+     */
+    private static MetaModelInvalidException metamodelInvalidException;
 
     public static MetaModelInvalidException getMetaModelInvalidExceptionIfAny() {
         return IsisContext.metamodelInvalidException;
@@ -102,9 +95,17 @@ public class IsisContext {
     public static void setMetaModelInvalidException(final MetaModelInvalidException metaModelInvalid) {
         IsisContext.metamodelInvalidException = metaModelInvalid;
     }
+    //endregion
 
+    private static IsisConfiguration configuration;
 
-    protected static enum SessionClosePolicy {
+    public static IsisContext createInstance(final IsisSessionFactory sessionFactory) {
+        return new IsisContext(sessionFactory);
+    }
+
+    //region > constructor, fields
+
+    protected enum SessionClosePolicy {
         /**
          * Sessions must be explicitly closed.
          *
@@ -119,6 +120,12 @@ public class IsisContext {
     }
 
 
+
+    private final IsisSessionFactory sessionFactory;
+    private final SessionClosePolicy sessionClosePolicy;
+
+
+
     /**
      * Creates a new instance of the {@link IsisSession} holder.
      * 
@@ -141,7 +148,16 @@ public class IsisContext {
         this(SessionClosePolicy.AUTO_CLOSE, sessionFactory);
     }
 
+    /**
+     * As injected in constructor.
+     */
+    public final IsisSessionFactory getSessionFactoryInstance() {
+        return sessionFactory;
+    }
+
+    //endregion
 
+    //region > shutdown
 
     protected void shutdownInstance() {
         this.sessionFactory.shutdown();
@@ -154,20 +170,9 @@ public class IsisContext {
     }
 
 
-    // ///////////////////////////////////////////////////////////
-    // SessionFactory
-    // ///////////////////////////////////////////////////////////
+    //endregion
 
-    /**
-     * As injected in constructor.
-     */
-    public final IsisSessionFactory getSessionFactoryInstance() {
-        return sessionFactory;
-    }
-
-    // ///////////////////////////////////////////////////////////
-    // Policies
-    // ///////////////////////////////////////////////////////////
+    //region > Policies
 
     /**
      * Whether any open session can be automatically
@@ -192,9 +197,11 @@ public class IsisContext {
         closeSessionInstance();
     }
 
-    // ///////////////////////////////////////////////////////////
-    // open / close 
-    // ///////////////////////////////////////////////////////////
+    //endregion
+
+    //region > openSessionInstance / closeSessionInstance, getSessionInstance
+
+    private final ThreadLocal<IsisSession> currentSession = new ThreadLocal<>();
 
     /**
      * Creates a new {@link IsisSession} and binds into the current context.
@@ -210,26 +217,10 @@ public class IsisContext {
      *             if already opened.
      */
     public IsisSession openSessionInstance(final AuthenticationSession authenticationSession) {
-        final Thread thread = Thread.currentThread();
-        synchronized (sessionsByThread) {
-            applySessionClosePolicy();
-            final IsisSession session = getSessionFactoryInstance().openSession(authenticationSession);
-            if (LOG.isDebugEnabled()) {
-                LOG.debug("  opening session " + session + " (count " + sessionsByThread.size() + ") for " + authenticationSession.getUserName());
-            }
-            saveSession(thread, session);
-            session.open();
-            return session;
-        }
-    }
-
-    private IsisSession saveSession(final Thread thread, final IsisSession session) {
-        synchronized (sessionsByThread) {
-            sessionsByThread.put(thread, session);
-        }
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("  saving session " + session + "; now have " + sessionsByThread.size() + " sessions");
-        }
+        applySessionClosePolicy();
+        final IsisSession session = getSessionFactoryInstance().openSession(authenticationSession);
+        currentSession.set(session);
+        session.open();
         return session;
     }
 
@@ -251,75 +242,22 @@ public class IsisContext {
         final IsisSession isisSession = getSessionInstance();
         if (isisSession != null) {
             isisSession.close();
-            doClose();
+            currentSession.set(null);
         }
     }
 
     /**
-     * Overridable hook method called from {@link #closeSessionInstance()},
-     * allowing subclasses to clean up (for example datastructures).
-     * 
-     * <p>
-     * The {@link #getSessionInstance() current} {@link IsisSession} will
-     * already have been {@link IsisSession#close() closed}.
-     */
-    protected void doClose() {
-        sessionsByThread.remove(Thread.currentThread());
-    }
-
-    /**
-     * Shutdown the application.
-     */
-    public void closeAllSessionsInstance() {
-        shutdownAllThreads();
-    }
-
-
-
-    // ///////////////////////////////////////////////////////////
-    // getSession()
-    // ///////////////////////////////////////////////////////////
-
-    /**
      * Locates the current {@link IsisSession} from the threadlocal.
      *
      * @see #openSessionInstance(AuthenticationSession)
      */
     public IsisSession getSessionInstance() {
-        final Thread thread = Thread.currentThread();
-        return sessionsByThread.get(thread);
+        return currentSession.get();
     }
 
-    /**
-     * The {@link IsisSession} for specified {@link IsisSession#getId()}.
-     */
-    protected IsisSession getSessionInstance(final String executionContextId) {
-        for (final IsisSession data : sessionsByThread.values()) {
-            if (data.getId().equals(executionContextId)) {
-                return data;
-            }
-        }
-        return null;
-    }
+    //endregion
 
-    /**
-     * All known session Ids.
-     * 
-     * <p>
-     * Provided primarily for debugging.
-     */
-    public String[] allSessionIds() {
-        final String[] ids = new String[sessionsByThread.size()];
-        int i = 0;
-        for (final IsisSession data  : sessionsByThread.values()) {
-            ids[i++] = data.getId();
-        }
-        return ids;
-    }
-
-    // ///////////////////////////////////////////////////////////
-    // Static Convenience methods (session management)
-    // ///////////////////////////////////////////////////////////
+    //region > Static Convenience methods (session management)
 
 
     /**
@@ -340,34 +278,9 @@ public class IsisContext {
         getInstance().closeSessionInstance();
     }
 
-    /**
-     * Convenience method to return {@link IsisSession} for specified
-     * {@link IsisSession#getId()}.
-     * 
-     * <p>
-     * Provided primarily for debugging.
-     * 
-     * @see #getSessionInstance(String)
-     */
-    public static IsisSession getSession(final String sessionId) {
-        return getInstance().getSessionInstance(sessionId);
-    }
-
-    /**
-     * Convenience method to close all sessions.
-     */
-    public static void closeAllSessions() {
-        LOG.info("closing all instances");
-        final IsisContext instance = getInstance();
-        if (instance != null) {
-            instance.closeAllSessionsInstance();
-        }
-    }
-
-    // ///////////////////////////////////////////////////////////
-    // Static Convenience methods (application scoped)
-    // ///////////////////////////////////////////////////////////
+    //endregion
 
+    //region > Static Convenience methods (application scoped)
     /**
      * Convenience method returning the {@link IsisSessionFactory} of the
      * current {@link #getSession() session}.
@@ -432,10 +345,9 @@ public class IsisContext {
         return getSessionFactory().getOidMarshaller();
     }
 
+    //endregion
 
-    // ///////////////////////////////////////////////////////////
-    // Static Convenience methods (session scoped)
-    // ///////////////////////////////////////////////////////////
+    //region > Static Convenience methods (session scoped)
 
     public static boolean inSession() {
         final IsisSession session = getInstance().getSessionInstance();
@@ -454,16 +366,6 @@ public class IsisContext {
     }
 
     /**
-     * Convenience method to return the {@link #getSession() current}
-     * {@link IsisSession}'s {@link IsisSession#getId() id}.
-     * 
-     * @see IsisSession#getId()
-     */
-    public static String getSessionId() {
-        return getSession().getId();
-    }
-
-    /**
      * @see IsisSession#getAuthenticationSession()
      */
     public static AuthenticationSession getAuthenticationSession() {
@@ -496,9 +398,9 @@ public class IsisContext {
         return getPersistenceSession().getTransactionManager();
     }
 
-    // ///////////////////////////////////////////////////////////
-    // Static Convenience methods (transaction scoped)
-    // ///////////////////////////////////////////////////////////
+    //endregion
+
+    //region > Static Convenience methods (transaction scoped)
 
     public static boolean inTransaction() {
         if (inSession())
@@ -576,32 +478,8 @@ public class IsisContext {
         }
     }
 
+    //endregion
 
 
-    public static IsisContext createInstance(final IsisSessionFactory sessionFactory) {
-        return new IsisContext(sessionFactory);
-    }
-
-    // TODO: could convert this to a regular ThreadLocal, I think; except for the closeAllSessionsInstance() method...; is that method really needed?
-    private final Map<Thread, IsisSession> sessionsByThread = new IdentityHashMap<>();
-
-
-
-
-    // /////////////////////////////////////////////////////////
-    // Session
-    // /////////////////////////////////////////////////////////
-
-
-    protected void shutdownAllThreads() {
-        synchronized (sessionsByThread) {
-            for (final Map.Entry<Thread, IsisSession> entry : sessionsByThread.entrySet()) {
-                LOG.info("Shutting down thread: {}", entry.getKey().getName());
-                final IsisSession data = entry.getValue();
-                data.closeAll();
-            }
-        }
-    }
-
 
 }

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
index 683ebfb..10bf2c2 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
@@ -319,8 +319,14 @@ public class PersistenceSession implements
                 new PersistenceQueryFindUsingApplibQueryProcessor(this));
 
         initServices();
+
+        // tell the proxy of all request-scoped services to instantiate the underlying
+        // services, store onto the thread-local and inject into them...
         startRequestOnRequestScopedServices();
 
+        // ... and invoke all @PostConstruct
+        postConstructOnRequestScopedServices();
+
         if(metricsService instanceof InstanceLifecycleListener) {
             final InstanceLifecycleListener metricsService = (InstanceLifecycleListener) this.metricsService;
             persistenceManager.addInstanceLifecycleListener(metricsService, (Class[]) null);
@@ -348,23 +354,18 @@ public class PersistenceSession implements
         this.state = State.OPEN;
     }
 
-
-
-    private void startRequestOnRequestScopedServices() {
-
-        final List<Object> registeredServices = servicesInjector.getRegisteredServices();
-
-        // tell the proxy of all request-scoped services to instantiate the underlying
-        // services, store onto the thread-local and inject into them...
-        for (final Object service : registeredServices) {
+    private void postConstructOnRequestScopedServices() {
+        for (final Object service : servicesInjector.getRegisteredServices()) {
             if(service instanceof RequestScopedService) {
-                ((RequestScopedService)service).__isis_startRequest(servicesInjector);
+                ((RequestScopedService)service).__isis_postConstruct();
             }
         }
-        // ... and invoke all @PostConstruct
-        for (final Object service : registeredServices) {
+    }
+
+    private void startRequestOnRequestScopedServices() {
+        for (final Object service : servicesInjector.getRegisteredServices()) {
             if(service instanceof RequestScopedService) {
-                ((RequestScopedService)service).__isis_postConstruct();
+                ((RequestScopedService)service).__isis_startRequest(servicesInjector);
             }
         }
     }
@@ -424,10 +425,6 @@ public class PersistenceSession implements
         completeCommandFromInteractionAndClearDomainEvents();
         transactionManager.flushTransaction();
 
-        Bulk.InteractionContext.current.set(null);
-
-        endRequestOnRequestScopeServices();
-
         try {
             final IsisTransaction currentTransaction = transactionManager.getTransaction();
             if (currentTransaction != null && !currentTransaction.getState().isComplete()) {
@@ -442,6 +439,15 @@ public class PersistenceSession implements
             LOG.error("close: failed to end transaction; continuing to avoid memory leakage");
         }
 
+        Bulk.InteractionContext.current.set(null);
+
+        // tell the proxy of all request-scoped services to invoke @PreDestroy
+        // (if any) on all underlying services stored on their thread-locals...
+        preDestroyOnRequestScopedServices();
+
+        // ... and then remove those underlying services from the thread-local
+        endRequestOnRequestScopeServices();
+
         try {
             persistenceManager.close();
         } catch(final Throwable ex) {
@@ -468,18 +474,17 @@ public class PersistenceSession implements
     }
 
     private void endRequestOnRequestScopeServices() {
-        // tell the proxy of all request-scoped services to invoke @PreDestroy
-        // (if any) on all underlying services stored on their thread-locals...
         for (final Object service : servicesInjector.getRegisteredServices()) {
             if(service instanceof RequestScopedService) {
-                ((RequestScopedService)service).__isis_preDestroy();
+                ((RequestScopedService)service).__isis_endRequest();
             }
         }
+    }
 
-        // ... and then remove those underlying services from the thread-local
+    private void preDestroyOnRequestScopedServices() {
         for (final Object service : servicesInjector.getRegisteredServices()) {
             if(service instanceof RequestScopedService) {
-                ((RequestScopedService)service).__isis_endRequest();
+                ((RequestScopedService)service).__isis_preDestroy();
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSession.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSession.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSession.java
index b664a04..42ba48f 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSession.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/session/IsisSession.java
@@ -19,13 +19,10 @@
 
 package org.apache.isis.core.runtime.system.session;
 
-import java.text.SimpleDateFormat;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.components.ApplicationScopedComponent;
 import org.apache.isis.core.commons.components.SessionScopedComponent;
 import org.apache.isis.core.commons.config.IsisConfiguration;
 import org.apache.isis.core.commons.util.ToString;
@@ -35,10 +32,6 @@ import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
 import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
 import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
 
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.not;
-import static org.hamcrest.CoreMatchers.nullValue;
-
 /**
  * Analogous to (and in essence a wrapper for) a JDO <code>PersistenceManager</code>;
  * holds the current set of components for a specific execution context (such as on a thread).
@@ -52,19 +45,12 @@ public class IsisSession implements SessionScopedComponent {
 
     private static final Logger LOG = LoggerFactory.getLogger(IsisSession.class);
 
-    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd/MM HH:mm:ss,SSS");
-    private static int nextId = 1;
+    //region > constructor, fields
 
     private final IsisSessionFactory isisSessionFactory;
-
     private final AuthenticationSession authenticationSession;
-    private PersistenceSession persistenceSession; // only non-final so can be
-    // replaced in tests.
-    private final int id;
-    private long accessTime;
-    private String debugSnapshot;
+    private PersistenceSession persistenceSession; // only non-final so can be replaced in tests.
 
-    //region > constructor
     public IsisSession(
             final IsisSessionFactory sessionFactory,
             final AuthenticationSession authenticationSession,
@@ -73,11 +59,6 @@ public class IsisSession implements SessionScopedComponent {
         this.isisSessionFactory = sessionFactory;
         this.authenticationSession = authenticationSession;
         this.persistenceSession = persistenceSession;
-
-        setSessionOpenTime(System.currentTimeMillis());
-
-        this.id = nextId++;
-
     }
     //endregion
 
@@ -98,23 +79,6 @@ public class IsisSession implements SessionScopedComponent {
 
     //endregion
 
-    //region > shutdown
-    /**
-     * Shuts down all components.
-     *
-     * Normal lifecycle is managed using callbacks in
-     * {@link SessionScopedComponent}. This method is to allow the outer
-     * {@link ApplicationScopedComponent}s to shutdown, closing any and all
-     * running {@link IsisSession}s.
-     */
-    public void closeAll() {
-        close();
-
-        persistenceSession.close();
-    }
-
-    //endregion
-
     //region > convenience methods
     /**
      * Convenience method.
@@ -146,19 +110,6 @@ public class IsisSession implements SessionScopedComponent {
     public AuthenticationSession getAuthenticationSession() {
         return authenticationSession;
     }
-
-    private String getSessionUserName() {
-        return getAuthenticationSession().getUserName();
-    }
-    //endregion
-
-    //region > id
-    /**
-     * A descriptive identifier for this {@link IsisSession}.
-     */
-    public String getId() {
-        return "#" + id + getSessionUserName();
-    }
     //endregion
 
     //region > Persistence Session
@@ -171,11 +122,6 @@ public class IsisSession implements SessionScopedComponent {
 
     //endregion
 
-    private void setSessionOpenTime(final long accessTime) {
-        this.accessTime = accessTime;
-    }
-    //endregion
-
     //region > transaction
 
     /**
@@ -192,7 +138,6 @@ public class IsisSession implements SessionScopedComponent {
     @Override
     public String toString() {
         final ToString asString = new ToString(this);
-        asString.append("context", getId());
         asString.append("authenticationSession", getAuthenticationSession());
         asString.append("persistenceSession", getPersistenceSession());
         asString.append("transaction", getCurrentTransaction());

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java
index 2461ae9..cfcffaf 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisComponentProviderDefault2.java
@@ -61,7 +61,6 @@ public class IsisComponentProviderDefault2 extends IsisComponentProvider  {
             final List<Object> servicesOverride,
             final List<InstallableFixture> fixturesOverride,
             final IsisConfiguration configurationOverride,
-            final ProgrammingModel programmingModelOverride,
             final MetaModelValidator metaModelValidatorOverride) {
         super(deploymentType, appManifestIfAny, elseDefault(configurationOverride));
 
@@ -80,7 +79,7 @@ public class IsisComponentProviderDefault2 extends IsisComponentProvider  {
         this.authenticationManager = createAuthenticationManager();
         this.authorizationManager = createAuthorizationManager();
 
-        this.programmingModel = elseDefault(programmingModelOverride);
+        this.programmingModel = createDefaultProgrammingModel();
         this.metaModelValidator = elseDefault(metaModelValidatorOverride);
 
     }
@@ -95,10 +94,6 @@ public class IsisComponentProviderDefault2 extends IsisComponentProvider  {
                 : new IsisConfigurationDefault(ResourceStreamSourceContextLoaderClassPath.create("config"));
     }
 
-    private ProgrammingModel elseDefault(final ProgrammingModel programmingModel) {
-        return programmingModel != null ? programmingModel : createDefaultProgrammingModel();
-    }
-
     // TODO: this is duplicating logic in JavaReflectorInstaller; need to unify.
     private ProgrammingModel createDefaultProgrammingModel() {
 

http://git-wip-us.apache.org/repos/asf/isis/blob/e38eaf7b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java
----------------------------------------------------------------------
diff --git a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java
index 8e2c289..4c0fd8c 100644
--- a/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java
+++ b/core/viewer-wicket-impl/src/main/java/org/apache/isis/viewer/wicket/viewer/integration/wicket/WebRequestCycleForIsis.java
@@ -247,10 +247,7 @@ public class WebRequestCycleForIsis extends AbstractRequestCycleListener {
         this.pageClassRegistry = pageClassRegistry;
     }
     
-    ///////////////////////////////////////////////////////////////
-    // Dependencies (from isis' context)
-    ///////////////////////////////////////////////////////////////
-    
+    //region > Dependencies (from isis' context)
     protected ServicesInjector getServicesInjector() {
         return IsisContext.getPersistenceSession().getServicesInjector();
     }
@@ -270,14 +267,14 @@ public class WebRequestCycleForIsis extends AbstractRequestCycleListener {
     protected AuthenticationSession getAuthenticationSession() {
         return IsisContext.getAuthenticationSession();
     }
+    //endregion
 
-    ///////////////////////////////////////////////////////////////
-    // Dependencies (from wicket)
-    ///////////////////////////////////////////////////////////////
+    //region > Dependencies (from wicket)
 
-    
     protected AuthenticatedWebSession getWicketAuthenticationSession() {
         return AuthenticatedWebSession.get();
     }
 
+    //endregion
+
 }


[3/3] isis git commit: ISIS-1419: calling bounceSystem (misnamed, just means close and re-open a session) at the end of each test.

Posted by da...@apache.org.
ISIS-1419: calling bounceSystem (misnamed, just means close and re-open a session) at the end of each test.


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

Branch: refs/heads/master
Commit: a5876219839bc5d5c366d4b1e8fd1dae1eef0a18
Parents: e38eaf7
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Tue May 31 07:30:28 2016 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Tue May 31 07:30:28 2016 +0100

----------------------------------------------------------------------
 .../apache/isis/core/integtestsupport/IntegrationTestAbstract.java  | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/a5876219/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract.java
index 360ea9e..ce7a929 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IntegrationTestAbstract.java
@@ -212,6 +212,7 @@ public abstract class IntegrationTestAbstract {
                     try {
                         base.evaluate();
                         isft.endTran();
+                        isft.bounceSystem();
                     } catch(final Throwable e) {
                         isft.bounceSystem();
                         final List<Throwable> causalChain = Throwables.getCausalChain(e);