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 2015/08/05 08:51:37 UTC
[1/2] isis git commit: ISIS-1187: mothballing legacy integration test
support.
Repository: isis
Updated Branches:
refs/heads/master 1d5e8c18f -> a930c1da1
ISIS-1187: mothballing legacy integration test support.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/6549e1eb
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/6549e1eb
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/6549e1eb
Branch: refs/heads/master
Commit: 6549e1eb46bd048eb31fcdba93759acdedb6c128
Parents: 1d5e8c1
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Wed Aug 5 06:55:26 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Wed Aug 5 06:55:26 2015 +0100
----------------------------------------------------------------------
.../integtestsupport/legacy/Authenticator.java | 32 ---
.../integtestsupport/legacy/Authorizor.java | 32 ---
.../core/integtestsupport/legacy/ConfigDir.java | 36 ----
.../core/integtestsupport/legacy/Fixture.java | 33 ---
.../core/integtestsupport/legacy/Fixtures.java | 33 ---
.../integtestsupport/legacy/IsisTestRunner.java | 215 -------------------
.../core/integtestsupport/legacy/Persistor.java | 32 ---
.../core/integtestsupport/legacy/Service.java | 33 ---
.../core/integtestsupport/legacy/Services.java | 33 ---
.../legacy/components/AnnotationInstaller.java | 94 --------
.../FixtureInstallerAnnotatedClass.java | 88 --------
.../IsisSystemUsingInstallersWithinJunit.java | 73 -------
.../ServicesInstallerAnnotatedClass.java | 91 --------
.../integtestsupport/legacy/Authenticator.java | 32 +++
.../integtestsupport/legacy/Authorizor.java | 32 +++
.../core/integtestsupport/legacy/ConfigDir.java | 36 ++++
.../core/integtestsupport/legacy/Fixture.java | 33 +++
.../core/integtestsupport/legacy/Fixtures.java | 33 +++
.../integtestsupport/legacy/IsisTestRunner.java | 215 +++++++++++++++++++
.../core/integtestsupport/legacy/Persistor.java | 32 +++
.../core/integtestsupport/legacy/Service.java | 33 +++
.../core/integtestsupport/legacy/Services.java | 33 +++
.../legacy/components/AnnotationInstaller.java | 94 ++++++++
.../FixtureInstallerAnnotatedClass.java | 88 ++++++++
.../IsisSystemUsingInstallersWithinJunit.java | 73 +++++++
.../ServicesInstallerAnnotatedClass.java | 91 ++++++++
26 files changed, 825 insertions(+), 825 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
deleted file mode 100644
index b788520..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Authenticator {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
deleted file mode 100644
index be399b3..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Authorizor {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
deleted file mode 100644
index eac566c..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The location of the <tt>config</tt> directory, relative to the base.
- */
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface ConfigDir {
- String value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
deleted file mode 100644
index bf8a9f8..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Fixture {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
deleted file mode 100644
index f2e25ed..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Fixtures {
- Fixture[] value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
deleted file mode 100644
index cdd1170..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import org.jmock.Mockery;
-import org.junit.internal.runners.*;
-import org.junit.runner.Description;
-import org.junit.runner.notification.Failure;
-import org.junit.runner.notification.RunNotifier;
-import org.apache.isis.applib.fixtures.LogonFixture;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
-import org.apache.isis.core.commons.config.IsisConfigurationBuilderDefault;
-import org.apache.isis.core.integtestsupport.legacy.components.IsisSystemUsingInstallersWithinJunit;
-import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
-import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
-import org.apache.isis.core.runtime.authentication.exploration.AuthenticationRequestExploration;
-import org.apache.isis.core.runtime.fixtures.authentication.AuthenticationRequestLogonFixture;
-import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.system.SystemConstants;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-
-/**
- * Copied from JMock, and with the same support.
- *
- */
-public class IsisTestRunner extends JUnit4ClassRunner {
-
- private final Field mockeryField;
-
- /**
- * Only used during object construction.
- */
- public IsisTestRunner(final Class<?> testClass) throws InitializationError {
- super(testClass);
-
- // JMock initialization, adapted to allow for no mockery field.
- mockeryField = findFieldAndMakeAccessible(testClass, Mockery.class);
- }
-
- private static String getConfigDir(final Class<?> javaClass) {
- final ConfigDir fixturesAnnotation = javaClass.getAnnotation(ConfigDir.class);
- if (fixturesAnnotation != null) {
- return fixturesAnnotation.value();
- }
- return null;
- }
-
- @Override
- protected void invokeTestMethod(final Method method, final RunNotifier notifier) {
-
- final TestClass testClass = getTestClass();
- final String configDirIfAny = getConfigDir(testClass.getJavaClass());
-
- final Description description = methodDescription(method);
-
- final IsisConfigurationBuilder isisConfigurationBuilder = new IsisConfigurationBuilderDefault(configDirIfAny);
- isisConfigurationBuilder.add(SystemConstants.NOSPLASH_KEY, "" + true); // switch
- // off
- // splash
-
- final InstallerLookup installerLookup = new InstallerLookup();
- isisConfigurationBuilder.injectInto(installerLookup);
- installerLookup.init();
-
- IsisSystemUsingInstallersWithinJunit system = null;
- AuthenticationSession session = null;
- try {
- // init the system; cf similar code in Isis and
- // IsisServletContextInitializer
- final DeploymentType deploymentType = DeploymentType.UNIT_TESTING;
-
- // TODO: replace with regular IsisSystem and remove this subclass.
- system = new IsisSystemUsingInstallersWithinJunit(deploymentType, installerLookup, testClass);
-
- system.init();
-
- // specific to this bootstrap mechanism
- AuthenticationRequest request;
- final LogonFixture logonFixture = system.getFixturesInstaller().getLogonFixture();
- if (logonFixture != null) {
- request = new AuthenticationRequestLogonFixture(logonFixture);
- } else {
- request = new AuthenticationRequestExploration(logonFixture);
- }
- session = IsisContext.getAuthenticationManager().authenticate(request);
-
- IsisContext.openSession(session);
- getTransactionManager().startTransaction();
-
- final Object test = createTest();
- getServicesInjector().injectServicesInto(test);
-
- final TestMethod testMethod = wrapMethod(method);
- new MethodRoadie(test, testMethod, notifier, description).run();
-
- getTransactionManager().endTransaction();
-
- } catch (final InvocationTargetException e) {
- testAborted(notifier, description, e.getCause());
- getTransactionManager().abortTransaction();
- return;
- } catch (final Exception e) {
- testAborted(notifier, description, e);
- return;
- } finally {
- if (system != null) {
- if (session != null) {
- IsisContext.closeSession();
- }
- system.shutdown();
- }
- }
- }
-
- private void testAborted(final RunNotifier notifier, final Description description, final Throwable e) {
- notifier.fireTestStarted(description);
- notifier.fireTestFailure(new Failure(description, e));
- notifier.fireTestFinished(description);
- }
-
- /**
- * Taken from JMock's runner.
- */
- @Override
- protected TestMethod wrapMethod(final Method method) {
- return new TestMethod(method, getTestClass()) {
- @Override
- public void invoke(final Object testFixture) throws IllegalAccessException, InvocationTargetException {
-
- super.invoke(testFixture);
-
- if (mockeryField != null) {
- mockeryOf(testFixture).assertIsSatisfied();
- }
- }
- };
- }
-
- /**
- * JMock code.
- *
- * @param test
- * @return
- */
- protected Mockery mockeryOf(final Object test) {
- if (mockeryField == null) {
- return null;
- }
- try {
- final Mockery mockery = (Mockery) mockeryField.get(test);
- if (mockery == null) {
- throw new IllegalStateException(String.format("Mockery named '%s' is null", mockeryField.getName()));
- }
- return mockery;
- } catch (final IllegalAccessException e) {
- throw new IllegalStateException(String.format("cannot get value of field %s", mockeryField.getName()), e);
- }
- }
-
- /**
- * Adapted from JMock code.
- */
- static Field findFieldAndMakeAccessible(final Class<?> testClass, final Class<?> clazz) throws InitializationError {
- for (Class<?> c = testClass; c != Object.class; c = c.getSuperclass()) {
- for (final Field field : c.getDeclaredFields()) {
- if (clazz.isAssignableFrom(field.getType())) {
- field.setAccessible(true);
- return field;
- }
- }
- }
- return null;
- }
-
- // /////////////////////////////////////////////////////
- // Dependencies (from context)
- // /////////////////////////////////////////////////////
-
- private static PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- private static ServicesInjectorSpi getServicesInjector() {
- return getPersistenceSession().getServicesInjector();
- }
-
- private static IsisTransactionManager getTransactionManager() {
- return getPersistenceSession().getTransactionManager();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
deleted file mode 100644
index 32ad6e0..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * 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.
- */
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Persistor {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
deleted file mode 100644
index 4e52531..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Service {
- Class<?> value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
deleted file mode 100644
index f4290d5..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Inherited
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Services {
- Service[] value();
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
deleted file mode 100644
index 151de42..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.
- */
-package org.apache.isis.core.integtestsupport.legacy.components;
-
-import org.apache.isis.core.integtestsupport.legacy.Authenticator;
-import org.apache.isis.core.integtestsupport.legacy.Authorizor;
-import org.apache.isis.core.integtestsupport.legacy.Persistor;
-import org.apache.isis.core.runtime.authentication.AuthenticationManagerInstaller;
-import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
-import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-import org.apache.isis.core.security.authentication.BypassAuthenticationManagerInstaller;
-import org.apache.isis.core.security.authorization.BypassAuthorizationManagerInstaller;
-import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
-
-public class AnnotationInstaller {
-
- /**
- * Should be called prior to installing; typically called immediately after
- * instantiation.
- *
- * <p>
- * Note: an alternative design would be to have a 1-arg constructor, but the
- * convention for installers is to make them no-arg.
- */
- // {{ AuthenticationManagerInstaller
- public AuthenticationManagerInstaller addAuthenticatorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Authenticator authenticatorAnnotation = javaClass.getAnnotation(Authenticator.class);
- if (authenticatorAnnotation != null) {
- return addAuthenticatorRepresentedBy(authenticatorAnnotation);
- } else {
- return new BypassAuthenticationManagerInstaller();
- }
-
- }
-
- private AuthenticationManagerInstaller addAuthenticatorRepresentedBy(final Authenticator authenticatorAnnotation) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = authenticatorAnnotation.value();
- return (AuthenticationManagerInstaller) fixtureClass.newInstance();
- }
-
- // }}
-
- // {{ AuthorizationManagerInstaller
- public AuthorizationManagerInstaller addAuthorizerAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Authorizor authorizorAnnotation = javaClass.getAnnotation(Authorizor.class);
- if (authorizorAnnotation != null) {
- return addAuthorizerRepresentedBy(authorizorAnnotation);
- } else {
- return new BypassAuthorizationManagerInstaller();
- }
-
- }
-
- private AuthorizationManagerInstaller addAuthorizerRepresentedBy(final Authorizor authorizorAnnotation) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = authorizorAnnotation.value();
- return (AuthorizationManagerInstaller) fixtureClass.newInstance();
- }
-
- // }}
-
- // {{ PersistenceMechanismInstaller
- public PersistenceMechanismInstaller addPersistorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Persistor annotation = javaClass.getAnnotation(Persistor.class);
- return annotation != null
- ? addPersistorRepresentedBy(annotation)
- : new DataNucleusPersistenceMechanismInstaller();
-
- }
-
- private PersistenceMechanismInstaller addPersistorRepresentedBy(
- final Persistor annotation)
- throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = annotation.value();
- return (PersistenceMechanismInstaller) fixtureClass.newInstance();
- }
- // }}
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
deleted file mode 100644
index 43b30ed..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy.components;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.core.integtestsupport.legacy.Fixture;
-import org.apache.isis.core.integtestsupport.legacy.Fixtures;
-import org.apache.isis.core.runtime.fixtures.FixturesInstallerAbstract;
-import org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate;
-
-public class FixtureInstallerAnnotatedClass extends FixturesInstallerAbstract {
-
- private final List<Object> fixtures = new ArrayList<Object>();
-
- /**
- * @see #addFixturesAnnotatedOn(Class)
- */
- public FixtureInstallerAnnotatedClass() {
- super("annotated");
- }
-
- // ///////////////////////////////////////////
- // Hook method
- // ///////////////////////////////////////////
-
- /**
- * Just copies the fixtures added using
- * {@link #addFixturesAnnotatedOn(Class)} into the delegate.
- */
- @Override
- protected void addFixturesTo(final FixturesInstallerDelegate delegate) {
- for (final Object fixture : fixtures) {
- delegate.addFixture(fixture);
- }
- }
-
- // ///////////////////////////////////////////
- // addFixturesAnnotatedOn (not API)
- // ///////////////////////////////////////////
-
- /**
- * Should be called prior to installing; typically called immediately after
- * instantiation.
- *
- * <p>
- * Note: an alternative design would be to have a 1-arg constructor, but the
- * convention for installers is to make them no-arg.
- */
- public void addFixturesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final Fixtures fixturesAnnotation = javaClass.getAnnotation(Fixtures.class);
- if (fixturesAnnotation != null) {
- final Fixture[] fixtureAnnotations = fixturesAnnotation.value();
- for (final Fixture fixtureAnnotation : fixtureAnnotations) {
- addFixtureRepresentedBy(fixtureAnnotation, fixtures);
- }
- }
-
- final Fixture fixtureAnnotation = javaClass.getAnnotation(Fixture.class);
- if (fixtureAnnotation != null) {
- addFixtureRepresentedBy(fixtureAnnotation, fixtures);
- }
- }
-
- private void addFixtureRepresentedBy(final Fixture fixtureAnnotation, final List<Object> fixtures) throws InstantiationException, IllegalAccessException {
- final Class<?> fixtureClass = fixtureAnnotation.value();
- fixtures.add(fixtureClass.newInstance());
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
deleted file mode 100644
index b4bbc87..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy.components;
-
-import org.junit.internal.runners.TestClass;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
-import org.apache.isis.core.runtime.system.DeploymentType;
-import org.apache.isis.core.runtime.systemusinginstallers.IsisSystemUsingInstallers;
-
-public class IsisSystemUsingInstallersWithinJunit extends IsisSystemUsingInstallers {
-
- private final TestClass testClass;
-
- public IsisSystemUsingInstallersWithinJunit(final DeploymentType deploymentType, final InstallerLookup installerLookup, final TestClass testClass) {
- super(deploymentType, installerLookup);
- installerLookup.getConfigurationBuilder().add("isis.deploymentType", deploymentType.nameLowerCase());
-
- this.testClass = testClass;
-
- final AnnotationInstaller installer = new AnnotationInstaller();
-
- try {
- setAuthenticationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthenticatorAnnotatedOn(this.testClass.getJavaClass())));
-
- setAuthorizationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthorizerAnnotatedOn(this.testClass.getJavaClass())));
-
- setPersistenceMechanismInstaller(getInstallerLookup().injectDependenciesInto(installer.addPersistorAnnotatedOn(this.testClass.getJavaClass())));
-
- // fixture installer
- final FixtureInstallerAnnotatedClass fixtureInstaller = new FixtureInstallerAnnotatedClass();
- fixtureInstaller.addFixturesAnnotatedOn(this.testClass.getJavaClass());
- setFixtureInstaller(fixtureInstaller);
- } catch (final InstantiationException e) {
- throw new IsisException(e);
- } catch (final IllegalAccessException e) {
- throw new IsisException(e);
- }
-
- // services installer
- final ServicesInstallerAnnotatedClass servicesInstaller = new ServicesInstallerAnnotatedClass();
- try {
- servicesInstaller.addServicesAnnotatedOn(this.testClass.getJavaClass());
- } catch (final InstantiationException e) {
- throw new IsisException(e);
- } catch (final IllegalAccessException e) {
- throw new IsisException(e);
- }
- setServicesInstaller(servicesInstaller);
- }
-
- public TestClass getTestClass() {
- return testClass;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
deleted file mode 100644
index 3d6fec2..0000000
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.integtestsupport.legacy.components;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.core.integtestsupport.legacy.Service;
-import org.apache.isis.core.integtestsupport.legacy.Services;
-import org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault;
-import org.apache.isis.core.runtime.services.ServicesInstallerAbstract;
-
-public class ServicesInstallerAnnotatedClass extends ServicesInstallerAbstract {
-
- public ServicesInstallerAnnotatedClass() {
- super("annotated");
- }
-
- public void addServicesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
- final List<Object> services = new ArrayList<Object>();
- addServicesAnnotatedOn(javaClass, services);
-
- final DomainObjectContainer doc = lookupContainerIn(services);
- if(doc == null) {
- services.add(new DomainObjectContainerDefault());
- }
-
- addServices(services);
-
- }
-
- private static DomainObjectContainer lookupContainerIn(List<Object> services1) {
- for (Object service : services1) {
- if(service instanceof DomainObjectContainer) {
- return (DomainObjectContainer) service;
- }
- }
- return null;
- }
-
-
- private void addServicesAnnotatedOn(final Class<?> testClass, final List<Object> services) throws InstantiationException, IllegalAccessException {
- final Services servicesAnnotation = testClass.getAnnotation(Services.class);
- if (servicesAnnotation != null) {
- final Service[] serviceAnnotations = servicesAnnotation.value();
- for (final Service serviceAnnotation : serviceAnnotations) {
- addServiceRepresentedBy(serviceAnnotation, services);
- }
- }
-
- final Service serviceAnnotation = testClass.getAnnotation(Service.class);
- if (serviceAnnotation != null) {
- addServiceRepresentedBy(serviceAnnotation, services);
- }
- }
-
- private void addServiceRepresentedBy(final Service serviceAnnotation, final List<Object> services) throws InstantiationException, IllegalAccessException {
- final Class<?> serviceClass = serviceAnnotation.value();
- // there's no need to unravel any Collections of services,
- // because the ServiceLoader will do it for us later.
- services.add(serviceClass.newInstance());
- }
-
- @Override
- public List<Class<?>> getTypes() {
- return listOf(List.class); // ie List<Object.class>, of services
- }
-
- @Override
- public void setIgnoreFailures(boolean ignoreFailures) {
- // no-op
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
new file mode 100644
index 0000000..b788520
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authenticator.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Authenticator {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
new file mode 100644
index 0000000..be399b3
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Authorizor.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Authorizor {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
new file mode 100644
index 0000000..eac566c
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/ConfigDir.java
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * The location of the <tt>config</tt> directory, relative to the base.
+ */
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ConfigDir {
+ String value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
new file mode 100644
index 0000000..bf8a9f8
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixture.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Fixture {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
new file mode 100644
index 0000000..f2e25ed
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Fixtures.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Fixtures {
+ Fixture[] value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
new file mode 100644
index 0000000..cdd1170
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/IsisTestRunner.java
@@ -0,0 +1,215 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import org.jmock.Mockery;
+import org.junit.internal.runners.*;
+import org.junit.runner.Description;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunNotifier;
+import org.apache.isis.applib.fixtures.LogonFixture;
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
+import org.apache.isis.core.commons.config.IsisConfigurationBuilderDefault;
+import org.apache.isis.core.integtestsupport.legacy.components.IsisSystemUsingInstallersWithinJunit;
+import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
+import org.apache.isis.core.runtime.authentication.AuthenticationRequest;
+import org.apache.isis.core.runtime.authentication.exploration.AuthenticationRequestExploration;
+import org.apache.isis.core.runtime.fixtures.authentication.AuthenticationRequestLogonFixture;
+import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.core.runtime.system.DeploymentType;
+import org.apache.isis.core.runtime.system.SystemConstants;
+import org.apache.isis.core.runtime.system.context.IsisContext;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+
+/**
+ * Copied from JMock, and with the same support.
+ *
+ */
+public class IsisTestRunner extends JUnit4ClassRunner {
+
+ private final Field mockeryField;
+
+ /**
+ * Only used during object construction.
+ */
+ public IsisTestRunner(final Class<?> testClass) throws InitializationError {
+ super(testClass);
+
+ // JMock initialization, adapted to allow for no mockery field.
+ mockeryField = findFieldAndMakeAccessible(testClass, Mockery.class);
+ }
+
+ private static String getConfigDir(final Class<?> javaClass) {
+ final ConfigDir fixturesAnnotation = javaClass.getAnnotation(ConfigDir.class);
+ if (fixturesAnnotation != null) {
+ return fixturesAnnotation.value();
+ }
+ return null;
+ }
+
+ @Override
+ protected void invokeTestMethod(final Method method, final RunNotifier notifier) {
+
+ final TestClass testClass = getTestClass();
+ final String configDirIfAny = getConfigDir(testClass.getJavaClass());
+
+ final Description description = methodDescription(method);
+
+ final IsisConfigurationBuilder isisConfigurationBuilder = new IsisConfigurationBuilderDefault(configDirIfAny);
+ isisConfigurationBuilder.add(SystemConstants.NOSPLASH_KEY, "" + true); // switch
+ // off
+ // splash
+
+ final InstallerLookup installerLookup = new InstallerLookup();
+ isisConfigurationBuilder.injectInto(installerLookup);
+ installerLookup.init();
+
+ IsisSystemUsingInstallersWithinJunit system = null;
+ AuthenticationSession session = null;
+ try {
+ // init the system; cf similar code in Isis and
+ // IsisServletContextInitializer
+ final DeploymentType deploymentType = DeploymentType.UNIT_TESTING;
+
+ // TODO: replace with regular IsisSystem and remove this subclass.
+ system = new IsisSystemUsingInstallersWithinJunit(deploymentType, installerLookup, testClass);
+
+ system.init();
+
+ // specific to this bootstrap mechanism
+ AuthenticationRequest request;
+ final LogonFixture logonFixture = system.getFixturesInstaller().getLogonFixture();
+ if (logonFixture != null) {
+ request = new AuthenticationRequestLogonFixture(logonFixture);
+ } else {
+ request = new AuthenticationRequestExploration(logonFixture);
+ }
+ session = IsisContext.getAuthenticationManager().authenticate(request);
+
+ IsisContext.openSession(session);
+ getTransactionManager().startTransaction();
+
+ final Object test = createTest();
+ getServicesInjector().injectServicesInto(test);
+
+ final TestMethod testMethod = wrapMethod(method);
+ new MethodRoadie(test, testMethod, notifier, description).run();
+
+ getTransactionManager().endTransaction();
+
+ } catch (final InvocationTargetException e) {
+ testAborted(notifier, description, e.getCause());
+ getTransactionManager().abortTransaction();
+ return;
+ } catch (final Exception e) {
+ testAborted(notifier, description, e);
+ return;
+ } finally {
+ if (system != null) {
+ if (session != null) {
+ IsisContext.closeSession();
+ }
+ system.shutdown();
+ }
+ }
+ }
+
+ private void testAborted(final RunNotifier notifier, final Description description, final Throwable e) {
+ notifier.fireTestStarted(description);
+ notifier.fireTestFailure(new Failure(description, e));
+ notifier.fireTestFinished(description);
+ }
+
+ /**
+ * Taken from JMock's runner.
+ */
+ @Override
+ protected TestMethod wrapMethod(final Method method) {
+ return new TestMethod(method, getTestClass()) {
+ @Override
+ public void invoke(final Object testFixture) throws IllegalAccessException, InvocationTargetException {
+
+ super.invoke(testFixture);
+
+ if (mockeryField != null) {
+ mockeryOf(testFixture).assertIsSatisfied();
+ }
+ }
+ };
+ }
+
+ /**
+ * JMock code.
+ *
+ * @param test
+ * @return
+ */
+ protected Mockery mockeryOf(final Object test) {
+ if (mockeryField == null) {
+ return null;
+ }
+ try {
+ final Mockery mockery = (Mockery) mockeryField.get(test);
+ if (mockery == null) {
+ throw new IllegalStateException(String.format("Mockery named '%s' is null", mockeryField.getName()));
+ }
+ return mockery;
+ } catch (final IllegalAccessException e) {
+ throw new IllegalStateException(String.format("cannot get value of field %s", mockeryField.getName()), e);
+ }
+ }
+
+ /**
+ * Adapted from JMock code.
+ */
+ static Field findFieldAndMakeAccessible(final Class<?> testClass, final Class<?> clazz) throws InitializationError {
+ for (Class<?> c = testClass; c != Object.class; c = c.getSuperclass()) {
+ for (final Field field : c.getDeclaredFields()) {
+ if (clazz.isAssignableFrom(field.getType())) {
+ field.setAccessible(true);
+ return field;
+ }
+ }
+ }
+ return null;
+ }
+
+ // /////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // /////////////////////////////////////////////////////
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ private static ServicesInjectorSpi getServicesInjector() {
+ return getPersistenceSession().getServicesInjector();
+ }
+
+ private static IsisTransactionManager getTransactionManager() {
+ return getPersistenceSession().getTransactionManager();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
new file mode 100644
index 0000000..32ad6e0
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Persistor.java
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Persistor {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
new file mode 100644
index 0000000..4e52531
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Service.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Service {
+ Class<?> value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
new file mode 100644
index 0000000..f4290d5
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/Services.java
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.TYPE)
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Services {
+ Service[] value();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
new file mode 100644
index 0000000..151de42
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/AnnotationInstaller.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+package org.apache.isis.core.integtestsupport.legacy.components;
+
+import org.apache.isis.core.integtestsupport.legacy.Authenticator;
+import org.apache.isis.core.integtestsupport.legacy.Authorizor;
+import org.apache.isis.core.integtestsupport.legacy.Persistor;
+import org.apache.isis.core.runtime.authentication.AuthenticationManagerInstaller;
+import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
+import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
+import org.apache.isis.core.security.authentication.BypassAuthenticationManagerInstaller;
+import org.apache.isis.core.security.authorization.BypassAuthorizationManagerInstaller;
+import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusPersistenceMechanismInstaller;
+
+public class AnnotationInstaller {
+
+ /**
+ * Should be called prior to installing; typically called immediately after
+ * instantiation.
+ *
+ * <p>
+ * Note: an alternative design would be to have a 1-arg constructor, but the
+ * convention for installers is to make them no-arg.
+ */
+ // {{ AuthenticationManagerInstaller
+ public AuthenticationManagerInstaller addAuthenticatorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final Authenticator authenticatorAnnotation = javaClass.getAnnotation(Authenticator.class);
+ if (authenticatorAnnotation != null) {
+ return addAuthenticatorRepresentedBy(authenticatorAnnotation);
+ } else {
+ return new BypassAuthenticationManagerInstaller();
+ }
+
+ }
+
+ private AuthenticationManagerInstaller addAuthenticatorRepresentedBy(final Authenticator authenticatorAnnotation) throws InstantiationException, IllegalAccessException {
+ final Class<?> fixtureClass = authenticatorAnnotation.value();
+ return (AuthenticationManagerInstaller) fixtureClass.newInstance();
+ }
+
+ // }}
+
+ // {{ AuthorizationManagerInstaller
+ public AuthorizationManagerInstaller addAuthorizerAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final Authorizor authorizorAnnotation = javaClass.getAnnotation(Authorizor.class);
+ if (authorizorAnnotation != null) {
+ return addAuthorizerRepresentedBy(authorizorAnnotation);
+ } else {
+ return new BypassAuthorizationManagerInstaller();
+ }
+
+ }
+
+ private AuthorizationManagerInstaller addAuthorizerRepresentedBy(final Authorizor authorizorAnnotation) throws InstantiationException, IllegalAccessException {
+ final Class<?> fixtureClass = authorizorAnnotation.value();
+ return (AuthorizationManagerInstaller) fixtureClass.newInstance();
+ }
+
+ // }}
+
+ // {{ PersistenceMechanismInstaller
+ public PersistenceMechanismInstaller addPersistorAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final Persistor annotation = javaClass.getAnnotation(Persistor.class);
+ return annotation != null
+ ? addPersistorRepresentedBy(annotation)
+ : new DataNucleusPersistenceMechanismInstaller();
+
+ }
+
+ private PersistenceMechanismInstaller addPersistorRepresentedBy(
+ final Persistor annotation)
+ throws InstantiationException, IllegalAccessException {
+ final Class<?> fixtureClass = annotation.value();
+ return (PersistenceMechanismInstaller) fixtureClass.newInstance();
+ }
+ // }}
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
new file mode 100644
index 0000000..43b30ed
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/FixtureInstallerAnnotatedClass.java
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy.components;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.core.integtestsupport.legacy.Fixture;
+import org.apache.isis.core.integtestsupport.legacy.Fixtures;
+import org.apache.isis.core.runtime.fixtures.FixturesInstallerAbstract;
+import org.apache.isis.core.runtime.fixtures.FixturesInstallerDelegate;
+
+public class FixtureInstallerAnnotatedClass extends FixturesInstallerAbstract {
+
+ private final List<Object> fixtures = new ArrayList<Object>();
+
+ /**
+ * @see #addFixturesAnnotatedOn(Class)
+ */
+ public FixtureInstallerAnnotatedClass() {
+ super("annotated");
+ }
+
+ // ///////////////////////////////////////////
+ // Hook method
+ // ///////////////////////////////////////////
+
+ /**
+ * Just copies the fixtures added using
+ * {@link #addFixturesAnnotatedOn(Class)} into the delegate.
+ */
+ @Override
+ protected void addFixturesTo(final FixturesInstallerDelegate delegate) {
+ for (final Object fixture : fixtures) {
+ delegate.addFixture(fixture);
+ }
+ }
+
+ // ///////////////////////////////////////////
+ // addFixturesAnnotatedOn (not API)
+ // ///////////////////////////////////////////
+
+ /**
+ * Should be called prior to installing; typically called immediately after
+ * instantiation.
+ *
+ * <p>
+ * Note: an alternative design would be to have a 1-arg constructor, but the
+ * convention for installers is to make them no-arg.
+ */
+ public void addFixturesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final Fixtures fixturesAnnotation = javaClass.getAnnotation(Fixtures.class);
+ if (fixturesAnnotation != null) {
+ final Fixture[] fixtureAnnotations = fixturesAnnotation.value();
+ for (final Fixture fixtureAnnotation : fixtureAnnotations) {
+ addFixtureRepresentedBy(fixtureAnnotation, fixtures);
+ }
+ }
+
+ final Fixture fixtureAnnotation = javaClass.getAnnotation(Fixture.class);
+ if (fixtureAnnotation != null) {
+ addFixtureRepresentedBy(fixtureAnnotation, fixtures);
+ }
+ }
+
+ private void addFixtureRepresentedBy(final Fixture fixtureAnnotation, final List<Object> fixtures) throws InstantiationException, IllegalAccessException {
+ final Class<?> fixtureClass = fixtureAnnotation.value();
+ fixtures.add(fixtureClass.newInstance());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
new file mode 100644
index 0000000..b4bbc87
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/IsisSystemUsingInstallersWithinJunit.java
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy.components;
+
+import org.junit.internal.runners.TestClass;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.core.runtime.system.DeploymentType;
+import org.apache.isis.core.runtime.systemusinginstallers.IsisSystemUsingInstallers;
+
+public class IsisSystemUsingInstallersWithinJunit extends IsisSystemUsingInstallers {
+
+ private final TestClass testClass;
+
+ public IsisSystemUsingInstallersWithinJunit(final DeploymentType deploymentType, final InstallerLookup installerLookup, final TestClass testClass) {
+ super(deploymentType, installerLookup);
+ installerLookup.getConfigurationBuilder().add("isis.deploymentType", deploymentType.nameLowerCase());
+
+ this.testClass = testClass;
+
+ final AnnotationInstaller installer = new AnnotationInstaller();
+
+ try {
+ setAuthenticationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthenticatorAnnotatedOn(this.testClass.getJavaClass())));
+
+ setAuthorizationInstaller(getInstallerLookup().injectDependenciesInto(installer.addAuthorizerAnnotatedOn(this.testClass.getJavaClass())));
+
+ setPersistenceMechanismInstaller(getInstallerLookup().injectDependenciesInto(installer.addPersistorAnnotatedOn(this.testClass.getJavaClass())));
+
+ // fixture installer
+ final FixtureInstallerAnnotatedClass fixtureInstaller = new FixtureInstallerAnnotatedClass();
+ fixtureInstaller.addFixturesAnnotatedOn(this.testClass.getJavaClass());
+ setFixtureInstaller(fixtureInstaller);
+ } catch (final InstantiationException e) {
+ throw new IsisException(e);
+ } catch (final IllegalAccessException e) {
+ throw new IsisException(e);
+ }
+
+ // services installer
+ final ServicesInstallerAnnotatedClass servicesInstaller = new ServicesInstallerAnnotatedClass();
+ try {
+ servicesInstaller.addServicesAnnotatedOn(this.testClass.getJavaClass());
+ } catch (final InstantiationException e) {
+ throw new IsisException(e);
+ } catch (final IllegalAccessException e) {
+ throw new IsisException(e);
+ }
+ setServicesInstaller(servicesInstaller);
+ }
+
+ public TestClass getTestClass() {
+ return testClass;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/6549e1eb/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
----------------------------------------------------------------------
diff --git a/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
new file mode 100644
index 0000000..3d6fec2
--- /dev/null
+++ b/mothballed/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/legacy/components/ServicesInstallerAnnotatedClass.java
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+package org.apache.isis.core.integtestsupport.legacy.components;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.core.integtestsupport.legacy.Service;
+import org.apache.isis.core.integtestsupport.legacy.Services;
+import org.apache.isis.core.metamodel.services.container.DomainObjectContainerDefault;
+import org.apache.isis.core.runtime.services.ServicesInstallerAbstract;
+
+public class ServicesInstallerAnnotatedClass extends ServicesInstallerAbstract {
+
+ public ServicesInstallerAnnotatedClass() {
+ super("annotated");
+ }
+
+ public void addServicesAnnotatedOn(final Class<?> javaClass) throws InstantiationException, IllegalAccessException {
+ final List<Object> services = new ArrayList<Object>();
+ addServicesAnnotatedOn(javaClass, services);
+
+ final DomainObjectContainer doc = lookupContainerIn(services);
+ if(doc == null) {
+ services.add(new DomainObjectContainerDefault());
+ }
+
+ addServices(services);
+
+ }
+
+ private static DomainObjectContainer lookupContainerIn(List<Object> services1) {
+ for (Object service : services1) {
+ if(service instanceof DomainObjectContainer) {
+ return (DomainObjectContainer) service;
+ }
+ }
+ return null;
+ }
+
+
+ private void addServicesAnnotatedOn(final Class<?> testClass, final List<Object> services) throws InstantiationException, IllegalAccessException {
+ final Services servicesAnnotation = testClass.getAnnotation(Services.class);
+ if (servicesAnnotation != null) {
+ final Service[] serviceAnnotations = servicesAnnotation.value();
+ for (final Service serviceAnnotation : serviceAnnotations) {
+ addServiceRepresentedBy(serviceAnnotation, services);
+ }
+ }
+
+ final Service serviceAnnotation = testClass.getAnnotation(Service.class);
+ if (serviceAnnotation != null) {
+ addServiceRepresentedBy(serviceAnnotation, services);
+ }
+ }
+
+ private void addServiceRepresentedBy(final Service serviceAnnotation, final List<Object> services) throws InstantiationException, IllegalAccessException {
+ final Class<?> serviceClass = serviceAnnotation.value();
+ // there's no need to unravel any Collections of services,
+ // because the ServiceLoader will do it for us later.
+ services.add(serviceClass.newInstance());
+ }
+
+ @Override
+ public List<Class<?>> getTypes() {
+ return listOf(List.class); // ie List<Object.class>, of services
+ }
+
+ @Override
+ public void setIgnoreFailures(boolean ignoreFailures) {
+ // no-op
+ }
+}
[2/2] isis git commit: ISIS-1188: removed
IsisSystemFixturesHookAbstract (collapsed down into IsisSystemAbstract).
Posted by da...@apache.org.
ISIS-1188: removed IsisSystemFixturesHookAbstract (collapsed down into IsisSystemAbstract).
Also deprecated DebugSelection interface; no longer used.
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/a930c1da
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/a930c1da
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/a930c1da
Branch: refs/heads/master
Commit: a930c1da1e3ec9e9d6aadf58856524d0a8a420a0
Parents: 6549e1e
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Wed Aug 5 07:38:20 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Wed Aug 5 07:39:34 2015 +0100
----------------------------------------------------------------------
.../integtestsupport/IsisSystemDefault.java | 16 -
.../core/runtime/system/DebugSelection.java | 3 +
.../system/IsisSystemFixturesHookAbstract.java | 469 -------------------
.../IsisSystemAbstract.java | 366 ++++++++++++---
.../IsisSystemUsingInstallers.java | 64 +--
5 files changed, 311 insertions(+), 607 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/a930c1da/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java
----------------------------------------------------------------------
diff --git a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java
index 7a1bae9..4c7b875 100644
--- a/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java
+++ b/core/integtestsupport/src/main/java/org/apache/isis/core/integtestsupport/IsisSystemDefault.java
@@ -61,28 +61,12 @@ public class IsisSystemDefault extends IsisSystemAbstract {
private final IsisConfigurationDefault configuration;
private final List<Object> servicesIfAny;
- public IsisSystemDefault(Object... servicesIfAny) {
- this(DeploymentType.SERVER, servicesIfAny);
- }
-
- public IsisSystemDefault(List<Object> services) {
- this(DeploymentType.SERVER, services);
- }
-
- public IsisSystemDefault(DeploymentType deploymentType, Object... servicesIfAny) {
- this(deploymentType, asList(servicesIfAny));
- }
-
public IsisSystemDefault(DeploymentType deploymentType, List<Object> services) {
super(deploymentType);
this.configuration = new IsisConfigurationDefault(ResourceStreamSourceContextLoaderClassPath.create("config"));
this.servicesIfAny = services;
}
- private static List<Object> asList(Object... objects) {
- return objects != null? Collections.unmodifiableList(Lists.newArrayList(objects)): null;
- }
-
/**
* Reads <tt>isis.properties</tt> (and other optional property files) from the "config" package on the current classpath.
*/
http://git-wip-us.apache.org/repos/asf/isis/blob/a930c1da/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DebugSelection.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DebugSelection.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DebugSelection.java
index 153a9d5..543592b 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DebugSelection.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/DebugSelection.java
@@ -24,7 +24,10 @@ import org.apache.isis.core.commons.debug.DebuggableWithTitle;
/**
* Provides a mechanism for providing a series of DebugInfo objects, keyed on
* name.
+ *
+ * @deprecated
*/
+@Deprecated
public interface DebugSelection {
DebuggableWithTitle debugSection(String sectionName);
http://git-wip-us.apache.org/repos/asf/isis/blob/a930c1da/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystemFixturesHookAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystemFixturesHookAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystemFixturesHookAbstract.java
deleted file mode 100644
index 799bc96..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/IsisSystemFixturesHookAbstract.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.isis.core.runtime.system;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.fixtures.LogonFixture;
-import org.apache.isis.core.commons.config.IsisConfiguration;
-import org.apache.isis.core.commons.debug.DebugBuilder;
-import org.apache.isis.core.commons.debug.DebuggableWithTitle;
-import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
-import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
-import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
-import org.apache.isis.core.metamodel.specloader.ServiceInitializer;
-import org.apache.isis.core.runtime.about.AboutIsis;
-import org.apache.isis.core.runtime.authentication.AuthenticationManager;
-import org.apache.isis.core.runtime.authentication.exploration.ExplorationSession;
-import org.apache.isis.core.runtime.authorization.AuthorizationManager;
-import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
-import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.internal.InitialisationSession;
-import org.apache.isis.core.runtime.system.internal.IsisLocaleInitializer;
-import org.apache.isis.core.runtime.system.internal.IsisTimeZoneInitializer;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
-import org.apache.isis.core.runtime.system.session.IsisSession;
-import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManagerException;
-
-/**
- * An implementation of {@link IsisSystem} that has a hook for installing
- * fixtures but does not install them itself.
- */
-public abstract class IsisSystemFixturesHookAbstract implements IsisSystem {
-
- public static final Logger LOG = LoggerFactory.getLogger(IsisSystemFixturesHookAbstract.class);
-
- private final IsisLocaleInitializer localeInitializer;
- private final IsisTimeZoneInitializer timeZoneInitializer;
- private final DeploymentType deploymentType;
-
- private boolean initialized = false;
-
- private IsisSessionFactory sessionFactory;
-
- private ServiceInitializer serviceInitializer;
-
- // ///////////////////////////////////////////
- // Constructors
- // ///////////////////////////////////////////
-
- public IsisSystemFixturesHookAbstract(final DeploymentType deploymentType) {
- this(deploymentType, new IsisLocaleInitializer(), new IsisTimeZoneInitializer());
- }
-
- public IsisSystemFixturesHookAbstract(final DeploymentType deploymentType, final IsisLocaleInitializer localeInitializer, final IsisTimeZoneInitializer timeZoneInitializer) {
- this.deploymentType = deploymentType;
- this.localeInitializer = localeInitializer;
- this.timeZoneInitializer = timeZoneInitializer;
- }
-
- // ///////////////////////////////////////////
- // DeploymentType
- // ///////////////////////////////////////////
-
- @Override
- public DeploymentType getDeploymentType() {
- return deploymentType;
- }
-
- // ///////////////////////////////////////////
- // init, shutdown
- // ///////////////////////////////////////////
-
- @Override
- public void init() {
-
- if (initialized) {
- throw new IllegalStateException("Already initialized");
- } else {
- initialized = true;
- }
-
- LOG.info("initialising Isis System");
- LOG.info("working directory: " + new File(".").getAbsolutePath());
- LOG.info("resource stream source: " + getConfiguration().getResourceStreamSource());
-
- localeInitializer.initLocale(getConfiguration());
- timeZoneInitializer.initTimeZone(getConfiguration());
-
- try {
- sessionFactory = doCreateSessionFactory(deploymentType);
-
- // temporarily make a configuration available
- // REVIEW: would rather inject this, or perhaps even the
- // ConfigurationBuilder
- IsisContext.setConfiguration(getConfiguration());
-
- initContext(sessionFactory);
- sessionFactory.init();
-
- // validate here after all entities have been registered in the persistence session factory
- final SpecificationLoaderSpi specificationLoader = sessionFactory.getSpecificationLoader();
- specificationLoader.validateAndAssert();
-
- serviceInitializer = initializeServices();
-
- installFixturesIfRequired();
-
- translateServicesAndEnumConstants();
-
- } catch (final IsisSystemException ex) {
- LOG.error("failed to initialise", ex);
- throw new RuntimeException(ex);
- }
- }
-
- private void initContext(final IsisSessionFactory sessionFactory) {
- getDeploymentType().initContext(sessionFactory);
- }
-
- /**
- * @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)
- IsisContext.openSession(new InitialisationSession());
- try {
- getTransactionManager().startTransaction();
- try {
- serviceInitializer.postConstruct();
-
- return serviceInitializer;
- } catch(RuntimeException ex) {
- getTransactionManager().getTransaction().setAbortCause(new IsisTransactionManagerException(ex));
- return serviceInitializer;
- } finally {
- // will commit or abort
- getTransactionManager().endTransaction();
- }
- } finally {
- IsisContext.closeSession();
- }
- }
-
- /**
- * The act of invoking titleOf(...) will cause translations to be requested.
- */
- private void translateServicesAndEnumConstants() {
- IsisContext.openSession(new InitialisationSession());
- try {
- final List<Object> services = sessionFactory.getServices();
- final DomainObjectContainer container = lookupService(DomainObjectContainer.class);
- for (Object service : services) {
- final String unused = container.titleOf(service);
- }
- for (final ObjectSpecification objSpec : allSpecifications()) {
- final Class<?> correspondingClass = objSpec.getCorrespondingClass();
- if(correspondingClass.isEnum()) {
- final Object[] enumConstants = correspondingClass.getEnumConstants();
- for (Object enumConstant : enumConstants) {
- final String unused = container.titleOf(enumConstant);
- }
- }
- }
- } finally {
- IsisContext.closeSession();
- }
-
- }
-
- private <T> T lookupService(final Class<T> serviceClass) {
- return getServicesInjector().lookupService(serviceClass);
- }
-
- private ServicesInjectorSpi getServicesInjector() {
- return getPersistenceSession().getServicesInjector();
- }
-
- private PersistenceSession getPersistenceSession() {
- return IsisContext.getPersistenceSession();
- }
-
- Collection<ObjectSpecification> allSpecifications() {
- return IsisContext.getSpecificationLoader().allSpecifications();
- }
-
- @Override
- public void shutdown() {
- LOG.info("shutting down system");
-
- shutdownServices(this.serviceInitializer);
-
- IsisContext.closeAllSessions();
- }
-
- /**
- * @see #initializeServices()
- */
- private void shutdownServices(final ServiceInitializer serviceInitializer) {
-
- // call @PostDestroy (in a session)
- IsisContext.openSession(new InitialisationSession());
- try {
- getTransactionManager().startTransaction();
- try {
- serviceInitializer.preDestroy();
-
- } catch(RuntimeException ex) {
- getTransactionManager().getTransaction().setAbortCause(new IsisTransactionManagerException(ex));
- } finally {
- // will commit or abort
- getTransactionManager().endTransaction();
- }
- } finally {
- IsisContext.closeSession();
- }
- }
-
- // ///////////////////////////////////////////
- // Hook:
- // ///////////////////////////////////////////
-
- /**
- * Hook method; the returned implementation is expected to use the same
- * general approach as the subclass itself.
- *
- * <p>
- * So, for example, <tt>IsisSystemUsingInstallers</tt> uses the
- * {@link InstallerLookup} mechanism to find its components. The
- * corresponding <tt>ExecutionContextFactoryUsingInstallers</tt> object
- * returned by this method should use {@link InstallerLookup} likewise.
- */
- protected abstract IsisSessionFactory doCreateSessionFactory(final DeploymentType deploymentType) throws IsisSystemException;
-
-
- // ///////////////////////////////////////////
- // Configuration
- // ///////////////////////////////////////////
-
- /**
- * Populated after {@link #init()}.
- */
- @Override
- public IsisSessionFactory getSessionFactory() {
- return sessionFactory;
- }
-
- // ///////////////////////////////////////////
- // Configuration
- // ///////////////////////////////////////////
-
- @Override
- public abstract IsisConfiguration getConfiguration();
-
-
- // ///////////////////////////////////////////
- // OidMarshaller
- // ///////////////////////////////////////////
-
- /**
- * Just returns a {@link OidMarshaller}; subclasses may override if
- * required.
- */
- protected OidMarshaller obtainOidMarshaller() {
- return new OidMarshaller();
- }
-
- // ///////////////////////////////////////////
- // Reflector
- // ///////////////////////////////////////////
-
- protected abstract SpecificationLoaderSpi obtainSpecificationLoaderSpi(DeploymentType deploymentType, Collection<MetaModelRefiner> metaModelRefiners) throws IsisSystemException;
-
- // ///////////////////////////////////////////
- // PersistenceSessionFactory
- // ///////////////////////////////////////////
-
- protected abstract PersistenceSessionFactory obtainPersistenceSessionFactory(DeploymentType deploymentType, final List<Object> services) throws IsisSystemException;
-
- // ///////////////////////////////////////////
- // Fixtures (hooks)
- // ///////////////////////////////////////////
-
- /**
- * Optional hook for appending debug information pertaining to fixtures
- * installer if required.
- */
- protected void appendFixturesInstallerDebug(final DebugBuilder debug) {
- }
-
- /**
- * The {@link LogonFixture}, if any, obtained by running fixtures.
- *
- * <p>
- * Intended to be used when for {@link DeploymentType#SERVER_EXPLORATION
- * exploration} (instead of an {@link ExplorationSession}) or
- * {@link DeploymentType#SERVER_PROTOTYPE prototype} deployments (saves logging
- * in). Should be <i>ignored</i> in other {@link DeploymentType}s.
- *
- * <p>
- * This implementation always returns <tt>null</tt>.
- */
- @Override
- public LogonFixture getLogonFixture() {
- return null;
- }
-
- /**
- * Optional hook for installing fixtures.
- *
- * <p>
- * This implementation does nothing.
- */
- protected void installFixturesIfRequired() throws IsisSystemException {
- }
-
- // ///////////////////////////////////////////
- // Authentication & Authorization Manager
- // ///////////////////////////////////////////
-
- protected abstract AuthenticationManager obtainAuthenticationManager(DeploymentType deploymentType) throws IsisSystemException;
-
- protected abstract AuthorizationManager obtainAuthorizationManager(final DeploymentType deploymentType);
-
- // ///////////////////////////////////////////
- // Services
- // ///////////////////////////////////////////
-
- protected abstract List<Object> obtainServices();
-
-
- // ///////////////////////////////////////////
- // debugging
- // ///////////////////////////////////////////
-
- private void debug(final DebugBuilder debug, final Object object) {
- if (object instanceof DebuggableWithTitle) {
- final DebuggableWithTitle d = (DebuggableWithTitle) object;
- debug.appendTitle(d.debugTitle());
- d.debugData(debug);
- } else {
- debug.appendln(object.toString());
- debug.appendln("... no further debug information");
- }
- }
-
- @Override
- public DebuggableWithTitle debugSection(final String selectionName) {
- // DebugInfo deb;
- if (selectionName.equals("Configuration")) {
- return getConfiguration();
- } /*
- * else if (selectionName.equals("Overview")) { debugOverview(debug);
- * } else if (selectionName.equals("Authenticator")) { deb =
- * IsisContext.getAuthenticationManager(); } else if
- * (selectionName.equals("Reflector")) { deb =
- * IsisContext.getSpecificationLoader(); } else if
- * (selectionName.equals("Contexts")) { deb =
- * debugListContexts(debug); } else { deb =
- * debugDisplayContext(selectionName, debug); }
- */
- return null;
- }
-
- private void debugDisplayContext(final String selector, final DebugBuilder debug) {
- final IsisSession d = IsisContext.getSession(selector);
- if (d != null) {
- d.debugAll(debug);
- } else {
- debug.appendln("No context: " + selector);
- }
- }
-
- private void debugListContexts(final DebugBuilder debug) {
- final String[] contextIds = IsisContext.getInstance().allSessionIds();
- for (final String contextId : contextIds) {
- debug.appendln(contextId);
- debug.appendln("-----");
- final IsisSession d = IsisContext.getSession(contextId);
- d.debug(debug);
- debug.appendln();
- }
- }
-
- @Override
- public String[] debugSectionNames() {
- final String[] general = new String[] { "Overview", "Authenticator", "Configuration", "Reflector", "Requests", "Contexts" };
- final String[] contextIds = IsisContext.getInstance().allSessionIds();
- final String[] combined = new String[general.length + contextIds.length];
- System.arraycopy(general, 0, combined, 0, general.length);
- System.arraycopy(contextIds, 0, combined, general.length, contextIds.length);
- return combined;
- }
-
- private void debugOverview(final DebugBuilder debug) {
- try {
- debug.appendln(AboutIsis.getFrameworkName());
- debug.appendln(AboutIsis.getFrameworkVersion());
- if (AboutIsis.getApplicationName() != null) {
- debug.appendln("application: " + AboutIsis.getApplicationName());
- }
- if (AboutIsis.getApplicationVersion() != null) {
- debug.appendln("version" + AboutIsis.getApplicationVersion());
- }
-
- final String user = System.getProperty("user.name");
- final String system = System.getProperty("os.name") + " (" + System.getProperty("os.arch") + ") " + System.getProperty("os.version");
- final String java = System.getProperty("java.vm.name") + " " + System.getProperty("java.vm.version");
- debug.appendln("user: " + user);
- debug.appendln("os: " + system);
- debug.appendln("java: " + java);
- debug.appendln("working directory: " + new File(".").getAbsolutePath());
-
- debug.appendTitle("System Installer");
- appendFixturesInstallerDebug(debug);
-
- debug.appendTitle("System Components");
- debug.appendln("Authentication manager", IsisContext.getAuthenticationManager().getClass().getName());
- debug.appendln("Configuration", getConfiguration().getClass().getName());
-
- final DebuggableWithTitle[] inf = IsisContext.debugSystem();
- for (final DebuggableWithTitle element : inf) {
- if (element != null) {
- element.debugData(debug);
- }
- }
- } catch (final RuntimeException e) {
- debug.appendException(e);
- }
- }
-
- IsisTransactionManager getTransactionManager() {
- return IsisContext.getTransactionManager();
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/a930c1da/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemAbstract.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemAbstract.java
index 9341c50..73e27bf 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemAbstract.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemAbstract.java
@@ -19,6 +19,7 @@
package org.apache.isis.core.runtime.systemusinginstallers;
+import java.io.File;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -26,6 +27,7 @@ import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.apache.isis.applib.DomainObjectContainer;
import org.apache.isis.applib.fixtures.LogonFixture;
import org.apache.isis.applib.fixturescripts.FixtureScripts;
import org.apache.isis.applib.services.fixturespec.FixtureScriptsDefault;
@@ -33,11 +35,14 @@ import org.apache.isis.core.commons.components.Installer;
import org.apache.isis.core.commons.components.Noop;
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
import org.apache.isis.core.commons.lang.ListExtensions;
import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.specloader.ServiceInitializer;
import org.apache.isis.core.runtime.authentication.AuthenticationManager;
import org.apache.isis.core.runtime.authentication.exploration.ExplorationSession;
import org.apache.isis.core.runtime.authorization.AuthorizationManager;
@@ -45,41 +50,184 @@ import org.apache.isis.core.runtime.fixtures.FixturesInstaller;
import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
import org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession;
import org.apache.isis.core.runtime.system.DeploymentType;
+import org.apache.isis.core.runtime.system.IsisSystem;
import org.apache.isis.core.runtime.system.IsisSystemException;
-import org.apache.isis.core.runtime.system.IsisSystemFixturesHookAbstract;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.internal.InitialisationSession;
import org.apache.isis.core.runtime.system.internal.IsisLocaleInitializer;
import org.apache.isis.core.runtime.system.internal.IsisTimeZoneInitializer;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
import org.apache.isis.core.runtime.system.session.IsisSessionFactory;
import org.apache.isis.core.runtime.system.session.IsisSessionFactoryDefault;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManagerException;
/**
*
*/
-public abstract class IsisSystemAbstract extends IsisSystemFixturesHookAbstract {
+public abstract class IsisSystemAbstract implements IsisSystem {
public static final Logger LOG = LoggerFactory.getLogger(IsisSystemAbstract.class);
- private FixturesInstaller fixtureInstaller;
- private LogonFixture logonFixture;
+ private final IsisLocaleInitializer localeInitializer;
+ private final IsisTimeZoneInitializer timeZoneInitializer;
+ private final DeploymentType deploymentType;
+
+ private boolean initialized = false;
- // ///////////////////////////////////////////
- // Constructors
- // ///////////////////////////////////////////
+ private ServiceInitializer serviceInitializer;
+ private FixturesInstaller fixtureInstaller;
+
+ //region > constructors
public IsisSystemAbstract(final DeploymentType deploymentType) {
this(deploymentType, new IsisLocaleInitializer(), new IsisTimeZoneInitializer());
}
public IsisSystemAbstract(final DeploymentType deploymentType, final IsisLocaleInitializer localeInitializer, final IsisTimeZoneInitializer timeZoneInitializer) {
- super(deploymentType, localeInitializer, timeZoneInitializer);
+ this.deploymentType = deploymentType;
+ this.localeInitializer = localeInitializer;
+ this.timeZoneInitializer = timeZoneInitializer;
}
+ //endregion
+ //region > deploymentType
@Override
- protected void installFixturesIfRequired() throws IsisSystemException {
+ public DeploymentType getDeploymentType() {
+ return deploymentType;
+ }
+
+ //endregion
+
+ //region > init
+
+ @Override
+ public void init() {
+
+ if (initialized) {
+ throw new IllegalStateException("Already initialized");
+ } else {
+ initialized = true;
+ }
+
+ LOG.info("initialising Isis System");
+ LOG.info("working directory: " + new File(".").getAbsolutePath());
+ LOG.info("resource stream source: " + getConfiguration().getResourceStreamSource());
+
+ localeInitializer.initLocale(getConfiguration());
+ timeZoneInitializer.initTimeZone(getConfiguration());
+
+ try {
+ sessionFactory = createSessionFactory(deploymentType);
+
+ // temporarily make a configuration available
+ // REVIEW: would rather inject this, or perhaps even the
+ // ConfigurationBuilder
+ IsisContext.setConfiguration(getConfiguration());
+
+ initContext(sessionFactory);
+ sessionFactory.init();
+
+ // validate here after all entities have been registered in the persistence session factory
+ final SpecificationLoaderSpi specificationLoader = sessionFactory.getSpecificationLoader();
+ specificationLoader.validateAndAssert();
+
+ serviceInitializer = initializeServices();
+
+ installFixturesIfRequired();
+
+ translateServicesAndEnumConstants();
+
+ } catch (final IsisSystemException ex) {
+ LOG.error("failed to initialise", ex);
+ throw new RuntimeException(ex);
+ }
+ }
+
+ //region > createSessionFactory
+
+ private IsisSessionFactory sessionFactory;
+
+ /**
+ * Populated after {@link #init()}.
+ */
+ @Override
+ public IsisSessionFactory getSessionFactory() {
+ return sessionFactory;
+ }
+
+ private IsisSessionFactory createSessionFactory(final DeploymentType deploymentType) throws IsisSystemException {
+ final List<Object> services = obtainServices();
+ final PersistenceSessionFactory persistenceSessionFactory =
+ obtainPersistenceSessionFactory(deploymentType, services);
+
+ final IsisConfiguration configuration = getConfiguration();
+ final AuthenticationManager authenticationManager = obtainAuthenticationManager(deploymentType);
+ final AuthorizationManager authorizationManager = obtainAuthorizationManager(deploymentType);
+ final OidMarshaller oidMarshaller = obtainOidMarshaller();
+
+ final Collection<MetaModelRefiner> metaModelRefiners =
+ refiners(authenticationManager, authorizationManager, persistenceSessionFactory);
+ final SpecificationLoaderSpi reflector = obtainSpecificationLoaderSpi(deploymentType, metaModelRefiners);
+
+ ServicesInjectorSpi servicesInjector = persistenceSessionFactory.getServicesInjector();
+ servicesInjector.addFallbackIfRequired(FixtureScripts.class, new FixtureScriptsDefault());
+ servicesInjector.validateServices();
+
+ // bind metamodel to the (runtime) framework
+ final RuntimeContextFromSession runtimeContext = obtainRuntimeContextFromSession();
+ runtimeContext.injectInto(reflector);
+
+ return new IsisSessionFactoryDefault(
+ deploymentType, configuration, reflector,
+ authenticationManager, authorizationManager,
+ persistenceSessionFactory, oidMarshaller);
+ }
+
+ private static Collection<MetaModelRefiner> refiners(Object... possibleRefiners ) {
+ return ListExtensions.filtered(Arrays.asList(possibleRefiners), MetaModelRefiner.class);
+ }
+ //endregion
+
+
+ private void initContext(final IsisSessionFactory sessionFactory) {
+ getDeploymentType().initContext(sessionFactory);
+ }
+
+ /**
+ * @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)
+ IsisContext.openSession(new InitialisationSession());
+ try {
+ getTransactionManager().startTransaction();
+ try {
+ serviceInitializer.postConstruct();
+
+ return serviceInitializer;
+ } catch(RuntimeException ex) {
+ getTransactionManager().getTransaction().setAbortCause(new IsisTransactionManagerException(ex));
+ return serviceInitializer;
+ } finally {
+ // will commit or abort
+ getTransactionManager().endTransaction();
+ }
+ } finally {
+ IsisContext.closeSession();
+ }
+ }
+
+ private void installFixturesIfRequired() throws IsisSystemException {
fixtureInstaller = obtainFixturesInstaller();
if (isNoop(fixtureInstaller)) {
@@ -103,15 +251,75 @@ public abstract class IsisSystemAbstract extends IsisSystemFixturesHookAbstract
return candidate == null || (fixtureInstaller instanceof Noop);
}
- // ///////////////////////////////////////////
- // Fixtures
- // ///////////////////////////////////////////
+ /**
+ * The act of invoking titleOf(...) will cause translations to be requested.
+ */
+ private void translateServicesAndEnumConstants() {
+ IsisContext.openSession(new InitialisationSession());
+ try {
+ final List<Object> services = sessionFactory.getServices();
+ final DomainObjectContainer container = lookupService(DomainObjectContainer.class);
+ for (Object service : services) {
+ final String unused = container.titleOf(service);
+ }
+ for (final ObjectSpecification objSpec : allSpecifications()) {
+ final Class<?> correspondingClass = objSpec.getCorrespondingClass();
+ if(correspondingClass.isEnum()) {
+ final Object[] enumConstants = correspondingClass.getEnumConstants();
+ for (Object enumConstant : enumConstants) {
+ final String unused = container.titleOf(enumConstant);
+ }
+ }
+ }
+ } finally {
+ IsisContext.closeSession();
+ }
+
+ }
+
+ private <T> T lookupService(final Class<T> serviceClass) {
+ return getServicesInjector().lookupService(serviceClass);
+ }
+
+ private ServicesInjectorSpi getServicesInjector() {
+ return getPersistenceSession().getServicesInjector();
+ }
+
+ private PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+ Collection<ObjectSpecification> allSpecifications() {
+ return IsisContext.getSpecificationLoader().allSpecifications();
+ }
+
+ //endregion
+
+ //region > obtainXxx: specificationLoaderSpi, persistenceSessionFactory, oidMarshaller, runtimeContextFromSession, authenticationManager authorizationManager, services, fixturesInstaller
+
+ protected abstract SpecificationLoaderSpi obtainSpecificationLoaderSpi(DeploymentType deploymentType, Collection<MetaModelRefiner> metaModelRefiners) throws IsisSystemException;
+
+ protected abstract PersistenceSessionFactory obtainPersistenceSessionFactory(DeploymentType deploymentType, final List<Object> services) throws IsisSystemException;
+
+ protected OidMarshaller obtainOidMarshaller() {
+ return new OidMarshaller();
+ }
+
+ protected RuntimeContextFromSession obtainRuntimeContextFromSession() {
+ return new RuntimeContextFromSession();
+ }
+
+ protected abstract AuthenticationManager obtainAuthenticationManager(DeploymentType deploymentType) throws IsisSystemException;
+
+ protected abstract AuthorizationManager obtainAuthorizationManager(final DeploymentType deploymentType);
+
+ protected abstract List<Object> obtainServices();
/**
* This is the only {@link Installer} that is used by any (all) subclass
* implementations, because it effectively <i>is</i> the component we need
* (as opposed to a builder/factory of the component we need).
- *
+ *
* <p>
* The fact that the component <i>is</i> an installer (and therefore can be
* {@link InstallerLookup} looked up} is at this level really just an
@@ -120,17 +328,56 @@ public abstract class IsisSystemAbstract extends IsisSystemFixturesHookAbstract
*/
protected abstract FixturesInstaller obtainFixturesInstaller() throws IsisSystemException;
- // ///////////////////////////////////////////
- // Fixtures Installer
- // ///////////////////////////////////////////
- public FixturesInstaller getFixturesInstaller() {
- return fixtureInstaller;
+ //endregion
+
+ //region > shutdown
+
+ @Override
+ public void shutdown() {
+ LOG.info("shutting down system");
+
+ shutdownServices(this.serviceInitializer);
+
+ IsisContext.closeAllSessions();
}
/**
+ * @see #initializeServices()
+ */
+ private void shutdownServices(final ServiceInitializer serviceInitializer) {
+
+ // call @PostDestroy (in a session)
+ IsisContext.openSession(new InitialisationSession());
+ try {
+ getTransactionManager().startTransaction();
+ try {
+ serviceInitializer.preDestroy();
+
+ } catch(RuntimeException ex) {
+ getTransactionManager().getTransaction().setAbortCause(new IsisTransactionManagerException(ex));
+ } finally {
+ // will commit or abort
+ getTransactionManager().endTransaction();
+ }
+ } finally {
+ IsisContext.closeSession();
+ }
+ }
+
+ //endregion
+
+ //region > configuration
+ @Override
+ public abstract IsisConfiguration getConfiguration();
+ //endregion
+
+ //region > logonFixture
+ private LogonFixture logonFixture;
+
+ /**
* The {@link LogonFixture}, if any, obtained by running fixtures.
- *
+ *
* <p>
* Intended to be used when for {@link DeploymentType#SERVER_EXPLORATION
* exploration} (instead of an {@link ExplorationSession}) or
@@ -141,68 +388,45 @@ public abstract class IsisSystemAbstract extends IsisSystemFixturesHookAbstract
public LogonFixture getLogonFixture() {
return logonFixture;
}
+ //endregion
- @Override
- protected void appendFixturesInstallerDebug(final DebugBuilder debug) {
- debug.appendln("Fixture Installer", fixtureInstaller == null ? "none" : fixtureInstaller.getClass().getName());
- }
-
+ //region > debugging
- // ///////////////////////////////////////////
- // Session Factory
- // ///////////////////////////////////////////
+ private void debug(final DebugBuilder debug, final Object object) {
+ if (object instanceof DebuggableWithTitle) {
+ final DebuggableWithTitle d = (DebuggableWithTitle) object;
+ debug.appendTitle(d.debugTitle());
+ d.debugData(debug);
+ } else {
+ debug.appendln(object.toString());
+ debug.appendln("... no further debug information");
+ }
+ }
@Override
- public IsisSessionFactory doCreateSessionFactory(final DeploymentType deploymentType) throws IsisSystemException {
- final List<Object> services = obtainServices();
- final PersistenceSessionFactory persistenceSessionFactory = obtainPersistenceSessionFactory(deploymentType, services);
- return createSessionFactory(deploymentType, persistenceSessionFactory);
+ public DebuggableWithTitle debugSection(final String selectionName) {
+ // DebugInfo deb;
+ if (selectionName.equals("Configuration")) {
+ return getConfiguration();
+ }
+ return null;
}
- /**
- * Overloaded version designed to be called by subclasses that need to
- * explicitly specify different persistence mechanisms.
- *
- * <p>
- * This is <i>not</i> a hook method, rather it is designed to be called
- * <i>from</i> the {@link #doCreateSessionFactory(DeploymentType) hook
- * method}.
- */
- protected final IsisSessionFactory createSessionFactory(
- final DeploymentType deploymentType,
- final PersistenceSessionFactory persistenceSessionFactory) throws IsisSystemException {
-
- final IsisConfiguration configuration = getConfiguration();
- final AuthenticationManager authenticationManager = obtainAuthenticationManager(deploymentType);
- final AuthorizationManager authorizationManager = obtainAuthorizationManager(deploymentType);
- final OidMarshaller oidMarshaller = obtainOidMarshaller();
-
- final Collection<MetaModelRefiner> metaModelRefiners =
- refiners(authenticationManager, authorizationManager, persistenceSessionFactory);
- final SpecificationLoaderSpi reflector = obtainSpecificationLoaderSpi(deploymentType, metaModelRefiners);
-
- ServicesInjectorSpi servicesInjector = persistenceSessionFactory.getServicesInjector();
- servicesInjector.addFallbackIfRequired(FixtureScripts.class, new FixtureScriptsDefault());
- servicesInjector.validateServices();
-
- // bind metamodel to the (runtime) framework
- final RuntimeContextFromSession runtimeContext = obtainRuntimeContextFromSession();
- runtimeContext.injectInto(reflector);
-
- return new IsisSessionFactoryDefault(
- deploymentType, configuration, reflector,
- authenticationManager, authorizationManager,
- persistenceSessionFactory, oidMarshaller);
+ @Override
+ public String[] debugSectionNames() {
+ final String[] general = new String[] { "Overview", "Authenticator", "Configuration", "Reflector", "Requests", "Contexts" };
+ final String[] contextIds = IsisContext.getInstance().allSessionIds();
+ final String[] combined = new String[general.length + contextIds.length];
+ System.arraycopy(general, 0, combined, 0, general.length);
+ System.arraycopy(contextIds, 0, combined, general.length, contextIds.length);
+ return combined;
}
- protected RuntimeContextFromSession obtainRuntimeContextFromSession() {
- return new RuntimeContextFromSession();
+ IsisTransactionManager getTransactionManager() {
+ return IsisContext.getTransactionManager();
}
- private static Collection<MetaModelRefiner> refiners(Object... possibleRefiners ) {
- return ListExtensions.filtered(Arrays.asList(possibleRefiners), MetaModelRefiner.class);
- }
+ //endregion
-
}
http://git-wip-us.apache.org/repos/asf/isis/blob/a930c1da/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemUsingInstallers.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemUsingInstallers.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemUsingInstallers.java
index 46a046e..fa96621 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemUsingInstallers.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/systemusinginstallers/IsisSystemUsingInstallers.java
@@ -21,8 +21,10 @@ package org.apache.isis.core.runtime.systemusinginstallers;
import java.util.Collection;
import java.util.List;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import org.apache.isis.core.commons.config.IsisConfiguration;
import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
@@ -34,17 +36,18 @@ import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
import org.apache.isis.core.runtime.fixtures.FixturesInstaller;
import org.apache.isis.core.runtime.installerregistry.InstallerLookup;
import org.apache.isis.core.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
import org.apache.isis.core.runtime.services.ServicesInstaller;
import org.apache.isis.core.runtime.system.DeploymentType;
import org.apache.isis.core.runtime.system.IsisSystemException;
import org.apache.isis.core.runtime.system.SystemConstants;
-import org.apache.isis.core.runtime.systemdependencyinjector.SystemDependencyInjector;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSessionFactory;
import org.apache.isis.core.runtime.transaction.facetdecorator.standard.TransactionFacetDecoratorInstaller;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
-import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
public class IsisSystemUsingInstallers extends IsisSystemAbstract {
@@ -59,6 +62,7 @@ public class IsisSystemUsingInstallers extends IsisSystemAbstract {
private PersistenceMechanismInstaller persistenceMechanismInstaller;
private FixturesInstaller fixtureInstaller;
+
// ///////////////////////////////////////////
// Constructors
// ///////////////////////////////////////////
@@ -69,32 +73,18 @@ public class IsisSystemUsingInstallers extends IsisSystemAbstract {
this.installerLookup = installerLookup;
}
- // ///////////////////////////////////////////
- // InstallerLookup
- // ///////////////////////////////////////////
-
- /**
- * As per
- * {@link #IsisSystemUsingInstallers(DeploymentType, InstallerLookup)
- * constructor}.
- */
- public SystemDependencyInjector getInstallerLookup() {
- return installerLookup;
- }
-
- // ///////////////////////////////////////////
- // Create context hooks
- // ///////////////////////////////////////////
-
// ///////////////////////////////////////////
// Configuration
// ///////////////////////////////////////////
/**
- * Returns a <i>snapshot</i> of the {@link IsisConfiguration configuration}
- * held by the {@link #getInstallerLookup() installer lookup}.
- *
+ * Returns a <i>snapshot</i> of the {@link IsisConfiguration configuration}.
+ *
+ * <p>
+ * ... as held by the internal {@link InstallerLookup}.
+ * </p>
+ *
* @see InstallerLookup#getConfiguration()
*/
@Override
@@ -143,10 +133,6 @@ public class IsisSystemUsingInstallers extends IsisSystemAbstract {
return authorizationInstaller.createAuthorizationManager();
}
- // ///////////////////////////////////////////
- // Fixtures
- // ///////////////////////////////////////////
-
public void lookupAndSetFixturesInstaller() {
final IsisConfiguration configuration = installerLookup.getConfiguration();
final String fixture = configuration.getString(SystemConstants.FIXTURES_INSTALLER_KEY);
@@ -157,10 +143,6 @@ public class IsisSystemUsingInstallers extends IsisSystemAbstract {
}
}
- public void setFixtureInstaller(final FixturesInstaller fixtureInstaller) {
- this.fixtureInstaller = fixtureInstaller;
- }
-
@Override
protected FixturesInstaller obtainFixturesInstaller() throws IsisSystemException {
return fixtureInstaller;
@@ -170,10 +152,6 @@ public class IsisSystemUsingInstallers extends IsisSystemAbstract {
// Reflector
// ///////////////////////////////////////////
- public void setReflectorInstaller(final ObjectReflectorInstaller reflectorInstaller) {
- this.reflectorInstaller = reflectorInstaller;
- }
-
@Override
protected SpecificationLoaderSpi obtainSpecificationLoaderSpi(final DeploymentType deploymentType, final Collection<MetaModelRefiner> metaModelRefiners) throws IsisSystemException {
if (reflectorInstaller == null) {
@@ -188,14 +166,6 @@ public class IsisSystemUsingInstallers extends IsisSystemAbstract {
return reflectorInstaller.createReflector(metaModelRefiners);
}
- // ///////////////////////////////////////////
- // Container and Services
- // ///////////////////////////////////////////
-
- public void setServicesInstaller(final ServicesInstaller servicesInstaller) {
- this.servicesInstaller = servicesInstaller;
- }
-
@Override
protected List<Object> obtainServices() {
if (servicesInstaller == null) {
@@ -207,14 +177,6 @@ public class IsisSystemUsingInstallers extends IsisSystemAbstract {
}
- // ///////////////////////////////////////////
- // PersistenceSessionFactory
- // ///////////////////////////////////////////
-
- public void setPersistenceMechanismInstaller(final PersistenceMechanismInstaller persistenceMechanismInstaller) {
- this.persistenceMechanismInstaller = persistenceMechanismInstaller;
- }
-
@Override
protected PersistenceSessionFactory obtainPersistenceSessionFactory(final DeploymentType deploymentType, final List<Object> services) throws IsisSystemException {