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:36 UTC
[37/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/persistence/objectstore/algorithm/PersistAlgorithmTopDown.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmTopDown.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmTopDown.java
new file mode 100644
index 0000000..4cce6b4
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmTopDown.java
@@ -0,0 +1,108 @@
+/*
+ * 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.persistence.objectstore.algorithm;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
+import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackUtils;
+import org.apache.isis.core.metamodel.facets.object.callbacks.PersistedCallbackFacet;
+import org.apache.isis.core.metamodel.facets.object.callbacks.PersistingCallbackFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+import org.apache.isis.runtimes.dflt.runtime.persistence.ObjectPersistenceException;
+
+public class PersistAlgorithmTopDown extends PersistAlgorithmAbstract {
+
+ private static final Logger LOG = Logger.getLogger(PersistAlgorithmTopDown.class);
+
+ @Override
+ public void makePersistent(final ObjectAdapter object, final ToPersistObjectSet toPersistObjectSet) {
+ if (object.getSpecification().isParentedOrFreeCollection()) {
+ makeCollectionPersistent(object, toPersistObjectSet);
+ } else {
+ makeObjectPersistent(object, toPersistObjectSet);
+ }
+ }
+
+ private void makeObjectPersistent(final ObjectAdapter object, final ToPersistObjectSet toPersistObjectSet) {
+ if (alreadyPersistedOrNotPersistableOrServiceOrStandalone(object)) {
+ LOG.warn("can't make object persistent - either already persistent, or transient only: " + object);
+ return;
+ }
+
+ final List<ObjectAssociation> fields = object.getSpecification().getAssociations();
+ if (!object.getSpecification().isEncodeable() && fields.size() > 0) {
+ LOG.info("persist " + object);
+ CallbackUtils.callCallback(object, PersistingCallbackFacet.class);
+ toPersistObjectSet.remapAsPersistent(object);
+ toPersistObjectSet.addCreateObjectCommand(object);
+ CallbackUtils.callCallback(object, PersistedCallbackFacet.class);
+
+ for (int i = 0; i < fields.size(); i++) {
+ final ObjectAssociation field = fields.get(i);
+ if (field.isNotPersisted()) {
+ continue;
+ } else if (field instanceof OneToManyAssociation) {
+ final ObjectAdapter collection = field.get(object);
+ if (collection == null) {
+ throw new ObjectPersistenceException("Collection " + field.getName() + " does not exist in " + object.getSpecification().getFullIdentifier());
+ }
+ makePersistent(collection, toPersistObjectSet);
+ } else {
+ final ObjectAdapter fieldValue = field.get(object);
+ if (fieldValue == null) {
+ continue;
+ }
+ makePersistent(fieldValue, toPersistObjectSet);
+ }
+ }
+ }
+ }
+
+ private void makeCollectionPersistent(final ObjectAdapter collectionAdapter, final ToPersistObjectSet toPersistObjectSet) {
+ LOG.info("persist " + collectionAdapter);
+ if (collectionAdapter.isTransient()) {
+ collectionAdapter.changeState(ResolveState.RESOLVED);
+ }
+ final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collectionAdapter);
+ for(ObjectAdapter element: facet.iterable(collectionAdapter)) {
+ makePersistent(element, toPersistObjectSet);
+ }
+ }
+
+ @Override
+ public String name() {
+ return "Simple Top Down Persistence Walker";
+ }
+
+ @Override
+ public String toString() {
+ final ToString toString = new ToString(this);
+ return toString.toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmTwoPass.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmTwoPass.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmTwoPass.java
new file mode 100644
index 0000000..50564c3
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/PersistAlgorithmTwoPass.java
@@ -0,0 +1,131 @@
+/*
+ * 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.persistence.objectstore.algorithm;
+
+import java.util.Enumeration;
+import java.util.List;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.ResolveState;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacet;
+import org.apache.isis.core.metamodel.facets.collections.modify.CollectionFacetUtils;
+import org.apache.isis.core.metamodel.facets.object.callbacks.CallbackUtils;
+import org.apache.isis.core.metamodel.facets.object.callbacks.PersistedCallbackFacet;
+import org.apache.isis.core.metamodel.facets.object.callbacks.PersistingCallbackFacet;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
+
+public class PersistAlgorithmTwoPass extends PersistAlgorithmAbstract {
+ private static final Logger LOG = Logger.getLogger(PersistAlgorithmTwoPass.class);
+
+ @Override
+ public String name() {
+ return "Two pass, bottom up persistence walker";
+ }
+
+ @Override
+ public void makePersistent(final ObjectAdapter object, final ToPersistObjectSet toPersistObjectSet) {
+ if (object.getSpecification().isParentedOrFreeCollection()) {
+ makeCollectionPersistent(object, toPersistObjectSet);
+ } else {
+ makeObjectPersistent(object, toPersistObjectSet);
+ }
+ }
+
+ private void makeObjectPersistent(final ObjectAdapter object, final ToPersistObjectSet toPersistObjectSet) {
+ if (alreadyPersistedOrNotPersistableOrServiceOrStandalone(object)) {
+ return;
+ }
+ final List<ObjectAssociation> fields = object.getSpecification().getAssociations();
+ if (!object.getSpecification().isEncodeable() && fields.size() > 0) {
+ LOG.info("persist " + object);
+ CallbackUtils.callCallback(object, PersistingCallbackFacet.class);
+ toPersistObjectSet.remapAsPersistent(object);
+
+ for (int i = 0; i < fields.size(); i++) {
+ final ObjectAssociation field = fields.get(i);
+ if (field.isNotPersisted()) {
+ continue;
+ } else if (field.isOneToManyAssociation()) {
+ // skip in first pass
+ continue;
+ } else {
+ final ObjectAdapter fieldValue = field.get(object);
+ if (fieldValue == null) {
+ continue;
+ }
+ makePersistent(fieldValue, toPersistObjectSet);
+ }
+ }
+
+ for (int i = 0; i < fields.size(); i++) {
+ final ObjectAssociation field = fields.get(i);
+ if (field.isNotPersisted()) {
+ continue;
+ } else if (field instanceof OneToManyAssociation) {
+ final ObjectAdapter collection = field.get(object);
+ makeCollectionPersistent(collection, toPersistObjectSet);
+ /**
+ * if (collection == null) { throw new
+ * ObjectPersistenceException("Collection " +
+ * field.getName() + " does not exist in " +
+ * object.getSpecification().getFullName()); }
+ * makePersistent(collection, toPersistObjectSet); final
+ * CollectionFacet facet =
+ * CollectionFacetUtils.getCollectionFacetFromSpec
+ * (collection); final Enumeration elements =
+ * facet.elements(collection); while
+ * (elements.hasMoreElements()) {
+ * makePersistent((ObjectAdapter) elements.nextElement(),
+ * toPersistObjectSet); }
+ */
+ } else {
+ // skip in second pass
+ continue;
+ }
+ }
+
+ toPersistObjectSet.addCreateObjectCommand(object);
+ CallbackUtils.callCallback(object, PersistedCallbackFacet.class);
+ }
+ }
+
+ private void makeCollectionPersistent(final ObjectAdapter collection, final ToPersistObjectSet toPersistObjectSet) {
+ LOG.info("persist " + collection);
+ if (collection.isTransient()) {
+ collection.changeState(ResolveState.RESOLVED);
+ }
+ final CollectionFacet facet = CollectionFacetUtils.getCollectionFacetFromSpec(collection);
+ final Enumeration elements = facet.elements(collection);
+ while (elements.hasMoreElements()) {
+ makePersistent((ObjectAdapter) elements.nextElement(), toPersistObjectSet);
+ }
+ }
+
+ @Override
+ public String toString() {
+ final ToString toString = new ToString(this);
+ return toString.toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/ToPersistObjectSet.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/ToPersistObjectSet.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/ToPersistObjectSet.java
new file mode 100644
index 0000000..f4d61c9
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/ToPersistObjectSet.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.persistence.objectstore.algorithm;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.oid.Oid;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession;
+
+/**
+ * Set of {@link ObjectAdapter}s that require persisting.
+ *
+ * <p>
+ * Is consumed by {@link PersistAlgorithm}, and is ultimately implemented by
+ * {@link PersistenceSession}.
+ */
+public interface ToPersistObjectSet {
+
+ void remapAsPersistent(final ObjectAdapter object);
+
+ void addCreateObjectCommand(ObjectAdapter object);
+
+ /**
+ * To support ISIS-234; keep track, for the duration of the transaction only,
+ * of the old transient {@link Oid}s and their corresponding persistent {@link Oid}s.
+ */
+ Oid remappedFrom(Oid oid);
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/package-info.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/package-info.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/package-info.java
new file mode 100644
index 0000000..5d7291a
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/algorithm/package-info.java
@@ -0,0 +1,39 @@
+/*
+ * 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.
+ */
+
+/**
+ * This interface is used by the {@link org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession} and
+ * is generally not intended to be implemented directly.
+ *
+ * <p>
+ * The {@link PersistAlgorithm} defines how persistence-by-reachability is enacted. This only
+ * applies to the <tt>ObjectStorePersistor</tt> implementation, but has been brought up into
+ * <tt>architecture</tt> module because it is very much a peer of the other helper objects
+ * that influence the {@link org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession}'s behaviour, such
+ * as {@link ClassSubstitutor} and {@link org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator}.
+ *
+ * <p>
+ * Since there is a close dependency between the {@link org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceSession}
+ * and the {@link PersistAlgorithm} implementation, it is the job of the {@link org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstaller} to
+ * ensure that the correct {@link PersistAlgorithm} is setup.
+ *
+ * @see org.apache.isis.metamodel.specloader.classsubstitutor.classsubstitor.ClassSubstitutor.ClassStrategy
+ * @see org.apache.isis.runtimes.dflt.runtime.system.persistence.OidGenerator
+ */
+package org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.algorithm;
\ 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/persistence/objectstore/transaction/CreateObjectCommand.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/CreateObjectCommand.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/CreateObjectCommand.java
new file mode 100644
index 0000000..fde8608
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/CreateObjectCommand.java
@@ -0,0 +1,24 @@
+/*
+ * 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.persistence.objectstore.transaction;
+
+public interface CreateObjectCommand extends PersistenceCommand {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/DestroyObjectCommand.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/DestroyObjectCommand.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/DestroyObjectCommand.java
new file mode 100644
index 0000000..47a81ff
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/DestroyObjectCommand.java
@@ -0,0 +1,24 @@
+/*
+ * 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.persistence.objectstore.transaction;
+
+public interface DestroyObjectCommand extends PersistenceCommand {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommand.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommand.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommand.java
new file mode 100644
index 0000000..3b8b603
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommand.java
@@ -0,0 +1,28 @@
+/*
+ * 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.persistence.objectstore.transaction;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+
+public interface PersistenceCommand {
+ void execute(PersistenceCommandContext context);
+
+ ObjectAdapter onAdapter();
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommandAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommandAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommandAbstract.java
new file mode 100644
index 0000000..bd32ad8
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommandAbstract.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.persistence.objectstore.transaction;
+
+import org.apache.isis.core.commons.authentication.AuthenticationSession;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+
+public abstract class PersistenceCommandAbstract implements PersistenceCommand {
+
+ private final ObjectAdapter adapter;
+
+ public PersistenceCommandAbstract(final ObjectAdapter adapter) {
+ super();
+ this.adapter = adapter;
+ }
+
+ @Override
+ public ObjectAdapter onAdapter() {
+ return adapter;
+ }
+
+ // /////////////////////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // /////////////////////////////////////////////////////////////////////
+
+ protected static AuthenticationSession getAuthenticationSession() {
+ return IsisContext.getAuthenticationSession();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommandContext.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommandContext.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommandContext.java
new file mode 100644
index 0000000..eabf9aa
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/PersistenceCommandContext.java
@@ -0,0 +1,28 @@
+/*
+ * 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.persistence.objectstore.transaction;
+
+public interface PersistenceCommandContext {
+
+ void start();
+
+ void end();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/SaveObjectCommand.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/SaveObjectCommand.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/SaveObjectCommand.java
new file mode 100644
index 0000000..e87d2ac
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/SaveObjectCommand.java
@@ -0,0 +1,24 @@
+/*
+ * 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.persistence.objectstore.transaction;
+
+public interface SaveObjectCommand extends PersistenceCommand {
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/TransactionalResource.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/TransactionalResource.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/TransactionalResource.java
new file mode 100644
index 0000000..e5ff704
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/objectstore/transaction/TransactionalResource.java
@@ -0,0 +1,60 @@
+/*
+ * 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.persistence.objectstore.transaction;
+
+import java.util.List;
+
+import org.apache.isis.runtimes.dflt.runtime.persistence.objectstore.ObjectStoreSpi;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransaction;
+import org.apache.isis.runtimes.dflt.runtime.system.transaction.IsisTransactionManager;
+
+/**
+ * Interface for the {@link IsisTransactionManager} to interact with some
+ * transactional resource (ie a {@link ObjectStoreSpi}).
+ */
+public interface TransactionalResource {
+
+ /**
+ * Used by the {@link ObjectStoreTransactionManager} to tell the underlying
+ * {@link ObjectStoreSpi} to start a transaction.
+ */
+ void startTransaction();
+
+ /**
+ * Used by the current {@link IsisTransaction} to flush changes to
+ * the {@link ObjectStoreSpi} (either via a
+ * {@link IsisTransactionManager#flushTransaction()} or a
+ * {@link IsisTransactionManager#endTransaction()}).
+ */
+ void execute(List<PersistenceCommand> unmodifiableList);
+
+ /**
+ * Used by the {@link ObjectStoreTransactionManager} to tell the underlying
+ * {@link ObjectStoreSpi} to commit a transaction.
+ */
+ void endTransaction();
+
+ /**
+ * Used by the {@link ObjectStoreTransactionManager} to tell the underlying
+ * {@link ObjectStoreSpi} to abort a transaction.
+ */
+ void abortTransaction();
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/package-info.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/package-info.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/package-info.java
new file mode 100644
index 0000000..51f9148
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/package-info.java
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+/**
+ * Object Persistor API.
+ *
+ * <p>
+ * Concrete implementations are in the <tt>persistor-xxx</tt> modules. The
+ * role of the {@link PersistenceSession} is to manage the lifecycle of
+ * domain objects, creating them, retrieving them, persisting them, deleting them.
+ * However, this object management role applies when deployed in client/server mode
+ * as well as standalone.
+ *
+ * <p>
+ * There are therefore just two implementations:
+ * <ul>
+ * <li> the <tt>persistor-objectstore</tt> implementation delegates to an <tt>ObjectAdapterStore</tt>
+ * API that actually persists objects to some persistent store (such as XML or RDBMS)</li>
+ * <li> the <tt>persistor-proxy</tt> implementation in effect provides the client-side remoting library,
+ * using the remoting protocol defined in the <tt>remoting-command</tt> module.
+ * </ul>
+ *
+ * <p>
+ * Note that the {@link PersistenceSession} both extends a number of superinterfaces as well as uses implementations of
+ * various helpers (for example {@link org.apache.isis.ServicesInjectorSpi.services.ServicesInjector} and {@link org.apache.isis.runtime.persistence.oidgenerator.OidGenerator}).
+ * These superinterfaces and helper interfaces are not normally implemented directly, and it is the
+ * responsibility of the {@link PersistenceMechanismInstaller} to ensure that the correct helper objects
+ * are passed to the {@link PersistenceSession} implementation.
+ */
+package org.apache.isis.runtimes.dflt.runtime.persistence;
+
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryAbstract.java
new file mode 100644
index 0000000..ef1db0c
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryAbstract.java
@@ -0,0 +1,108 @@
+/*
+ * 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.persistence.query;
+
+import java.io.IOException;
+
+import org.apache.isis.core.commons.encoding.DataInputExtended;
+import org.apache.isis.core.commons.encoding.DataOutputExtended;
+import org.apache.isis.core.commons.encoding.Encodable;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
+import org.apache.isis.runtimes.dflt.runtime.system.context.IsisContext;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
+
+public abstract class PersistenceQueryAbstract implements PersistenceQuery, Encodable {
+
+ private final ObjectSpecification specification;
+
+ public PersistenceQueryAbstract(final ObjectSpecification specification) {
+ this.specification = specification;
+ initialized();
+ }
+
+ protected PersistenceQueryAbstract(final DataInputExtended input) throws IOException {
+ final String specName = input.readUTF();
+ specification = getSpecificationLoader().loadSpecification(specName);
+ initialized();
+ }
+
+ @Override
+ public void encode(final DataOutputExtended output) throws IOException {
+ output.writeUTF(specification.getFullIdentifier());
+ }
+
+ private void initialized() {
+ // nothing to do
+ }
+
+ // ///////////////////////////////////////////////////////
+ //
+ // ///////////////////////////////////////////////////////
+
+ @Override
+ public ObjectSpecification getSpecification() {
+ return specification;
+ }
+
+ // ///////////////////////////////////////////////////////
+ // equals, hashCode
+ // ///////////////////////////////////////////////////////
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final PersistenceQueryAbstract other = (PersistenceQueryAbstract) obj;
+ if (specification == null) {
+ if (other.specification != null) {
+ return false;
+ }
+ } else if (!specification.equals(other.specification)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + 1231;
+ result = PRIME * result + ((specification == null) ? 0 : specification.hashCode());
+ return result;
+ }
+
+ // ///////////////////////////////////////////////////////
+ // Dependencies (from context)
+ // ///////////////////////////////////////////////////////
+
+ protected static SpecificationLoaderSpi getSpecificationLoader() {
+ return IsisContext.getSpecificationLoader();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryBuiltIn.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryBuiltIn.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryBuiltIn.java
new file mode 100644
index 0000000..d149687
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryBuiltIn.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.persistence.query;
+
+import org.apache.isis.applib.DomainObjectContainer;
+import org.apache.isis.applib.filter.Filter;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
+
+public interface PersistenceQueryBuiltIn extends PersistenceQuery {
+
+ /**
+ * The built-in queries iterate over all instances.
+ *
+ * <p>
+ * This is similar to the {@link Filter} interface in the applib, except the
+ * filtering is done within the object store as opposed to be the
+ * {@link DomainObjectContainer}.
+ *
+ * <p>
+ * Object store implementations do not necessarily need to rely on this
+ * method. For example, an RDBMS-based implementation may use an alternative
+ * mechanism to determine the matching results, for example using a
+ * <tt>WHERE</tt> clause in some SQL query.
+ *
+ */
+ public boolean matches(final ObjectAdapter object);
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryBuiltInAbstract.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryBuiltInAbstract.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryBuiltInAbstract.java
new file mode 100644
index 0000000..5db1516
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryBuiltInAbstract.java
@@ -0,0 +1,47 @@
+/*
+ * 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.persistence.query;
+
+import java.io.IOException;
+
+import org.apache.isis.applib.query.Query;
+import org.apache.isis.applib.query.QueryBuiltInAbstract;
+import org.apache.isis.core.commons.encoding.DataInputExtended;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.runtimes.dflt.runtime.system.persistence.PersistenceQuery;
+
+/**
+ * Corresponds to {@link QueryBuiltInAbstract}.
+ *
+ * <p>
+ * REVIEW: now that we've dropped remoting, could we get rid of the {@link PersistenceQuery} hierarchy
+ * classes and just use the applib {@link Query} throughout?
+ */
+public abstract class PersistenceQueryBuiltInAbstract extends PersistenceQueryAbstract implements PersistenceQueryBuiltIn {
+
+ public PersistenceQueryBuiltInAbstract(final ObjectSpecification specification) {
+ super(specification);
+ }
+
+ public PersistenceQueryBuiltInAbstract(final DataInputExtended input) throws IOException {
+ super(input);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindAllInstances.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindAllInstances.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindAllInstances.java
new file mode 100644
index 0000000..c1bc064
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindAllInstances.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.persistence.query;
+
+import org.apache.isis.applib.query.QueryFindAllInstances;
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+/**
+ * Corresponds to {@link QueryFindAllInstances}
+ */
+public class PersistenceQueryFindAllInstances extends PersistenceQueryBuiltInAbstract {
+ public PersistenceQueryFindAllInstances(final ObjectSpecification specification) {
+ super(specification);
+ }
+
+ /**
+ * Returns true so it matches all instances.
+ */
+ @Override
+ public boolean matches(final ObjectAdapter object) {
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ final ToString str = ToString.createAnonymous(this);
+ str.append("spec", getSpecification().getShortIdentifier());
+ return str.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindByPattern.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindByPattern.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindByPattern.java
new file mode 100644
index 0000000..ee21da7
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindByPattern.java
@@ -0,0 +1,110 @@
+/*
+ * 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.persistence.query;
+
+import java.util.List;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.services.container.query.QueryFindByPattern;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
+
+/**
+ * Corresponds to {@link QueryFindByPattern}.
+ */
+public class PersistenceQueryFindByPattern extends PersistenceQueryBuiltInAbstract {
+ private final ObjectAdapter pattern;
+
+ public ObjectAdapter getPattern() {
+ return pattern;
+ }
+
+ public PersistenceQueryFindByPattern(final ObjectSpecification specification, final ObjectAdapter pattern) {
+ super(specification);
+ this.pattern = pattern;
+ }
+
+ @Override
+ public boolean matches(final ObjectAdapter object) {
+ final ObjectSpecification requiredSpec = pattern.getSpecification();
+ final ObjectSpecification objectSpec = object.getSpecification();
+ return objectSpec.equals(requiredSpec) && matchesPattern(pattern, object);
+ }
+
+ private boolean matchesPattern(final ObjectAdapter pattern, final ObjectAdapter instance) {
+ final ObjectAdapter object = instance;
+ final ObjectSpecification nc = object.getSpecification();
+ final List<ObjectAssociation> fields = nc.getAssociations();
+
+ for (int f = 0; f < fields.size(); f++) {
+ final ObjectAssociation fld = fields.get(f);
+
+ // are ignoring internal collections - these probably should be
+ // considered
+
+ // ignore non-persistent fields - there is no persisted field to
+ // compare against
+ if (fld.isNotPersisted()) {
+ continue;
+ }
+ if (!fld.isOneToOneAssociation()) {
+ continue;
+ }
+
+ // if pattern contains empty value then it matches anything
+ if (fld.isEmpty(pattern)) {
+ continue;
+ }
+
+ // find the object to match against, if any
+ final ObjectAdapter reqd = fld.get(pattern);
+ if (reqd == null) {
+ continue;
+ }
+
+ // find the object; it's a bust if nothing
+ final ObjectAdapter search = fld.get(object);
+ if (search == null) {
+ return false;
+ }
+
+ if (fld.getSpecification().isValue()) {
+ // compare values directly
+ if (!reqd.getObject().equals(search.getObject())) {
+ return false;
+ }
+
+ } else {
+
+ // compare the titles
+ final String r = reqd.titleString().toLowerCase();
+ final String s = search.titleString().toLowerCase();
+
+ // if the pattern does not occur in the object, then it's a bust
+ if (s.indexOf(r) == -1) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindByTitle.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindByTitle.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindByTitle.java
new file mode 100644
index 0000000..441bec2
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindByTitle.java
@@ -0,0 +1,61 @@
+/*
+ * 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.persistence.query;
+
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.services.container.query.QueryFindByTitle;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+/**
+ * Corresponds to {@link QueryFindByTitle}.
+ */
+public class PersistenceQueryFindByTitle extends PersistenceQueryBuiltInAbstract {
+ private final String title;
+
+ public PersistenceQueryFindByTitle(final ObjectSpecification specification, final String title) {
+ super(specification);
+ this.title = title == null ? "" : title.toLowerCase();
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ @Override
+ public boolean matches(final ObjectAdapter object) {
+ final String titleString = object.titleString().toLowerCase();
+ return matches(titleString);
+ }
+
+ public boolean matches(final String titleString) {
+ final String objectTitle = titleString.toLowerCase();
+ return objectTitle.indexOf(title) >= 0;
+ }
+
+ @Override
+ public String toString() {
+ final ToString str = ToString.createAnonymous(this);
+ str.append("spec", getSpecification().getShortIdentifier());
+ str.append("title", title);
+ return str.toString();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindUsingApplibQueryDefault.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindUsingApplibQueryDefault.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindUsingApplibQueryDefault.java
new file mode 100644
index 0000000..e517173
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindUsingApplibQueryDefault.java
@@ -0,0 +1,97 @@
+/*
+ * 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.persistence.query;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.isis.applib.query.Query;
+import org.apache.isis.core.commons.encoding.DataInputExtended;
+import org.apache.isis.core.commons.encoding.DataOutputExtended;
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.services.container.query.QueryCardinality;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+/**
+ * Corresponds to an object-store specific implementation of {@link Query}.
+ */
+public class PersistenceQueryFindUsingApplibQueryDefault extends PersistenceQueryAbstract {
+
+ private final String queryName;
+ private final QueryCardinality cardinality;
+ private final Map<String, ObjectAdapter> argumentsAdaptersByParameterName;
+
+ public PersistenceQueryFindUsingApplibQueryDefault(final ObjectSpecification specification, final String queryName, final Map<String, ObjectAdapter> argumentsAdaptersByParameterName, final QueryCardinality cardinality) {
+ super(specification);
+ this.queryName = queryName;
+ this.cardinality = cardinality;
+ this.argumentsAdaptersByParameterName = argumentsAdaptersByParameterName;
+ initialized();
+ }
+
+ public PersistenceQueryFindUsingApplibQueryDefault(final DataInputExtended input) throws IOException {
+ super(input);
+ this.queryName = input.readUTF();
+ this.cardinality = QueryCardinality.valueOf(input.readUTF());
+ // TODO: need to read from input
+ this.argumentsAdaptersByParameterName = new HashMap<String, ObjectAdapter>();
+ initialized();
+ }
+
+ @Override
+ public void encode(final DataOutputExtended output) throws IOException {
+ super.encode(output);
+ output.writeUTF(queryName);
+ output.writeUTF(cardinality.name());
+ // TODO: need to write to output
+ // ... this.argumentsAdaptersByParameterName....
+
+ }
+
+ private void initialized() {
+ // nothing to do
+ }
+
+ // ///////////////////////////////////////////////////////
+ //
+ // ///////////////////////////////////////////////////////
+
+ public String getQueryName() {
+ return queryName;
+ }
+
+ public Map<String, ObjectAdapter> getArgumentsAdaptersByParameterName() {
+ return Collections.unmodifiableMap(argumentsAdaptersByParameterName);
+ }
+
+ public QueryCardinality getCardinality() {
+ return cardinality;
+ }
+
+ @Override
+ public String toString() {
+ final ToString str = ToString.createAnonymous(this);
+ str.append("spec", getSpecification().getShortIdentifier());
+ return str.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindUsingApplibQuerySerializable.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindUsingApplibQuerySerializable.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindUsingApplibQuerySerializable.java
new file mode 100644
index 0000000..431015c
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/persistence/query/PersistenceQueryFindUsingApplibQuerySerializable.java
@@ -0,0 +1,83 @@
+/*
+ * 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.persistence.query;
+
+import java.io.IOException;
+
+import org.apache.isis.applib.query.Query;
+import org.apache.isis.core.commons.encoding.DataInputExtended;
+import org.apache.isis.core.commons.encoding.DataOutputExtended;
+import org.apache.isis.core.commons.lang.ToString;
+import org.apache.isis.core.metamodel.services.container.query.QueryCardinality;
+import org.apache.isis.core.metamodel.spec.ObjectSpecification;
+
+/**
+ * Corresponds to an object-store specific implementation of {@link Query}.
+ */
+public class PersistenceQueryFindUsingApplibQuerySerializable extends PersistenceQueryAbstract {
+
+ private final Query<?> query;
+ private final QueryCardinality cardinality;
+
+ public PersistenceQueryFindUsingApplibQuerySerializable(final ObjectSpecification specification, final Query<?> query, final QueryCardinality cardinality) {
+ super(specification);
+ this.query = query;
+ this.cardinality = cardinality;
+ initialized();
+ }
+
+ public PersistenceQueryFindUsingApplibQuerySerializable(final DataInputExtended input) throws IOException {
+ super(input);
+ this.query = input.readSerializable(Query.class);
+ this.cardinality = QueryCardinality.valueOf(input.readUTF());
+ initialized();
+ }
+
+ @Override
+ public void encode(final DataOutputExtended output) throws IOException {
+ super.encode(output);
+ output.writeSerializable(query);
+ output.writeUTF(cardinality.name());
+ }
+
+ private void initialized() {
+ // nothing to do
+ }
+
+ // ///////////////////////////////////////////////////////
+ //
+ // ///////////////////////////////////////////////////////
+
+ public Query getApplibQuery() {
+ return query;
+ }
+
+ public QueryCardinality getCardinality() {
+ return cardinality;
+ }
+
+ @Override
+ public String toString() {
+ final ToString str = ToString.createAnonymous(this);
+ str.append("spec", getSpecification().getShortIdentifier());
+ str.append("query", query.getDescription());
+ return str.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/progmodels/JavaReflectorInstaller.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/progmodels/JavaReflectorInstaller.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/progmodels/JavaReflectorInstaller.java
new file mode 100644
index 0000000..ff67f5f
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/progmodels/JavaReflectorInstaller.java
@@ -0,0 +1,98 @@
+/*
+ * 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.progmodels;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.apache.log4j.Logger;
+
+import org.apache.isis.core.commons.config.IsisConfiguration;
+import org.apache.isis.core.metamodel.facetdecorator.FacetDecorator;
+import org.apache.isis.core.metamodel.specloader.FacetDecoratorInstaller;
+import org.apache.isis.core.metamodel.specloader.ReflectorConstants;
+import org.apache.isis.progmodels.dflt.JavaReflectorInstallerNoDecorators;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.InstallerLookupAware;
+
+public class JavaReflectorInstaller extends JavaReflectorInstallerNoDecorators implements InstallerLookupAware {
+
+ private static final Logger LOG = Logger.getLogger(JavaReflectorInstaller.class);
+
+ private InstallerLookup installerLookup;
+
+ /**
+ * Hook method to allow subclasses to specify a different sets of
+ * {@link FacetDecorator}s.
+ *
+ * <p>
+ * By default, returns the {@link FacetDecorator}s that are specified in the
+ * {@link IsisConfiguration} (using
+ * {@link ReflectorConstants#FACET_DECORATOR_CLASS_NAMES}) along with any
+ * {@link FacetDecorator}s explicitly registered using
+ * {@link #addFacetDecoratorInstaller(FacetDecoratorInstaller)}. created
+ * using the {@link FacetDecoratorInstaller}s.
+ */
+ protected Set<FacetDecorator> createFacetDecorators(final IsisConfiguration configuration) {
+ addFacetDecoratorInstallers(configuration);
+ return createFacetDecorators(decoratorInstallers);
+ }
+
+ private void addFacetDecoratorInstallers(final IsisConfiguration configuration) {
+ final String[] decoratorNames = configuration.getList(ReflectorConstants.FACET_DECORATOR_CLASS_NAMES);
+ for (final String decoratorName : decoratorNames) {
+ if (LOG.isInfoEnabled()) {
+ LOG.info("adding reflector facet decorator from configuration " + decoratorName);
+ }
+ addFacetDecoratorInstaller(lookupFacetDecorator(decoratorName));
+ }
+ }
+
+ private FacetDecoratorInstaller lookupFacetDecorator(final String decoratorClassName) {
+ return installerLookup.getInstaller(FacetDecoratorInstaller.class, decoratorClassName);
+ }
+
+ private Set<FacetDecorator> createFacetDecorators(final Set<FacetDecoratorInstaller> decoratorInstallers) {
+ final LinkedHashSet<FacetDecorator> decorators = new LinkedHashSet<FacetDecorator>();
+ if (decoratorInstallers.size() == 0) {
+ if (LOG.isInfoEnabled()) {
+ LOG.info("No facet decorators installers added");
+ }
+ }
+ for (final FacetDecoratorInstaller installer : decoratorInstallers) {
+ decorators.addAll(installer.createDecorators());
+ }
+ return Collections.unmodifiableSet(decorators);
+ }
+
+ // /////////////////////////////////////////////////////
+ // Optionally Injected: InstallerLookup
+ // /////////////////////////////////////////////////////
+
+ /**
+ * Injected by virtue of being {@link InstallerLookupAware}.
+ */
+ @Override
+ public void setInstallerLookup(final InstallerLookup installerLookup) {
+ this.installerLookup = installerLookup;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/Constants.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/Constants.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/Constants.java
new file mode 100644
index 0000000..00e6ffd
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/Constants.java
@@ -0,0 +1,83 @@
+/*
+ * 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.runner;
+
+import org.apache.isis.core.metamodel.specloader.ObjectReflectorInstaller;
+import org.apache.isis.core.runtime.logging.LoggingConstants;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.IsisViewerInstaller;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.PersistenceMechanismInstaller;
+import org.apache.isis.runtimes.dflt.runtime.system.DeploymentType;
+import org.apache.isis.runtimes.dflt.runtime.userprofile.UserProfileStoreInstaller;
+
+public final class Constants {
+
+ private Constants() {
+ }
+
+ public static final String TYPE_OPT = "t";
+ public static final String TYPE_LONG_OPT = "type";
+ public static final String TYPE_EXPLORATION = DeploymentType.EXPLORATION.friendlyName();
+ public static final String TYPE_PROTOTYPE = DeploymentType.PROTOTYPE.friendlyName();
+ public static final String TYPE_SINGLE_USER = DeploymentType.SINGLE_USER.friendlyName();
+ public static final String TYPE_CLIENT = DeploymentType.CLIENT.friendlyName();
+ public static final String TYPE_SERVER_EXPLORATION = DeploymentType.SERVER_EXPLORATION.friendlyName();
+ public static final String TYPE_SERVER_PROTOTYPE = DeploymentType.SERVER_PROTOTYPE.friendlyName();
+ public static final String TYPE_SERVER = DeploymentType.SERVER.friendlyName();
+
+ public static final String REFLECTOR_OPT = "l";
+ public static final String REFLECTOR_LONG_OPT = ObjectReflectorInstaller.TYPE;
+
+ public static final String OBJECT_PERSISTENCE_OPT = "r";
+ public static final String OBJECT_PERSISTENCE_LONG_OPT = PersistenceMechanismInstaller.TYPE;
+
+ public static final String USER_PROFILE_STORE_OPT = "e";
+ public static final String USER_PROFILE_STORE_LONG_OPT = UserProfileStoreInstaller.TYPE;
+
+ public static final String VIEWER_OPT = "v";
+ public static final String VIEWER_LONG_OPT = IsisViewerInstaller.TYPE;
+
+ public static final String CONFIGURATION_OPT = "c";
+ public static final String CONFIGURATION_LONG_OPT = "config";
+
+ public static final String FIXTURE_OPT = "f";
+ public static final String FIXTURE_LONG_OPT = "fixture";
+
+ public static final String HELP_OPT = "h";
+ public static final String HELP_LONG_OPT = "help";
+
+ public static final String NO_SPLASH_OPT = "s";
+ public static final String NO_SPLASH_LONG_OPT = "nosplash";
+
+ public static final String USER_OPT = "u";
+ public static final String USER_LONG_OPT = "user";
+
+ public static final String PASSWORD_OPT = "p";
+ public static final String PASSWORD_LONG_OPT = "password";
+
+ public static final String DIAGNOSTICS_OPT = "diagnostics";
+ public static final String VERSION_OPT = "version";
+
+ public static final String DEBUG_OPT = LoggingConstants.DEBUG_OPT;
+ public static final String VERBOSE_OPT = LoggingConstants.VERBOSE_OPT;
+ public static final String QUIET_OPT = LoggingConstants.QUIET_OPT;
+
+ public static final String ADDITIONAL_PROPERTY = "D";
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/dbb64345/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/IsisBootstrapper.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/IsisBootstrapper.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/IsisBootstrapper.java
new file mode 100644
index 0000000..76af9eb
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/IsisBootstrapper.java
@@ -0,0 +1,29 @@
+/*
+ * 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.runner;
+
+import com.google.inject.Injector;
+
+public interface IsisBootstrapper {
+ public void bootstrap(Injector injector);
+}
\ 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/runner/IsisModule.java
----------------------------------------------------------------------
diff --git a/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/IsisModule.java b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/IsisModule.java
new file mode 100644
index 0000000..8a50542
--- /dev/null
+++ b/framework/core/runtime/src/main/java/org/apache/isis/runtimes/dflt/runtime/runner/IsisModule.java
@@ -0,0 +1,189 @@
+/*
+ * 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.runner;
+
+import java.util.Collections;
+import java.util.List;
+
+import com.google.common.collect.Lists;
+import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Provides;
+import com.google.inject.Singleton;
+
+import org.apache.isis.core.commons.config.IsisConfigurationBuilder;
+import org.apache.isis.core.commons.config.IsisConfigurationBuilderDefault;
+import org.apache.isis.core.commons.config.IsisConfigurationBuilderPrimer;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.InstallerLookup;
+import org.apache.isis.runtimes.dflt.runtime.installerregistry.installerapi.IsisViewerInstaller;
+import org.apache.isis.runtimes.dflt.runtime.installers.InstallerLookupDefault;
+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.systemusinginstallers.IsisSystemThatUsesInstallersFactory;
+import org.apache.isis.runtimes.dflt.runtime.viewer.IsisViewer;
+
+public class IsisModule extends AbstractModule {
+
+ private final DeploymentType deploymentType;
+ private final InstallerLookup installerLookup;
+ private final IsisConfigurationBuilder isisConfigurationBuilder;
+
+ private final List<IsisConfigurationBuilderPrimer> isisConfigurationBuilderPrimers = Lists.newArrayList();
+ private final List<String> viewerNames = Lists.newArrayList();
+
+ private static InstallerLookupDefault defaultInstallerLookup() {
+ return new InstallerLookupDefault();
+ }
+
+ private static IsisConfigurationBuilderDefault defaultConfigurationBuider() {
+ return new IsisConfigurationBuilderDefault();
+ }
+
+ public IsisModule(final DeploymentType deploymentType) {
+ this(deploymentType, defaultConfigurationBuider(), defaultInstallerLookup());
+ }
+
+ public IsisModule(final DeploymentType deploymentType, final IsisConfigurationBuilder isisConfigurationBuilder) {
+ this(deploymentType, isisConfigurationBuilder, defaultInstallerLookup());
+ }
+
+ public IsisModule(final DeploymentType deploymentType, final InstallerLookup installerLookup) {
+ this(deploymentType, defaultConfigurationBuider(), installerLookup);
+ }
+
+ public IsisModule(final DeploymentType deploymentType, final IsisConfigurationBuilder isisConfigurationBuilder, final InstallerLookup installerLookup) {
+ this.installerLookup = installerLookup;
+ this.isisConfigurationBuilder = isisConfigurationBuilder;
+ this.deploymentType = deploymentType;
+ }
+
+ /**
+ * As passed in or defaulted by the constructors.
+ */
+ @SuppressWarnings("unused")
+ @Provides
+ @Singleton
+ private DeploymentType provideDeploymentsType() {
+ return deploymentType;
+ }
+
+ /**
+ * As passed in or defaulted by the constructors.
+ */
+ @SuppressWarnings("unused")
+ @Provides
+ @Singleton
+ private IsisConfigurationBuilder providesConfigurationBuilder() {
+ return primeConfiguration(isisConfigurationBuilder);
+ }
+
+ private IsisConfigurationBuilder primeConfiguration(final IsisConfigurationBuilder configBuilder) {
+ for (final IsisConfigurationBuilderPrimer isisConfigurationBuilderPrimer : isisConfigurationBuilderPrimers) {
+ isisConfigurationBuilderPrimer.primeConfigurationBuilder(configBuilder);
+ }
+ return configBuilder;
+ }
+
+ /**
+ * As passed in or defaulted by the constructors.
+ */
+ @SuppressWarnings("unused")
+ @Provides
+ @Singleton
+ @Inject
+ private InstallerLookup providesInstallerLookup(final IsisConfigurationBuilder configBuilder) {
+ // wire up and initialize installer lookup
+ configBuilder.injectInto(installerLookup);
+ installerLookup.init();
+ return installerLookup;
+ }
+
+ /**
+ * Adjustment (as per GOOS book)
+ */
+ public void addConfigurationPrimers(final List<? extends IsisConfigurationBuilderPrimer> isisConfigurationBuilderPrimers) {
+ this.isisConfigurationBuilderPrimers.addAll(isisConfigurationBuilderPrimers);
+ }
+
+ /**
+ * Adjustment (as per GOOS book)
+ */
+ public void addViewerNames(final List<String> viewerNames) {
+ this.viewerNames.addAll(viewerNames);
+ }
+
+ @Override
+ protected void configure() {
+ requireBinding(DeploymentType.class);
+ requireBinding(IsisConfigurationBuilder.class);
+ requireBinding(InstallerLookup.class);
+ }
+
+ @SuppressWarnings("unused")
+ @Provides
+ @Inject
+ @Singleton
+ private IsisSystemFactory provideIsisSystemFactory(final InstallerLookup installerLookup) {
+ final IsisSystemThatUsesInstallersFactory systemFactory = new IsisSystemThatUsesInstallersFactory(installerLookup);
+ systemFactory.init();
+ return systemFactory;
+ }
+
+ @Provides
+ @Inject
+ @Singleton
+ protected IsisSystem provideIsisSystem(final DeploymentType deploymentType, final IsisSystemFactory systemFactory) {
+ final IsisSystem system = systemFactory.createSystem(deploymentType);
+ system.init();
+ return system;
+ }
+
+ public static class ViewerList {
+ private final List<IsisViewer> viewers;
+
+ public ViewerList(final List<IsisViewer> viewers) {
+ this.viewers = Collections.unmodifiableList(viewers);
+ }
+
+ public List<IsisViewer> getViewers() {
+ return viewers;
+ }
+ }
+
+ @SuppressWarnings("unused")
+ @Provides
+ @Inject
+ @Singleton
+ private ViewerList lookupViewers(final InstallerLookup installerLookup, final DeploymentType deploymentType) {
+
+ final List<String> viewersToStart = Lists.newArrayList(viewerNames);
+ deploymentType.addDefaultViewer(viewersToStart);
+
+ final List<IsisViewer> viewers = Lists.newArrayList();
+ for (final String requestedViewer : viewersToStart) {
+ final IsisViewerInstaller viewerInstaller = installerLookup.viewerInstaller(requestedViewer);
+ final IsisViewer viewer = viewerInstaller.createViewer();
+ viewers.add(viewer);
+ }
+ return new ViewerList(viewers);
+ }
+
+}
\ No newline at end of file