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 2012/12/06 11:10:37 UTC
[43/51] [partial] ISIS-188: moving modules into core
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureAbstract.java
new file mode 100644
index 0000000..49d3578
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureAbstract.java
@@ -0,0 +1,49 @@
+/*
+ * 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.runtimes.dflt.runtime.system.transaction;
+
+
+/**
+ * Convenience adapter providing no-op implementations of {@link #onSuccess()}
+ * and {@link #onFailure()}.
+ */
+public abstract class TransactionalClosureAbstract implements TransactionalClosure {
+
+ /**
+ * No-op implementation; does nothing.
+ */
+ @Override
+ public void preExecute() {
+ }
+
+ /**
+ * No-op implementation; does nothing.
+ */
+ @Override
+ public void onSuccess() {
+ }
+
+ /**
+ * No-op implementation; does nothing.
+ */
+ @Override
+ public void onFailure() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureWithReturn.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureWithReturn.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureWithReturn.java
new file mode 100644
index 0000000..bbc1426
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureWithReturn.java
@@ -0,0 +1,31 @@
+/*
+ * 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.runtimes.dflt.runtime.system.transaction;
+
+public interface TransactionalClosureWithReturn<T> {
+
+ public void preExecute();
+
+ public T execute();
+
+ public void onSuccess();
+
+ public void onFailure();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
new file mode 100644
index 0000000..4473e6d
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/TransactionalClosureWithReturnAbstract.java
@@ -0,0 +1,49 @@
+/*
+ * 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.runtimes.dflt.runtime.system.transaction;
+
+
+/**
+ * Convenience adapter providing no-op implementations of {@link #onSuccess()}
+ * and {@link #onFailure()}.
+ */
+public abstract class TransactionalClosureWithReturnAbstract<T> implements TransactionalClosureWithReturn<T> {
+
+ /**
+ * No-op implementation; does nothing.
+ */
+ @Override
+ public void preExecute() {
+ }
+
+ /**
+ * No-op implementation; does nothing.
+ */
+ @Override
+ public void onSuccess() {
+ }
+
+ /**
+ * No-op implementation; does nothing.
+ */
+ @Override
+ public void onFailure() {
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/UpdateNotifier.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/UpdateNotifier.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/UpdateNotifier.java
new file mode 100644
index 0000000..f21ec7f
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/UpdateNotifier.java
@@ -0,0 +1,79 @@
+/*
+ * 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.runtimes.dflt.runtime.system.transaction;
+
+import java.util.List;
+
+import org.apache.isis.core.commons.components.TransactionScopedComponent;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+
+/**
+ * UpdateNotifier provides updates to client making available lists of the
+ * latest changed and disposed objects.
+ */
+public interface UpdateNotifier extends TransactionScopedComponent {
+
+ // //////////////////////////////////////////////////
+ // Changed Objects
+ // //////////////////////////////////////////////////
+
+ /**
+ * Used by the framework to add objects that have just changed.
+ */
+ void addChangedObject(ObjectAdapter object);
+
+ /**
+ * Returns an immutable {@link List} of changed objects.
+ *
+ * <p>
+ * Each changed object that was added is only ever provided during one call
+ * to this method so the list must be processed fully to avoid missing
+ * updates.
+ */
+ List<ObjectAdapter> getChangedObjects();
+
+ // //////////////////////////////////////////////////
+ // Disposed Objects
+ // //////////////////////////////////////////////////
+
+ /**
+ * Used by the framework to add objects that have just been disposed of.
+ */
+ void addDisposedObject(ObjectAdapter adapter);
+
+ /**
+ * Returns an immutable {@link List} of disposed objects.
+ *
+ * <p>
+ * Each object that was disposed of is only ever provided during one call to
+ * this method so the list must be processed fully to avoid missing
+ * deletions.
+ */
+ public List<ObjectAdapter> getDisposedObjects();
+
+ // //////////////////////////////////////////////////
+ // Empty, Clear
+ // //////////////////////////////////////////////////
+
+ void ensureEmpty();
+
+ void clear();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/UpdateNotifierDefault.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/UpdateNotifierDefault.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/UpdateNotifierDefault.java
new file mode 100644
index 0000000..4a7d260
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/system/transaction/UpdateNotifierDefault.java
@@ -0,0 +1,167 @@
+/*
+ * 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.runtimes.dflt.runtime.system.transaction;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.debug.DebugBuilder;
+import org.apache.isis.core.commons.debug.DebuggableWithTitle;
+import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+
+public class UpdateNotifierDefault implements UpdateNotifier, DebuggableWithTitle {
+
+ private static final Logger LOG = Logger.getLogger(UpdateNotifierDefault.class);
+
+ private final List<ObjectAdapter> changes = new ArrayList<ObjectAdapter>();
+ private final List<ObjectAdapter> disposals = new ArrayList<ObjectAdapter>();
+
+ // //////////////////////////////////////////////////
+ // Constructor
+ // //////////////////////////////////////////////////
+
+ public UpdateNotifierDefault() {
+ // does nothing
+ }
+
+ // //////////////////////////////////////////////////
+ // Changed Objects
+ // //////////////////////////////////////////////////
+
+ @Override
+ public synchronized void addChangedObject(final ObjectAdapter adapter) {
+ if (!adapter.isResolved() && !adapter.isTransient()) {
+ return;
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("mark as changed " + adapter);
+ }
+ if (!changes.contains(adapter)) {
+ changes.add(adapter);
+ }
+ }
+
+ @Override
+ public List<ObjectAdapter> getChangedObjects() {
+ if (changes.size() > 0) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("dirty (changed) objects " + changes);
+ }
+ }
+ final List<ObjectAdapter> changedObjects = new ArrayList<ObjectAdapter>();
+ changedObjects.addAll(changes);
+
+ changes.clear();
+
+ return Collections.unmodifiableList(changedObjects);
+ }
+
+ // //////////////////////////////////////////////////
+ // Disposed Objects
+ // //////////////////////////////////////////////////
+
+ @Override
+ public void addDisposedObject(final ObjectAdapter adapter) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("mark as disposed " + adapter);
+ }
+ if (!disposals.contains(adapter)) {
+ disposals.add(adapter);
+ }
+ }
+
+ @Override
+ public List<ObjectAdapter> getDisposedObjects() {
+ if (disposals.size() > 0) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("dirty (disposed) objects " + disposals);
+ }
+ }
+ final List<ObjectAdapter> disposedObjects = new ArrayList<ObjectAdapter>();
+ disposedObjects.addAll(disposals);
+
+ disposals.clear();
+
+ return Collections.unmodifiableList(disposedObjects);
+ }
+
+ // //////////////////////////////////////////////////
+ // Empty, Clear
+ // //////////////////////////////////////////////////
+
+ @Override
+ public void ensureEmpty() {
+ if (changes.size() > 0) {
+ throw new IsisException("Update notifier still has updates");
+ }
+ }
+
+ @Override
+ public void clear() {
+ changes.clear();
+ disposals.clear();
+ }
+
+ // //////////////////////////////////////////////////
+ // Debugging
+ // //////////////////////////////////////////////////
+
+ @Override
+ public void debugData(final DebugBuilder debug) {
+ debug.appendln("Changes");
+ debugList(debug, changes);
+
+ debug.appendln("Disposals");
+ debugList(debug, disposals);
+ }
+
+ @Override
+ public String debugTitle() {
+ return "Simple Update Notifier";
+ }
+
+ private void debugList(final DebugBuilder debug, final List<ObjectAdapter> list) {
+ debug.indent();
+ if (list.size() == 0) {
+ debug.appendln("none");
+ } else {
+ for (final ObjectAdapter adapter : list) {
+ debug.appendln(adapter.toString());
+ }
+ }
+ debug.unindent();
+ }
+
+ // //////////////////////////////////////////////////
+ // toString
+ // //////////////////////////////////////////////////
+
+ @Override
+ public String toString() {
+ return new ToString(this).append("changes", changes).toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemdependencyinjector/SystemDependencyInjector.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemdependencyinjector/SystemDependencyInjector.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemdependencyinjector/SystemDependencyInjector.java
new file mode 100644
index 0000000..3ed08ec
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemdependencyinjector/SystemDependencyInjector.java
@@ -0,0 +1,26 @@
+/**
+ * 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.runtimes.dflt.runtime.systemdependencyinjector;
+
+public interface SystemDependencyInjector {
+
+ /**
+ * Injects self into candidate
+ */
+ public abstract <T> T injectDependenciesInto(T candidate);
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemdependencyinjector/SystemDependencyInjectorAware.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemdependencyinjector/SystemDependencyInjectorAware.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemdependencyinjector/SystemDependencyInjectorAware.java
new file mode 100644
index 0000000..354e605
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemdependencyinjector/SystemDependencyInjectorAware.java
@@ -0,0 +1,25 @@
+/*
+ * 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.runtimes.dflt.runtime.systemdependencyinjector;
+
+public interface SystemDependencyInjectorAware {
+
+ void setSystemDependencyInjector(final SystemDependencyInjector dependencyInjector);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemAbstract.java
new file mode 100644
index 0000000..333cbaa
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemAbstract.java
@@ -0,0 +1,223 @@
+/*
+ * 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.runtimes.dflt.runtime.systemusinginstallers;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Lists;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.applib.fixtures.LogonFixture;
+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.lang.Types;
+import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.facetapi.ClassSubstitutorFactory;
+import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
+import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
+import org.apache.isis.core.metamodel.layout.MemberLayoutArranger;
+import org.apache.isis.core.metamodel.progmodel.ProgrammingModel;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.specloader.ObjectReflectorDefault;
+import org.apache.isis.core.metamodel.specloader.classsubstitutor.ClassSubstitutor;
+import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistry;
+import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistryDefault;
+import org.apache.isis.core.metamodel.specloader.traverser.SpecificationTraverser;
+import org.apache.isis.core.metamodel.specloader.traverser.SpecificationTraverserDefault;
+import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidator;
+import org.apache.isis.core.metamodel.specloader.validator.MetaModelValidatorComposite;
+import org.apache.isis.core.progmodel.layout.dflt.MemberLayoutArrangerDefault;
+import org.apache.isis.core.runtime.authentication.AuthenticationManager;
+import org.apache.isis.core.runtime.authorization.AuthorizationManager;
+import org.apache.isis.core.runtime.imageloader.TemplateImageLoader;
+import org.apache.isis.core.runtime.userprofile.UserProfileLoader;
+import org.apache.isis.runtimes.dflt.runtime.authentication.exploration.ExplorationSession;
+import org.apache.isis.runtimes.dflt.runtime.fixtures.FixturesInstaller;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.runtimes.dflt.runtime.persistence.internal.RuntimeContextFromSession;
+import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
+import org.apache.isis.runtimes.dflt.runtime.system.IsisSystemException;
+import org.apache.isis.runtimes.dflt.runtime.system.IsisSystemFixturesHookAbstract;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.internal.InitialisationSession;
+import org.apache.isis.runtimes.dflt.runtime.system.internal.IsisLocaleInitializer;
+import org.apache.isis.runtimes.dflt.runtime.system.internal.IsisTimeZoneInitializer;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionFactory;
+import org.apache.isis.runtimes.dflt.runtime.system.session.IsisSessionFactory;
+import org.apache.isis.runtimes.dflt.runtime.system.session.IsisSessionFactoryDefault;
+import org.apache.isis.runtimes.dflt.runtime.userprofile.UserProfileLoaderDefault;
+
+/**
+ *
+ */
+public abstract class IsisSystemAbstract extends IsisSystemFixturesHookAbstract {
+
+ public static final Logger LOG = Logger.getLogger(IsisSystemAbstract.class);
+
+ private FixturesInstaller fixtureInstaller;
+
+ private LogonFixture logonFixture;
+
+ // ///////////////////////////////////////////
+ // Constructors
+ // ///////////////////////////////////////////
+
+ public IsisSystemAbstract(final DeploymentType deploymentType) {
+ super(deploymentType, new IsisLocaleInitializer(), new IsisTimeZoneInitializer());
+ }
+
+ public IsisSystemAbstract(final DeploymentType deploymentType, final IsisLocaleInitializer localeInitializer, final IsisTimeZoneInitializer timeZoneInitializer) {
+ super(deploymentType, localeInitializer, timeZoneInitializer);
+ }
+
+ @Override
+ protected void installFixturesIfRequired() throws IsisSystemException {
+ // some deployment types (eg CLIENT) do not support installing fixtures
+ // instead, any fixtures should be installed when server boots up.
+ if (!getDeploymentType().canInstallFixtures()) {
+ return;
+ }
+
+ fixtureInstaller = obtainFixturesInstaller();
+ if (isNoop(fixtureInstaller)) {
+ return;
+ }
+
+ IsisContext.openSession(new InitialisationSession());
+ fixtureInstaller.installFixtures();
+ try {
+
+ // only allow logon fixtures if not in production mode.
+ if (!getDeploymentType().isProduction()) {
+ logonFixture = fixtureInstaller.getLogonFixture();
+ }
+ } finally {
+ IsisContext.closeSession();
+ }
+ }
+
+ private boolean isNoop(final FixturesInstaller candidate) {
+ return candidate == null || (fixtureInstaller instanceof Noop);
+ }
+
+ // ///////////////////////////////////////////
+ // Fixtures
+ // ///////////////////////////////////////////
+
+ /**
+ * 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
+ * incidental implementation detail useful for the subclass that uses
+ * {@link InstallerLookup} to create the other components.
+ */
+ protected abstract FixturesInstaller obtainFixturesInstaller() throws IsisSystemException;
+
+ // ///////////////////////////////////////////
+ // Fixtures Installer
+ // ///////////////////////////////////////////
+
+ public FixturesInstaller getFixturesInstaller() {
+ return fixtureInstaller;
+ }
+
+ /**
+ * The {@link LogonFixture}, if any, obtained by running fixtures.
+ *
+ * <p>
+ * Intended to be used when for {@link DeploymentType#EXPLORATION
+ * exploration} (instead of an {@link ExplorationSession}) or
+ * {@link DeploymentType#PROTOTYPE prototype} deployments (saves logging
+ * in). Should be <i>ignored</i> in other {@link DeploymentType}s.
+ */
+ @Override
+ public LogonFixture getLogonFixture() {
+ return logonFixture;
+ }
+
+ @Override
+ protected void appendFixturesInstallerDebug(final DebugBuilder debug) {
+ debug.appendln("Fixture Installer", fixtureInstaller == null ? "none" : fixtureInstaller.getClass().getName());
+ }
+
+
+
+ // ///////////////////////////////////////////
+ // Session Factory
+ // ///////////////////////////////////////////
+
+ @Override
+ public IsisSessionFactory doCreateSessionFactory(final DeploymentType deploymentType) throws IsisSystemException {
+ final PersistenceSessionFactory persistenceSessionFactory = obtainPersistenceSessionFactory(deploymentType);
+ final UserProfileLoader userProfileLoader = new UserProfileLoaderDefault(obtainUserProfileStore());
+ return createSessionFactory(deploymentType, userProfileLoader, persistenceSessionFactory);
+ }
+
+ /**
+ * 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 UserProfileLoader userProfileLoader, final PersistenceSessionFactory persistenceSessionFactory) throws IsisSystemException {
+
+ final IsisConfiguration configuration = getConfiguration();
+ final AuthenticationManager authenticationManager = obtainAuthenticationManager(deploymentType);
+ final AuthorizationManager authorizationManager = obtainAuthorizationManager(deploymentType);
+ final TemplateImageLoader templateImageLoader = obtainTemplateImageLoader();
+ final OidMarshaller oidMarshaller = obtainOidMarshaller();
+
+ final Collection<MetaModelRefiner> metaModelRefiners = refiners(authenticationManager, authorizationManager, templateImageLoader, persistenceSessionFactory);
+ final SpecificationLoaderSpi reflector = obtainSpecificationLoaderSpi(deploymentType, persistenceSessionFactory, metaModelRefiners);
+
+ final List<Object> servicesList = obtainServices();
+
+ // bind metamodel to the (runtime) framework
+ RuntimeContextFromSession runtimeContext = new RuntimeContextFromSession();
+ runtimeContext.injectInto(reflector);
+
+ return new IsisSessionFactoryDefault(deploymentType, configuration, templateImageLoader, reflector, authenticationManager, authorizationManager, userProfileLoader, persistenceSessionFactory, servicesList, oidMarshaller);
+ }
+
+
+
+ private static Collection<MetaModelRefiner> refiners(Object... possibleRefiners ) {
+ return Types.filtered(Arrays.asList(possibleRefiners), MetaModelRefiner.class);
+ }
+
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemThatUsesInstallersFactory.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemThatUsesInstallersFactory.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemThatUsesInstallersFactory.java
new file mode 100644
index 0000000..8f255c9
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemThatUsesInstallersFactory.java
@@ -0,0 +1,84 @@
+/*
+ * 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.runtimes.dflt.runtime.systemusinginstallers;
+
+import com.google.inject.Inject;
+
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
+import org.apache.isis.runtimes.dflt.runtime.system.IsisSystem;
+import org.apache.isis.runtimes.dflt.runtime.system.IsisSystemFactory;
+import org.apache.isis.runtimes.dflt.runtime.systemdependencyinjector.SystemDependencyInjector;
+
+/**
+ * Implementation of {@link IsisSystemFactory} that uses {@link InstallerLookup}
+ * to convert the names of components into actual component instances.
+ */
+public class IsisSystemThatUsesInstallersFactory implements IsisSystemFactory {
+
+ private final InstallerLookup installerLookup;
+
+ // //////////////////////////////////////////////////////////
+ // constructor
+ // //////////////////////////////////////////////////////////
+
+ @Inject
+ public IsisSystemThatUsesInstallersFactory(final InstallerLookup installerLookup) {
+ this.installerLookup = installerLookup;
+ }
+
+ // //////////////////////////////////////////////////////////
+ // init, shutdown
+ // //////////////////////////////////////////////////////////
+
+ @Override
+ public void init() {
+ // nothing to do
+ }
+
+ @Override
+ public void shutdown() {
+ // nothing to do
+ }
+
+ // //////////////////////////////////////////////////////////
+ // main API
+ // //////////////////////////////////////////////////////////
+
+ @Override
+ public IsisSystem createSystem(final DeploymentType deploymentType) {
+
+ final IsisSystemUsingInstallers system = new IsisSystemUsingInstallers(deploymentType, installerLookup);
+
+ system.lookupAndSetAuthenticatorAndAuthorization(deploymentType);
+ system.lookupAndSetUserProfileFactoryInstaller();
+ system.lookupAndSetFixturesInstaller();
+ return system;
+ }
+
+ // //////////////////////////////////////////////////////////
+ // Dependencies (injected or defaulted in constructor)
+ // //////////////////////////////////////////////////////////
+
+ public SystemDependencyInjector getInstallerLookup() {
+ return installerLookup;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemUsingInstallers.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemUsingInstallers.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemUsingInstallers.java
new file mode 100644
index 0000000..36913ff
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/systemusinginstallers/IsisSystemUsingInstallers.java
@@ -0,0 +1,280 @@
+/*
+ * 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.runtimes.dflt.runtime.systemusinginstallers;
+
+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.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetapi.ClassSubstitutorFactory;
+import org.apache.isis.core.metamodel.facetapi.MetaModelRefiner;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.core.metamodel.specloader.ObjectReflectorInstaller;
+import org.apache.isis.core.runtime.authentication.AuthenticationManager;
+import org.apache.isis.core.runtime.authentication.AuthenticationManagerInstaller;
+import org.apache.isis.core.runtime.authorization.AuthorizationManager;
+import org.apache.isis.core.runtime.authorization.AuthorizationManagerInstaller;
+import org.apache.isis.core.runtime.imageloader.TemplateImageLoader;
+import org.apache.isis.core.runtime.imageloader.TemplateImageLoaderInstaller;
+import org.apache.isis.core.runtime.userprofile.UserProfileStore;
+import org.apache.isis.runtimes.dflt.runtime.fixtures.FixturesInstaller;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
+import org.apache.isis.runtimes.dflt.runtime.services.ServicesInstaller;
+import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
+import org.apache.isis.runtimes.dflt.runtime.system.IsisSystemException;
+import org.apache.isis.runtimes.dflt.runtime.system.SystemConstants;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSessionFactory;
+import org.apache.isis.runtimes.dflt.runtime.systemdependencyinjector.SystemDependencyInjector;
+import org.apache.isis.runtimes.dflt.runtime.transaction.facetdecorator.standard.TransactionFacetDecoratorInstaller;
+import org.apache.isis.runtimes.dflt.runtime.userprofile.UserProfileStoreInstaller;
+
+public class IsisSystemUsingInstallers extends IsisSystemAbstract {
+
+ public static final Logger LOG = Logger.getLogger(IsisSystemUsingInstallers.class);
+
+ private final InstallerLookup installerLookup;
+
+ private AuthenticationManagerInstaller authenticationInstaller;
+ private AuthorizationManagerInstaller authorizationInstaller;
+ private ObjectReflectorInstaller reflectorInstaller;
+ private ServicesInstaller servicesInstaller;
+ private UserProfileStoreInstaller userProfileStoreInstaller;
+ private PersistenceMechanismInstaller persistenceMechanismInstaller;
+ private FixturesInstaller fixtureInstaller;
+
+ // ///////////////////////////////////////////
+ // Constructors
+ // ///////////////////////////////////////////
+
+ public IsisSystemUsingInstallers(final DeploymentType deploymentType, final InstallerLookup installerLookup) {
+ super(deploymentType);
+ ensureThatArg(installerLookup, is(not(nullValue())));
+ 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}.
+ *
+ * @see InstallerLookup#getConfiguration()
+ */
+ @Override
+ public IsisConfiguration getConfiguration() {
+ return installerLookup.getConfiguration();
+ }
+
+ // ///////////////////////////////////////////
+ // Authentication & Authorization
+ // ///////////////////////////////////////////
+
+ public void lookupAndSetAuthenticatorAndAuthorization(final DeploymentType deploymentType) {
+
+ //final IsisConfiguration configuration = installerLookup.getConfiguration();
+
+ // use the one specified in configuration
+ final String authenticationManagerKey = getConfiguration().getString(SystemConstants.AUTHENTICATION_INSTALLER_KEY);
+ final AuthenticationManagerInstaller authenticationInstaller = installerLookup.authenticationManagerInstaller(authenticationManagerKey, deploymentType);
+ if (authenticationInstaller != null) {
+ setAuthenticationInstaller(authenticationInstaller);
+ }
+
+ // use the one specified in configuration
+ final String authorizationManagerKey = getConfiguration().getString(SystemConstants.AUTHORIZATION_INSTALLER_KEY);
+ final AuthorizationManagerInstaller authorizationInstaller = installerLookup.authorizationManagerInstaller(authorizationManagerKey, deploymentType);
+ if (authorizationInstaller != null) {
+ setAuthorizationInstaller(authorizationInstaller);
+ }
+ }
+
+ public void setAuthenticationInstaller(final AuthenticationManagerInstaller authenticationManagerInstaller) {
+ this.authenticationInstaller = authenticationManagerInstaller;
+ }
+
+ public void setAuthorizationInstaller(final AuthorizationManagerInstaller authorizationManagerInstaller) {
+ this.authorizationInstaller = authorizationManagerInstaller;
+ }
+
+ @Override
+ protected AuthenticationManager obtainAuthenticationManager(final DeploymentType deploymentType) {
+ return authenticationInstaller.createAuthenticationManager();
+ }
+
+ @Override
+ protected AuthorizationManager obtainAuthorizationManager(final DeploymentType deploymentType) {
+ return authorizationInstaller.createAuthorizationManager();
+ }
+
+ // ///////////////////////////////////////////
+ // Fixtures
+ // ///////////////////////////////////////////
+
+ public void lookupAndSetFixturesInstaller() {
+ final IsisConfiguration configuration = installerLookup.getConfiguration();
+ final String fixture = configuration.getString(SystemConstants.FIXTURES_INSTALLER_KEY);
+
+ final FixturesInstaller fixturesInstaller = installerLookup.fixturesInstaller(fixture);
+ if (fixturesInstaller != null) {
+ this.fixtureInstaller = fixturesInstaller;
+ }
+ }
+
+ public void setFixtureInstaller(final FixturesInstaller fixtureInstaller) {
+ this.fixtureInstaller = fixtureInstaller;
+ }
+
+ @Override
+ protected FixturesInstaller obtainFixturesInstaller() throws IsisSystemException {
+ return fixtureInstaller;
+ }
+
+ // ///////////////////////////////////////////
+ // Template Image Loader
+ // ///////////////////////////////////////////
+
+ /**
+ * Uses the {@link TemplateImageLoader} configured in
+ * {@link InstallerLookup}, if available, else falls back to that of the
+ * superclass.
+ */
+ @Override
+ protected TemplateImageLoader obtainTemplateImageLoader() {
+ final TemplateImageLoaderInstaller templateImageLoaderInstaller = installerLookup.templateImageLoaderInstaller(null);
+ if (templateImageLoaderInstaller != null) {
+ return templateImageLoaderInstaller.createLoader();
+ } else {
+ return super.obtainTemplateImageLoader();
+ }
+ }
+
+ // ///////////////////////////////////////////
+ // Reflector
+ // ///////////////////////////////////////////
+
+ public void setReflectorInstaller(final ObjectReflectorInstaller reflectorInstaller) {
+ this.reflectorInstaller = reflectorInstaller;
+ }
+
+ @Override
+ protected SpecificationLoaderSpi obtainSpecificationLoaderSpi(final DeploymentType deploymentType, final ClassSubstitutorFactory classSubstitutorFactory, final Collection<MetaModelRefiner> metaModelRefiners) throws IsisSystemException {
+ if (reflectorInstaller == null) {
+ final String fromCmdLine = getConfiguration().getString(SystemConstants.REFLECTOR_KEY);
+ reflectorInstaller = installerLookup.reflectorInstaller(fromCmdLine);
+ }
+ ensureThatState(reflectorInstaller, is(not(nullValue())), "reflector installer has not been injected and could not be looked up");
+
+ // add in transaction support (if already in set then will be ignored)
+ reflectorInstaller.addFacetDecoratorInstaller(installerLookup.getInstaller(TransactionFacetDecoratorInstaller.class));
+
+ return reflectorInstaller.createReflector(classSubstitutorFactory, metaModelRefiners);
+ }
+
+ // ///////////////////////////////////////////
+ // Services
+ // ///////////////////////////////////////////
+
+ public void setServicesInstaller(final ServicesInstaller servicesInstaller) {
+ this.servicesInstaller = servicesInstaller;
+ }
+
+ @Override
+ protected List<Object> obtainServices() {
+ if (servicesInstaller == null) {
+ servicesInstaller = installerLookup.servicesInstaller(null);
+ }
+ ensureThatState(servicesInstaller, is(not(nullValue())), "services installer has not been injected and could not be looked up");
+
+ return servicesInstaller.getServices(getDeploymentType());
+ }
+
+ // ///////////////////////////////////////////
+ // User Profile Loader/Store
+ // ///////////////////////////////////////////
+
+ public void lookupAndSetUserProfileFactoryInstaller() {
+ final IsisConfiguration configuration = installerLookup.getConfiguration();
+ final String persistor = configuration.getString(SystemConstants.PROFILE_PERSISTOR_INSTALLER_KEY);
+
+ final UserProfileStoreInstaller userProfilePersistenceMechanismInstaller = installerLookup.userProfilePersistenceMechanismInstaller(persistor, getDeploymentType());
+ if (userProfilePersistenceMechanismInstaller != null) {
+ setUserProfileStoreInstaller(userProfilePersistenceMechanismInstaller);
+ }
+ }
+
+ public void setUserProfileStoreInstaller(final UserProfileStoreInstaller userProfilestoreInstaller) {
+ this.userProfileStoreInstaller = userProfilestoreInstaller;
+ }
+
+ @Override
+ protected UserProfileStore obtainUserProfileStore() {
+ return userProfileStoreInstaller.createUserProfileStore(getConfiguration());
+ }
+
+ // ///////////////////////////////////////////
+ // PersistenceSessionFactory
+ // ///////////////////////////////////////////
+
+ public void setPersistenceMechanismInstaller(final PersistenceMechanismInstaller persistenceMechanismInstaller) {
+ this.persistenceMechanismInstaller = persistenceMechanismInstaller;
+ }
+
+ @Override
+ protected PersistenceSessionFactory obtainPersistenceSessionFactory(final DeploymentType deploymentType) throws IsisSystemException {
+
+ // look for a object store persistor
+ if (persistenceMechanismInstaller == null) {
+ final String persistenceMechanism = getConfiguration().getString(SystemConstants.OBJECT_PERSISTOR_INSTALLER_KEY);
+ persistenceMechanismInstaller = installerLookup.persistenceMechanismInstaller(persistenceMechanism, deploymentType);
+ }
+
+ ensureThatState(persistenceMechanismInstaller, is(not(nullValue())), "persistor installer has not been injected and could not be looked up");
+ return persistenceMechanismInstaller.createPersistenceSessionFactory(deploymentType);
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/TransactionFacetDecorator.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/TransactionFacetDecorator.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/TransactionFacetDecorator.java
new file mode 100644
index 0000000..152a67d
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/TransactionFacetDecorator.java
@@ -0,0 +1,26 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facetdecorator;
+
+import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
+
+public interface TransactionFacetDecorator extends FacetDecorator {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/TransactionFacetDecoratorAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/TransactionFacetDecoratorAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/TransactionFacetDecoratorAbstract.java
new file mode 100644
index 0000000..fc1ebba
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/TransactionFacetDecoratorAbstract.java
@@ -0,0 +1,48 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facetdecorator;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetdecorator.FacetDecoratorAbstract;
+import org.apache.isis.core.metamodel.facets.actions.invoke.ActionInvocationFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionClearFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertyClearFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet;
+
+public abstract class TransactionFacetDecoratorAbstract extends FacetDecoratorAbstract implements TransactionFacetDecorator {
+
+ private final IsisConfiguration configuration;
+
+ public TransactionFacetDecoratorAbstract(final IsisConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ protected IsisConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ @Override
+ public Class<? extends Facet>[] getFacetTypes() {
+ return new Class[] { ActionInvocationFacet.class, PropertyClearFacet.class, PropertySetterFacet.class, CollectionAddToFacet.class, CollectionRemoveFromFacet.class, CollectionClearFacet.class };
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/package-info.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/package-info.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/package-info.java
new file mode 100644
index 0000000..218df70
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/package-info.java
@@ -0,0 +1,27 @@
+/*
+ * 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.
+ */
+
+/**
+ * Transaction API.
+ *
+ * <p>
+ * Not generally intended to be implemented; the default implementation in
+ * <tt>nof-core</tt> should normally suffice.
+ */
+package org.apache.isis.runtimes.dflt.runtime.transaction.facetdecorator;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/standard/StandardTransactionFacetDecorator.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/standard/StandardTransactionFacetDecorator.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/standard/StandardTransactionFacetDecorator.java
new file mode 100644
index 0000000..e7fd0e0
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/standard/StandardTransactionFacetDecorator.java
@@ -0,0 +1,93 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facetdecorator.standard;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetapi.Facet;
+import org.apache.isis.core.metamodel.facetapi.FacetHolder;
+import org.apache.isis.core.metamodel.facets.actions.invoke.ActionInvocationFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionClearFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertyClearFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet;
+import org.apache.isis.runtimes.dflt.runtime.transaction.facetdecorator.TransactionFacetDecoratorAbstract;
+import org.apache.isis.runtimes.dflt.runtime.transaction.facets.ActionInvocationFacetWrapTransaction;
+import org.apache.isis.runtimes.dflt.runtime.transaction.facets.CollectionAddToFacetWrapTransaction;
+import org.apache.isis.runtimes.dflt.runtime.transaction.facets.CollectionClearFacetWrapTransaction;
+import org.apache.isis.runtimes.dflt.runtime.transaction.facets.CollectionRemoveFromFacetWrapTransaction;
+import org.apache.isis.runtimes.dflt.runtime.transaction.facets.PropertyClearFacetWrapTransaction;
+import org.apache.isis.runtimes.dflt.runtime.transaction.facets.PropertySetterFacetWrapTransaction;
+
+public class StandardTransactionFacetDecorator extends TransactionFacetDecoratorAbstract {
+
+ public StandardTransactionFacetDecorator(final IsisConfiguration configuration) {
+ super(configuration);
+ }
+
+ @Override
+ public Facet decorate(final Facet facet, final FacetHolder requiredHolder) {
+ final Class<? extends Facet> facetType = facet.facetType();
+ if (facetType == ActionInvocationFacet.class) {
+ final ActionInvocationFacet decoratedFacet = (ActionInvocationFacet) facet;
+ final Facet decoratingFacet = new ActionInvocationFacetWrapTransaction(decoratedFacet);
+ requiredHolder.addFacet(decoratingFacet);
+ return decoratingFacet;
+ }
+
+ if (facetType == CollectionAddToFacet.class) {
+ final CollectionAddToFacet decoratedFacet = (CollectionAddToFacet) facet;
+ final Facet decoratingFacet = new CollectionAddToFacetWrapTransaction(decoratedFacet);
+ requiredHolder.addFacet(decoratingFacet);
+ return decoratingFacet;
+ }
+
+ if (facetType == CollectionClearFacet.class) {
+ final CollectionClearFacet decoratedFacet = (CollectionClearFacet) facet;
+ final Facet decoratingFacet = new CollectionClearFacetWrapTransaction(decoratedFacet);
+ requiredHolder.addFacet(decoratingFacet);
+ return decoratingFacet;
+ }
+
+ if (facetType == CollectionRemoveFromFacet.class) {
+ final CollectionRemoveFromFacet decoratedFacet = (CollectionRemoveFromFacet) facet;
+ final Facet decoratingFacet = new CollectionRemoveFromFacetWrapTransaction(decoratedFacet);
+ requiredHolder.addFacet(decoratingFacet);
+ return decoratingFacet;
+ }
+
+ if (facetType == PropertyClearFacet.class) {
+ final PropertyClearFacet decoratedFacet = (PropertyClearFacet) facet;
+ final Facet decoratingFacet = new PropertyClearFacetWrapTransaction(decoratedFacet);
+ requiredHolder.addFacet(decoratingFacet);
+ return decoratingFacet;
+ }
+
+ if (facetType == PropertySetterFacet.class) {
+ final PropertySetterFacet decoratedFacet = (PropertySetterFacet) facet;
+ final Facet decoratingFacet = new PropertySetterFacetWrapTransaction(decoratedFacet);
+ requiredHolder.addFacet(decoratingFacet);
+ return decoratingFacet;
+ }
+
+ return facet;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/standard/TransactionFacetDecoratorInstaller.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/standard/TransactionFacetDecoratorInstaller.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/standard/TransactionFacetDecoratorInstaller.java
new file mode 100644
index 0000000..97530b2
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facetdecorator/standard/TransactionFacetDecoratorInstaller.java
@@ -0,0 +1,45 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facetdecorator.standard;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+import org.apache.isis.core.commons.config.InstallerAbstract;
+import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
+import org.apache.isis.core.metamodel.specloader.FacetDecoratorInstaller;
+
+public class TransactionFacetDecoratorInstaller extends InstallerAbstract implements FacetDecoratorInstaller {
+
+ public TransactionFacetDecoratorInstaller() {
+ super(FacetDecoratorInstaller.TYPE, "transaction");
+ }
+
+ @Override
+ public List<FacetDecorator> createDecorators() {
+ return Lists.<FacetDecorator> newArrayList(new StandardTransactionFacetDecorator(getConfiguration()));
+ }
+
+ @Override
+ public List<Class<?>> getTypes() {
+ return listOf(List.class); // ie List<FacetDecorator>
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/ActionInvocationFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/ActionInvocationFacetWrapTransaction.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/ActionInvocationFacetWrapTransaction.java
new file mode 100644
index 0000000..ab026fd
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/ActionInvocationFacetWrapTransaction.java
@@ -0,0 +1,87 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facets;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
+import org.apache.isis.core.metamodel.facets.actions.invoke.ActionInvocationFacet;
+import org.apache.isis.core.metamodel.facets.actions.invoke.ActionInvocationFacetAbstract;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.TransactionalClosureWithReturnAbstract;
+
+public class ActionInvocationFacetWrapTransaction extends ActionInvocationFacetAbstract implements DecoratingFacet<ActionInvocationFacet> {
+
+ private final static Logger LOG = Logger.getLogger(ActionInvocationFacetWrapTransaction.class);
+
+ private final ActionInvocationFacet underlyingFacet;
+
+ @Override
+ public ActionInvocationFacet getDecoratedFacet() {
+ return underlyingFacet;
+ }
+
+ public ActionInvocationFacetWrapTransaction(final ActionInvocationFacet underlyingFacet) {
+ super(underlyingFacet.getFacetHolder());
+ this.underlyingFacet = underlyingFacet;
+ }
+
+ @Override
+ public ObjectAdapter invoke(final ObjectAdapter targetAdapter, final ObjectAdapter[] parameterAdapters) {
+ return getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturnAbstract<ObjectAdapter>() {
+ @Override
+ public ObjectAdapter execute() {
+ return underlyingFacet.invoke(targetAdapter, parameterAdapters);
+ }
+ });
+ }
+
+ @Override
+ public ObjectSpecification getReturnType() {
+ return underlyingFacet.getReturnType();
+ }
+
+ @Override
+ public ObjectSpecification getOnType() {
+ return underlyingFacet.getOnType();
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " --> " + underlyingFacet.toString();
+ }
+
+ // ///////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ///////////////////////////////////////////////////////////////
+
+ private static IsisTransactionManager getTransactionManager() {
+ return getPersistenceSession().getTransactionManager();
+ }
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionAddToFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionAddToFacetWrapTransaction.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionAddToFacetWrapTransaction.java
new file mode 100644
index 0000000..35eddc6
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionAddToFacetWrapTransaction.java
@@ -0,0 +1,78 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facets;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacetAbstract;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.TransactionalClosureAbstract;
+
+public class CollectionAddToFacetWrapTransaction extends CollectionAddToFacetAbstract implements DecoratingFacet<CollectionAddToFacet> {
+
+ private final CollectionAddToFacet underlyingFacet;
+
+ @Override
+ public CollectionAddToFacet getDecoratedFacet() {
+ return underlyingFacet;
+ }
+
+ public CollectionAddToFacetWrapTransaction(final CollectionAddToFacet underlyingFacet) {
+ super(underlyingFacet.getFacetHolder());
+ this.underlyingFacet = underlyingFacet;
+ }
+
+ @Override
+ public void add(final ObjectAdapter adapter, final ObjectAdapter referencedAdapter) {
+ if (adapter.isTransient()) {
+ // NOT !adapter.isPersistent();
+ // (value adapters are neither persistent or transient)
+ underlyingFacet.add(adapter, referencedAdapter);
+ } else {
+ getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
+ @Override
+ public void execute() {
+ underlyingFacet.add(adapter, referencedAdapter);
+ }
+ });
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " --> " + underlyingFacet.toString();
+ }
+
+ // ///////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ///////////////////////////////////////////////////////////////
+
+ private static IsisTransactionManager getTransactionManager() {
+ return getPersistenceSession().getTransactionManager();
+ }
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionClearFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionClearFacetWrapTransaction.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionClearFacetWrapTransaction.java
new file mode 100644
index 0000000..ab68b3f
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionClearFacetWrapTransaction.java
@@ -0,0 +1,78 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facets;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionClearFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionClearFacetAbstract;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.TransactionalClosureAbstract;
+
+public class CollectionClearFacetWrapTransaction extends CollectionClearFacetAbstract implements DecoratingFacet<CollectionClearFacet> {
+
+ private final CollectionClearFacet underlyingFacet;
+
+ @Override
+ public CollectionClearFacet getDecoratedFacet() {
+ return underlyingFacet;
+ }
+
+ public CollectionClearFacetWrapTransaction(final CollectionClearFacet underlyingFacet) {
+ super(underlyingFacet.getFacetHolder());
+ this.underlyingFacet = underlyingFacet;
+ }
+
+ @Override
+ public void clear(final ObjectAdapter adapter) {
+ if (adapter.isTransient()) {
+ // NOT !adapter.isPersistent();
+ // (value adapters are neither persistent or transient)
+ underlyingFacet.clear(adapter);
+ } else {
+ getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
+ @Override
+ public void execute() {
+ underlyingFacet.clear(adapter);
+ }
+ });
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " --> " + underlyingFacet.toString();
+ }
+
+ // ///////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ///////////////////////////////////////////////////////////////
+
+ private static IsisTransactionManager getTransactionManager() {
+ return getPersistenceSession().getTransactionManager();
+ }
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionRemoveFromFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionRemoveFromFacetWrapTransaction.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionRemoveFromFacetWrapTransaction.java
new file mode 100644
index 0000000..36cf615
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/CollectionRemoveFromFacetWrapTransaction.java
@@ -0,0 +1,78 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facets;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacetAbstract;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.TransactionalClosureAbstract;
+
+public class CollectionRemoveFromFacetWrapTransaction extends CollectionRemoveFromFacetAbstract implements DecoratingFacet<CollectionRemoveFromFacet> {
+
+ private final CollectionRemoveFromFacet underlyingFacet;
+
+ @Override
+ public CollectionRemoveFromFacet getDecoratedFacet() {
+ return underlyingFacet;
+ }
+
+ public CollectionRemoveFromFacetWrapTransaction(final CollectionRemoveFromFacet underlyingFacet) {
+ super(underlyingFacet.getFacetHolder());
+ this.underlyingFacet = underlyingFacet;
+ }
+
+ @Override
+ public void remove(final ObjectAdapter adapter, final ObjectAdapter referencedAdapter) {
+ if (adapter.isTransient()) {
+ // NOT !adapter.isPersistent();
+ // (value adapters are neither persistent or transient)
+ underlyingFacet.remove(adapter, referencedAdapter);
+ } else {
+ getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
+ @Override
+ public void execute() {
+ underlyingFacet.remove(adapter, referencedAdapter);
+ }
+ });
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " --> " + underlyingFacet.toString();
+ }
+
+ // ///////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ///////////////////////////////////////////////////////////////
+
+ private static IsisTransactionManager getTransactionManager() {
+ return getPersistenceSession().getTransactionManager();
+ }
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/PropertyClearFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/PropertyClearFacetWrapTransaction.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/PropertyClearFacetWrapTransaction.java
new file mode 100644
index 0000000..09d0c61
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/PropertyClearFacetWrapTransaction.java
@@ -0,0 +1,78 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facets;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertyClearFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertyClearFacetAbstract;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.TransactionalClosureAbstract;
+
+public class PropertyClearFacetWrapTransaction extends PropertyClearFacetAbstract implements DecoratingFacet<PropertyClearFacet> {
+
+ private final PropertyClearFacet underlyingFacet;
+
+ @Override
+ public PropertyClearFacet getDecoratedFacet() {
+ return underlyingFacet;
+ }
+
+ public PropertyClearFacetWrapTransaction(final PropertyClearFacet underlyingFacet) {
+ super(underlyingFacet.getFacetHolder());
+ this.underlyingFacet = underlyingFacet;
+ }
+
+ @Override
+ public void clearProperty(final ObjectAdapter adapter) {
+ if (adapter.isTransient()) {
+ // NOT !adapter.isPersistent();
+ // (value adapters are neither persistent or transient)
+ underlyingFacet.clearProperty(adapter);
+ } else {
+ getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
+ @Override
+ public void execute() {
+ underlyingFacet.clearProperty(adapter);
+ }
+ });
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " --> " + underlyingFacet.toString();
+ }
+
+ // ///////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ///////////////////////////////////////////////////////////////
+
+ private static IsisTransactionManager getTransactionManager() {
+ return getPersistenceSession().getTransactionManager();
+ }
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/PropertySetterFacetWrapTransaction.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/PropertySetterFacetWrapTransaction.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/PropertySetterFacetWrapTransaction.java
new file mode 100644
index 0000000..2a80d6a
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/transaction/facets/PropertySetterFacetWrapTransaction.java
@@ -0,0 +1,78 @@
+/*
+ * 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.runtimes.dflt.runtime.transaction.facets;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.facetapi.DecoratingFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacet;
+import org.apache.isis.core.metamodel.facets.properties.modify.PropertySetterFacetAbstract;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.TransactionalClosureAbstract;
+
+public class PropertySetterFacetWrapTransaction extends PropertySetterFacetAbstract implements DecoratingFacet<PropertySetterFacet> {
+
+ private final PropertySetterFacet underlyingFacet;
+
+ public PropertySetterFacetWrapTransaction(final PropertySetterFacet underlyingFacet) {
+ super(underlyingFacet.getFacetHolder());
+ this.underlyingFacet = underlyingFacet;
+ }
+
+ @Override
+ public PropertySetterFacet getDecoratedFacet() {
+ return underlyingFacet;
+ }
+
+ @Override
+ public void setProperty(final ObjectAdapter adapter, final ObjectAdapter referencedAdapter) {
+ if (adapter.isTransient()) {
+ // NOT !adapter.isPersistent();
+ // (value adapters are neither persistent or transient)
+ underlyingFacet.setProperty(adapter, referencedAdapter);
+ } else {
+ getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
+ @Override
+ public void execute() {
+ underlyingFacet.setProperty(adapter, referencedAdapter);
+ }
+ });
+ }
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + " --> " + underlyingFacet.toString();
+ }
+
+ // ///////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ///////////////////////////////////////////////////////////////
+
+ private static IsisTransactionManager getTransactionManager() {
+ return getPersistenceSession().getTransactionManager();
+ }
+
+ private static PersistenceSession getPersistenceSession() {
+ return IsisContext.getPersistenceSession();
+ }
+
+}