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 2014/11/07 04:46:49 UTC
[25/29] isis git commit: ISIS-939: simplifying PersistenceSession
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
index af1619f..8d4c1cb 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession.java
@@ -18,7 +18,6 @@
*/
package org.apache.isis.core.runtime.system.persistence;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Lists;
@@ -26,8 +25,6 @@ import com.google.common.collect.Maps;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.isis.applib.query.Query;
-import org.apache.isis.applib.query.QueryDefault;
-import org.apache.isis.applib.query.QueryFindAllInstances;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.components.ApplicationScopedComponent;
import org.apache.isis.core.commons.components.SessionScopedComponent;
@@ -48,10 +45,7 @@ import org.apache.isis.core.metamodel.facets.object.viewmodel.ViewModelFacet;
import org.apache.isis.core.metamodel.services.ServiceUtil;
import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
import org.apache.isis.core.metamodel.services.container.query.QueryCardinality;
-import org.apache.isis.core.metamodel.services.container.query.QueryFindByPattern;
-import org.apache.isis.core.metamodel.services.container.query.QueryFindByTitle;
import org.apache.isis.core.metamodel.spec.*;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.runtime.persistence.FixturesInstalledFlag;
import org.apache.isis.core.runtime.persistence.NotPersistableException;
import org.apache.isis.core.runtime.persistence.adapter.PojoAdapterFactory;
@@ -59,19 +53,19 @@ import org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDef
import org.apache.isis.core.runtime.persistence.adaptermanager.PojoRecreatorUnified;
import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithm;
import org.apache.isis.core.runtime.persistence.objectstore.algorithm.PersistAlgorithmUnified;
-import org.apache.isis.core.runtime.persistence.objectstore.algorithm.ToPersistObjectSet;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.CreateObjectCommand;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.DestroyObjectCommand;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.SaveObjectCommand;
-import org.apache.isis.core.runtime.persistence.query.*;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.*;
+import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
+import org.apache.isis.core.runtime.system.transaction.TransactionalClosureAbstract;
+import org.apache.isis.core.runtime.system.transaction.TransactionalClosureWithReturnAbstract;
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.*;
-public class PersistenceSession implements Persistor, EnlistedObjectDirtying, ToPersistObjectSet, RecreatedPojoRemapper, SessionScopedComponent, DebuggableWithTitle {
+public class PersistenceSession implements SessionScopedComponent, DebuggableWithTitle {
private static final Logger LOG = LoggerFactory.getLogger(PersistenceSession.class);
@@ -87,13 +81,14 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
private final ObjectStore objectStore;
private final Map<ObjectSpecId, RootOid> servicesByObjectType = Maps.newHashMap();
- private boolean dirtiableSupport;
+ private final PersistenceQueryFactory persistenceQueryFactory;
- /**
- * Injected using setter-based injection.
- */
private IsisTransactionManager transactionManager;
+ private boolean dirtiableSupport = true;
+
+
+
private static enum State {
NOT_INITIALIZED, OPEN, CLOSED
}
@@ -124,6 +119,10 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
this.oidGenerator = new OidGenerator(new IdentifierGeneratorUnified(configuration));
this.adapterManager = new AdapterManagerDefault(new PojoRecreatorUnified(configuration));
this.persistAlgorithm = new PersistAlgorithmUnified(configuration);
+ this.objectStore = objectStore;
+
+ this.persistenceQueryFactory = new PersistenceQueryFactory(getSpecificationLoader(), adapterManager);
+ this.transactionManager = new IsisTransactionManager(this, objectStore, servicesInjector);
setState(State.NOT_INITIALIZED);
@@ -131,7 +130,6 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
LOG.debug("creating " + this);
}
- this.objectStore = objectStore;
}
// ///////////////////////////////////////////////////////////////////////////
@@ -208,7 +206,7 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
ObjectAdapter serviceAdapter =
existingOid == null
? getAdapterManager().adapterFor(service)
- : mapRecreatedPojo(existingOid, service);
+ : getAdapterManager().mapRecreatedPojo(existingOid, service);
if (serviceAdapter.getOid().isTransient()) {
adapterManager.remapAsPersistent(serviceAdapter, null);
}
@@ -287,7 +285,27 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
// Factory
// ///////////////////////////////////////////////////////////////////////////
- @Override
+ /**
+ * Create a root or standalone {@link ObjectAdapter adapter}.
+ *
+ * <p>
+ * Creates a new instance of the specified type and returns it in an adapter
+ * whose resolved state set to {@link ResolveState#TRANSIENT} (except if the
+ * type is marked as {@link ObjectSpecification#isValueOrIsParented()
+ * aggregated} in which case it will be set to {@link ResolveState#VALUE}).
+ *
+ * <p>
+ * The returned object will be initialised (had the relevant callback
+ * lifecycle methods invoked).
+ *
+ * <p>
+ * While creating the object it will be initialised with default values and
+ * its created lifecycle method (its logical constructor) will be invoked.
+ *
+ * <p>
+ * This method is ultimately delegated to by the
+ * {@link org.apache.isis.applib.DomainObjectContainer}.
+ */
public ObjectAdapter createTransientInstance(final ObjectSpecification objectSpec) {
if (LOG.isDebugEnabled()) {
LOG.debug("creating transient instance of " + objectSpec);
@@ -308,7 +326,20 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
return objectSpec.initialize(adapter);
}
- @Override
+ /**
+ * Creates a new instance of the specified type and returns an adapter with
+ * an aggregated OID that show that this new object belongs to the specified
+ * parent. The new object's resolved state is set to
+ * {@link ResolveState#RESOLVED} as it state is part of it parent.
+ *
+ * <p>
+ * While creating the object it will be initialised with default values and
+ * its created lifecycle method (its logical constructor) will be invoked.
+ *
+ * <p>
+ * This method is ultimately delegated to by the
+ * {@link org.apache.isis.applib.DomainObjectContainer}.
+ */
public ObjectAdapter createAggregatedInstance(final ObjectSpecification objectSpec, final ObjectAdapter parentAdapter) {
if (LOG.isDebugEnabled()) {
LOG.debug("creating aggregated instance of " + objectSpec);
@@ -328,7 +359,16 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
// findInstances, getInstances
// ///////////////////////////////////////////////////////////////////////////
- @Override
+ /**
+ * Finds and returns instances that match the specified query.
+ *
+ * <p>
+ * The {@link QueryCardinality} determines whether all instances or just the
+ * first matching instance is returned.
+ *
+ * @throws org.apache.isis.core.runtime.persistence.UnsupportedFindException
+ * if the criteria is not support by this persistor
+ */
public <T> ObjectAdapter findInstances(final Query<T> query, final QueryCardinality cardinality) {
final PersistenceQuery persistenceQuery = createPersistenceQueryFor(query, cardinality);
if (persistenceQuery == null) {
@@ -337,7 +377,19 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
return findInstances(persistenceQuery);
}
- @Override
+ /**
+ * Finds and returns instances that match the specified
+ * {@link PersistenceQuery}.
+ *
+ * <p>
+ * Compared to {@link #findInstances(Query, QueryCardinality)}, not that
+ * there is no {@link QueryCardinality} parameter. That's because
+ * {@link PersistenceQuery} intrinsically carry the knowledge as to how many
+ * rows they return.
+ *
+ * @throws org.apache.isis.core.runtime.persistence.UnsupportedFindException
+ * if the criteria is not support by this persistor
+ */
public ObjectAdapter findInstances(final PersistenceQuery persistenceQuery) {
final List<ObjectAdapter> instances = getInstances(persistenceQuery);
final ObjectSpecification specification = persistenceQuery.getSpecification();
@@ -350,53 +402,9 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
* {@link PersistenceQuery NOF-internal representation}.
*/
protected final PersistenceQuery createPersistenceQueryFor(final Query<?> query, final QueryCardinality cardinality) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("createPersistenceQueryFor: " + query.getDescription());
- }
- final ObjectSpecification noSpec = specFor(query);
- if (query instanceof QueryFindAllInstances) {
- final QueryFindAllInstances<?> queryFindAllInstances = (QueryFindAllInstances<?>) query;
- return new PersistenceQueryFindAllInstances(noSpec, queryFindAllInstances.getStart(), queryFindAllInstances.getCount());
- }
- if (query instanceof QueryFindByTitle) {
- final QueryFindByTitle<?> queryByTitle = (QueryFindByTitle<?>) query;
- final String title = queryByTitle.getTitle();
- return new PersistenceQueryFindByTitle(noSpec, title, queryByTitle.getStart(), queryByTitle.getCount());
- }
- if (query instanceof QueryFindByPattern) {
- final QueryFindByPattern<?> queryByPattern = (QueryFindByPattern<?>) query;
- final Object pattern = queryByPattern.getPattern();
- final ObjectAdapter patternAdapter = getAdapterManager().adapterFor(pattern);
- return new PersistenceQueryFindByPattern(noSpec, patternAdapter, queryByPattern.getStart(), queryByPattern.getCount());
- }
- if (query instanceof QueryDefault) {
- final QueryDefault<?> queryDefault = (QueryDefault<?>) query;
- final String queryName = queryDefault.getQueryName();
- final Map<String, ObjectAdapter> argumentsAdaptersByParameterName = wrap(queryDefault.getArgumentsByParameterName());
- return new PersistenceQueryFindUsingApplibQueryDefault(noSpec, queryName, argumentsAdaptersByParameterName, cardinality, queryDefault.getStart(), queryDefault.getCount());
- }
- // fallback; generic serializable applib query.
- return new PersistenceQueryFindUsingApplibQuerySerializable(noSpec, query, cardinality);
+ return persistenceQueryFactory.createPersistenceQueryFor(query, cardinality);
}
- private ObjectSpecification specFor(final Query<?> query) {
- return getSpecificationLoader().loadSpecification(query.getResultType());
- }
-
- /**
- * Converts a map of pojos keyed by string to a map of adapters keyed by the
- * same strings.
- */
- private Map<String, ObjectAdapter> wrap(final Map<String, Object> argumentsByParameterName) {
- final Map<String, ObjectAdapter> argumentsAdaptersByParameterName = new HashMap<String, ObjectAdapter>();
- for (final Map.Entry<String, Object> entry : argumentsByParameterName.entrySet()) {
- final String parameterName = entry.getKey();
- final Object argument = argumentsByParameterName.get(parameterName);
- final ObjectAdapter argumentAdapter = argument != null ? getAdapterManager().adapterFor(argument) : null;
- argumentsAdaptersByParameterName.put(parameterName, argumentAdapter);
- }
- return argumentsAdaptersByParameterName;
- }
protected List<ObjectAdapter> getInstances(final PersistenceQuery persistenceQuery) {
if (LOG.isDebugEnabled()) {
@@ -423,19 +431,10 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
// Manual dirtying support
// ///////////////////////////////////////////////////////////////////////////
- /**
- * @see #setDirtiableSupport(boolean)
- */
public boolean isCheckObjectsForDirtyFlag() {
return dirtiableSupport;
}
- /**
- * Whether to notice {@link Dirtiable manually-dirtied} objects.
- */
- public void setDirtiableSupport(final boolean checkObjectsForDirtyFlag) {
- this.dirtiableSupport = checkObjectsForDirtyFlag;
- }
/**
* Mark as {@link #objectChanged(ObjectAdapter) changed } all
@@ -451,7 +450,6 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
* <p>
* Called by the {@link IsisTransactionManager}.
*/
- @Override
public void objectChangedAllDirty() {
if (!dirtiableSupport) {
return;
@@ -471,7 +469,10 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
}
}
- @Override
+ /**
+ * Set as {@link Dirtiable#clearDirty(ObjectAdapter) clean} any
+ * {@link Dirtiable} objects.
+ */
public synchronized void clearAllDirty() {
if (!isCheckObjectsForDirtyFlag()) {
return;
@@ -510,18 +511,6 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
objectStore.registerService(rootOid);
}
- public ObjectAdapter getService(final String id) {
- for (final Object service : servicesInjector.getRegisteredServices()) {
- // TODO this (ServiceUtil) uses reflection to access the service
- // object; it should use the
- // reflector, ie call allServices first and use the returned array
- if (id.equals(ServiceUtil.id(service))) {
- return getService(service);
- }
- }
- return null;
- }
-
// REVIEW why does this get called multiple times when starting up
public List<ObjectAdapter> getServices() {
final List<Object> services = servicesInjector.getRegisteredServices();
@@ -535,19 +524,12 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
private ObjectAdapter getService(final Object servicePojo) {
final ObjectSpecification serviceSpecification = getSpecificationLoader().loadSpecification(servicePojo.getClass());
final RootOid oid = getOidForService(serviceSpecification);
- final ObjectAdapter serviceAdapter = mapRecreatedPojo(oid, servicePojo);
+ final ObjectAdapter serviceAdapter = getAdapterManager().mapRecreatedPojo(oid, servicePojo);
serviceAdapter.markAsResolvedIfPossible();
return serviceAdapter;
}
- /**
- * Has any services.
- */
- public boolean hasServices() {
- return servicesInjector.getRegisteredServices().size() > 0;
- }
-
private RootOid getOidForServiceFromPersistenceLayer(ObjectSpecification serviceSpecification) {
final ObjectSpecId objectSpecId = serviceSpecification.getSpecId();
RootOid oid = servicesByObjectType.get(objectSpecId);
@@ -587,15 +569,10 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
*/
public boolean isFixturesInstalled() {
final PersistenceSessionFactory persistenceSessionFactory = getPersistenceSessionFactory();
- if (persistenceSessionFactory instanceof FixturesInstalledFlag) {
- final FixturesInstalledFlag fixturesInstalledFlag = (FixturesInstalledFlag) persistenceSessionFactory;
- if (fixturesInstalledFlag.isFixturesInstalled() == null) {
- fixturesInstalledFlag.setFixturesInstalled(objectStore.isFixturesInstalled());
- }
- return fixturesInstalledFlag.isFixturesInstalled();
- } else {
- return objectStore.isFixturesInstalled();
+ if (persistenceSessionFactory.isFixturesInstalled() == null) {
+ persistenceSessionFactory.setFixturesInstalled(objectStore.isFixturesInstalled());
}
+ return persistenceSessionFactory.isFixturesInstalled();
}
@Override
@@ -608,7 +585,10 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
// loadObject, reload
// ///////////////////////////////////////////////////////////////////////////
- @Override
+ /**
+ * Loads the object identified by the specified {@link TypedOid} from the
+ * persisted set of objects.
+ */
public ObjectAdapter loadObject(final TypedOid oid) {
// REVIEW:
@@ -642,7 +622,11 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
// resolveImmediately, resolveField
// ///////////////////////////////////////////////////////////////////////////
- @Override
+ /**
+ * Re-initialises the fields of an object. If the object is unresolved then
+ * the object's missing data should be retrieved from the persistence
+ * mechanism and be used to set up the value objects and associations.
+ */
public void resolveImmediately(final ObjectAdapter adapter) {
// synchronize on the current session because getting race
// conditions, I think between different UI threads when running
@@ -695,49 +679,28 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
});
}
- @Override
- public void resolveField(final ObjectAdapter objectAdapter, final ObjectAssociation field) {
- if (field.isNotPersisted()) {
- return;
- }
- if (field.isOneToManyAssociation()) {
- return;
- }
- if (field.getSpecification().isParented()) {
- return;
- }
- if (field.getSpecification().isValue()) {
- return;
- }
- final ObjectAdapter referenceAdapter = field.get(objectAdapter);
- if (referenceAdapter == null || referenceAdapter.isResolved()) {
- return;
- }
- if (!referenceAdapter.representsPersistent()) {
- return;
- }
- if (LOG.isInfoEnabled()) {
- // don't log object - it's toString() may use the unresolved field
- // or unresolved collection
- LOG.info("resolve field " + objectAdapter.getSpecification().getShortIdentifier() + "." + field.getId() + ": " + referenceAdapter.getSpecification().getShortIdentifier() + " " + referenceAdapter.getResolveState().code() + " " + referenceAdapter.getOid());
- }
- resolveFieldFromPersistenceLayer(objectAdapter, field);
- }
-
- private void resolveFieldFromPersistenceLayer(final ObjectAdapter objectAdapter, final ObjectAssociation field) {
- getTransactionManager().executeWithinTransaction(new TransactionalClosureAbstract() {
- @Override
- public void execute() {
- objectStore.resolveField(objectAdapter, field);
- }
- });
- }
-
// ////////////////////////////////////////////////////////////////
// makePersistent
// ////////////////////////////////////////////////////////////////
- @Override
+ /**
+ * Makes an {@link ObjectAdapter} persistent. The specified object should be
+ * stored away via this object store's persistence mechanism, and have an
+ * new and unique OID assigned to it. The object, should also be added to
+ * the {@link org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault} as the object is implicitly 'in use'.
+ *
+ * <p>
+ * If the object has any associations then each of these, where they aren't
+ * already persistent, should also be made persistent by recursively calling
+ * this method.
+ *
+ * <p>
+ * If the object to be persisted is a collection, then each element of that
+ * collection, that is not already persistent, should be made persistent by
+ * recursively calling this method.
+ *
+ * @see #remapAsPersistent(ObjectAdapter)
+ */
public void makePersistent(final ObjectAdapter adapter) {
if (adapter.representsPersistent()) {
throw new NotPersistableException("Object already persistent: " + adapter);
@@ -784,7 +747,10 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
// objectChanged
// ///////////////////////////////////////////////////////////////////////////
- @Override
+ /**
+ * Mark the {@link ObjectAdapter} as changed, and therefore requiring
+ * flushing to the persistence mechanism.
+ */
public void objectChanged(final ObjectAdapter adapter) {
if (adapter.isTransient() || (adapter.isParented() && adapter.getAggregateRoot().isTransient())) {
@@ -842,7 +808,10 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
// destroyObject
// ///////////////////////////////////////////////////////////////////////////
- @Override
+ /**
+ * Removes the specified object from the system. The specified object's data
+ * should be removed from the persistence mechanism.
+ */
public void destroyObject(final ObjectAdapter adapter) {
ObjectSpecification spec = adapter.getSpecification();
if (spec.isParented()) {
@@ -879,52 +848,6 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
});
}
- // ///////////////////////////////////////////////////////////////////////////
- // hasInstances
- // ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean hasInstances(final ObjectSpecification specification) {
- if (LOG.isInfoEnabled()) {
- LOG.info("hasInstances of " + specification.getShortIdentifier());
- }
- return hasInstancesFromPersistenceLayer(specification);
- }
-
- private boolean hasInstancesFromPersistenceLayer(final ObjectSpecification specification) {
- return getTransactionManager().executeWithinTransaction(new TransactionalClosureWithReturnAbstract<Boolean>() {
- @Override
- public Boolean execute() {
- return objectStore.hasInstances(specification);
- }
- });
- }
-
- // ///////////////////////////////////////////////////////////////////////////
- // RecreatedPojoRemapper
- // ///////////////////////////////////////////////////////////////////////////
-
- @Override
- public ObjectAdapter mapRecreatedPojo(Oid oid, Object recreatedPojo) {
- return adapterManager.mapRecreatedPojo(oid, recreatedPojo);
- }
-
- @Override
- public void remapRecreatedPojo(ObjectAdapter adapter, Object recreatedPojo) {
- adapterManager.remapRecreatedPojo(adapter, recreatedPojo);
- }
-
- // ///////////////////////////////////////////////////////////////////////////
- // AdapterLifecycleTransitioner
- // ///////////////////////////////////////////////////////////////////////////
-
- public void remapAsPersistent(ObjectAdapter adapter, RootOid hintRootOid) {
- adapterManager.remapAsPersistent(adapter, hintRootOid);
- }
-
- public void removeAdapter(ObjectAdapter adapter) {
- adapterManager.removeAdapter(adapter);
- }
// ///////////////////////////////////////////////////////////////////////////
// ToPersistObjectSet
@@ -950,7 +873,6 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
*
* @see #remapAsPersistent(ObjectAdapter)
*/
- @Override
public void remapAsPersistent(final ObjectAdapter adapter) {
final Oid transientOid = adapter.getOid();
adapterManager.remapAsPersistent(adapter, null);
@@ -958,7 +880,10 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
persistentByTransient.put(transientOid, persistentOid);
}
- @Override
+ /**
+ * 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.
+ */
public Oid remappedFrom(Oid transientOid) {
return persistentByTransient.get(transientOid);
}
@@ -969,7 +894,6 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
* {@link CreateObjectCommand}, and adds to the
* {@link IsisTransactionManager}.
*/
- @Override
public void addCreateObjectCommand(final ObjectAdapter object) {
getTransactionManager().addCommand(objectStore.createCreateObjectCommand(object));
}
@@ -1086,11 +1010,16 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
/**
* The configured {@link AdapterManager}.
- *
+ *
+ * Access to looking up (and possibly lazily loading) adapters.
+ *
+ * <p>
+ * However, manipulating of adapters is not part of this interface.
+ *
* <p>
* Injected in constructor.
*/
- public final AdapterManager getAdapterManager() {
+ public final AdapterManagerDefault getAdapterManager() {
return adapterManager;
}
@@ -1116,28 +1045,17 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
// ///////////////////////////////////////////////////////////////////////////
/**
- * Inject the {@link IsisTransactionManager}.
- *
- * <p>
- * This must be injected using setter-based injection rather than through
- * the constructor because there is a bidirectional relationship between the
- * this class and the {@link IsisTransactionManager}.
- *
- * @see #getTransactionManager()
- */
- public void setTransactionManager(final IsisTransactionManager transactionManager) {
- this.transactionManager = transactionManager;
- }
-
- /**
* The configured {@link IsisTransactionManager}.
- *
- * @see #setTransactionManager(IsisTransactionManager)
*/
public IsisTransactionManager getTransactionManager() {
return transactionManager;
}
+ // for testing only
+ void setTransactionManager(IsisTransactionManager transactionManager) {
+ this.transactionManager = transactionManager;
+ }
+
// ///////////////////////////////////////////////////////////////////////////
// Dependencies (from context)
// ///////////////////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
index cb3b320..2b203a2 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionFactory.java
@@ -39,7 +39,6 @@ import org.apache.isis.core.runtime.persistence.ObjectStoreFactory;
import org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession;
import org.apache.isis.core.runtime.system.DeploymentType;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
@@ -96,12 +95,8 @@ public class PersistenceSessionFactory implements MetaModelRefiner, ApplicationS
ensureThatArg(objectStore, is(not(nullValue())));
- final PersistenceSession persistenceSession =new PersistenceSession(this, servicesInjector, objectStore, getConfiguration());
+ final PersistenceSession persistenceSession = new PersistenceSession(this, servicesInjector, objectStore, getConfiguration());
- final IsisTransactionManager transactionManager = new IsisTransactionManager(persistenceSession, objectStore, servicesInjector);
-
- persistenceSession.setDirtiableSupport(true);
- persistenceSession.setTransactionManager(transactionManager);
return persistenceSession;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/Persistor.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/Persistor.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/Persistor.java
deleted file mode 100644
index 11b4091..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/Persistor.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.isis.core.runtime.system.persistence;
-
-import org.apache.isis.applib.DomainObjectContainer;
-import org.apache.isis.applib.query.Query;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.oid.TypedOid;
-import org.apache.isis.core.metamodel.services.container.query.QueryCardinality;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
-import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-import org.apache.isis.core.runtime.persistence.UnsupportedFindException;
-import org.apache.isis.core.runtime.persistence.internal.RuntimeContextFromSession;
-
-/**
- * Represents the client-side API of the <tt>PersistenceSession</tt>.
- */
-public interface Persistor {
-
-
- /////////////////////////////////////////////////////////////////
- // AdapterManager
- /////////////////////////////////////////////////////////////////
-
- /**
- * Access to looking up (and possibly lazily loading) adapters.
- *
- * <p>
- * However, manipulating of adapters is not part of this interface.
- * @return
- */
- public abstract AdapterManager getAdapterManager();
-
-
- /////////////////////////////////////////////////////////////////
- // find, load, resolve
- /////////////////////////////////////////////////////////////////
-
-
- /**
- * Finds and returns instances that match the specified query.
- *
- * <p>
- * The {@link QueryCardinality} determines whether all instances or just the
- * first matching instance is returned.
- *
- * @throws UnsupportedFindException
- * if the criteria is not support by this persistor
- */
- public abstract <T> ObjectAdapter findInstances(Query<T> query, QueryCardinality cardinality);
-
- /**
- * Whether there are any instances of the specified
- * {@link ObjectSpecification type}.
- *
- * <p>
- * Checks whether there are any instances of the specified type. The object
- * store should look for instances of the type represented by <variable>type
- * </variable> and return <code>true</code> if there are, or
- * <code>false</code> if there are not.
- *
- * <p>
- * Used (ostensibly) by client-side code.
- */
- public abstract boolean hasInstances(ObjectSpecification specification);
-
- /**
- * Finds and returns instances that match the specified
- * {@link PersistenceQuery}.
- *
- * <p>
- * Compared to {@link #findInstances(Query, QueryCardinality)}, not that
- * there is no {@link QueryCardinality} parameter. That's because
- * {@link PersistenceQuery} intrinsically carry the knowledge as to how many
- * rows they return.
- *
- * @throws UnsupportedFindException
- * if the criteria is not support by this persistor
- */
- public abstract ObjectAdapter findInstances(PersistenceQuery persistenceQuery);
-
- /**
- * Loads the object identified by the specified {@link TypedOid} from the
- * persisted set of objects.
- */
- public abstract ObjectAdapter loadObject(TypedOid oid);
-
-
- /**
- * Re-initialises the fields of an object. If the object is unresolved then
- * the object's missing data should be retrieved from the persistence
- * mechanism and be used to set up the value objects and associations.
- */
- public abstract void resolveImmediately(ObjectAdapter adapter);
-
- /**
- * Hint that specified field within the specified object is likely to be
- * needed soon. This allows the object's data to be loaded, ready for use.
- *
- * <p>
- * This method need not do anything, but offers the object store the
- * opportunity to load in objects before their use. Contrast this with
- * resolveImmediately, which requires an object to be loaded before
- * continuing.
- *
- * @see #resolveImmediately(ObjectAdapter)
- */
- public abstract void resolveField(ObjectAdapter objectAdapter, ObjectAssociation field);
-
-
-
- /////////////////////////////////////////////////////////////////
- // create, persist
- /////////////////////////////////////////////////////////////////
-
- /**
- * Create a root or standalone {@link ObjectAdapter adapter}.
- *
- * <p>
- * Creates a new instance of the specified type and returns it in an adapter
- * whose resolved state set to {@link ResolveState#TRANSIENT} (except if the
- * type is marked as {@link ObjectSpecification#isValueOrIsParented()
- * aggregated} in which case it will be set to {@link ResolveState#VALUE}).
- *
- * <p>
- * The returned object will be initialised (had the relevant callback
- * lifecycle methods invoked).
- *
- * <p>
- * <b><i> REVIEW: not sure about {@link ResolveState#VALUE} - see comments
- * in {@link #adapterFor(Object, Oid, OneToManyAssociation)}.</i></b>
- * <p>
- * TODO: this is the same as
- * {@link RuntimeContextFromSession#createTransientInstance(ObjectSpecification)};
- * could it be unified?
- *
- * <p>
- * While creating the object it will be initialised with default values and
- * its created lifecycle method (its logical constructor) will be invoked.
- * Contrast this with
- * {@link #recreateTransientInstance(Oid, ObjectSpecification)}.
- *
- * <p>
- * This method is ultimately delegated to by the
- * {@link DomainObjectContainer}.
- */
- public abstract ObjectAdapter createTransientInstance(ObjectSpecification objectSpec);
-
- /**
- * Creates a new instance of the specified type and returns an adapter with
- * an aggregated OID that show that this new object belongs to the specified
- * parent. The new object's resolved state is set to
- * {@link ResolveState#RESOLVED} as it state is part of it parent.
- *
- * <p>
- * While creating the object it will be initialised with default values and
- * its created lifecycle method (its logical constructor) will be invoked.
- * Contrast this with
- * {@link #recreateTransientInstance(Oid, ObjectSpecification)}.
- *
- * <p>
- * This method is ultimately delegated to by the
- * {@link DomainObjectContainer}.
- */
- public abstract ObjectAdapter createAggregatedInstance(ObjectSpecification objectSpec, ObjectAdapter parentAdapter);
-
- /**
- * Makes an {@link ObjectAdapter} persistent. The specified object should be
- * stored away via this object store's persistence mechanism, and have an
- * new and unique OID assigned to it. The object, should also be added to
- * the {@link org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault} as the object is implicitly 'in use'.
- *
- * <p>
- * If the object has any associations then each of these, where they aren't
- * already persistent, should also be made persistent by recursively calling
- * this method.
- *
- * <p>
- * If the object to be persisted is a collection, then each element of that
- * collection, that is not already persistent, should be made persistent by
- * recursively calling this method.
- *
- * @see #remapAsPersistent(ObjectAdapter)
- */
- public abstract void makePersistent(ObjectAdapter adapter);
-
-
- /////////////////////////////////////////////////////////////////
- // change
- /////////////////////////////////////////////////////////////////
-
- /**
- * Mark the {@link ObjectAdapter} as changed, and therefore requiring
- * flushing to the persistence mechanism.
- */
- public abstract void objectChanged(ObjectAdapter adapter);
-
-
- /////////////////////////////////////////////////////////////////
- // destroy
- /////////////////////////////////////////////////////////////////
-
- /**
- * Removes the specified object from the system. The specified object's data
- * should be removed from the persistence mechanism.
- */
- public abstract void destroyObject(ObjectAdapter adapter);
-
-
-
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/RecreatedPojoRemapper.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/RecreatedPojoRemapper.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/RecreatedPojoRemapper.java
deleted file mode 100644
index ea89e21..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/RecreatedPojoRemapper.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.system.persistence;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.ResolveState;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-
-public interface RecreatedPojoRemapper {
-
- /**
- * Either returns an existing {@link ObjectAdapter adapter} (as per
- * {@link #getAdapterFor(Object)} or {@link #getAdapterFor(Oid)}), otherwise
- * re-creates an adapter with the specified (persistent) {@link Oid}.
- *
- * <p>
- * Typically called when the {@link Oid} is already known, that is, when
- * resolving an already-persisted object. Is also available for
- * <tt>Memento</tt> support however, so {@link Oid} could also represent a
- * {@link Oid#isTransient() transient} object.
- *
- * <p>
- * If the {@link ObjectAdapter adapter} is recreated, its
- * {@link ResolveState} will be set to either
- * {@link ResolveState#TRANSIENT} or {@link ResolveState#GHOST} based on
- * whether the {@link Oid} is {@link Oid#isTransient() transient} or not.
- *
- * @param oid
- * @param recreatedPojo - already known to the object store impl, or a service
- */
- ObjectAdapter mapRecreatedPojo(Oid oid, Object recreatedPojo);
-
- void remapRecreatedPojo(ObjectAdapter adapter, Object recreatedPojo);
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/EnlistedObjectDirtying.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/EnlistedObjectDirtying.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/EnlistedObjectDirtying.java
deleted file mode 100644
index 6efde67..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/EnlistedObjectDirtying.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.runtime.system.transaction;
-
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.spec.Dirtiable;
-
-/**
- * As called by the {@link IsisTransactionManager}.
- *
- * <p>
- * Dirtiable support.
- */
-public interface EnlistedObjectDirtying {
-
- /**
- * Mark as {@link #objectChanged(ObjectAdapter) changed } all
- * {@link Dirtiable} objects that have been
- * {@link Dirtiable#markDirty(ObjectAdapter) manually marked} as dirty.
- *
- * <p>
- * Called by the {@link IsisTransactionManager}.
- */
- void objectChangedAllDirty();
-
- /**
- * Set as {@link Dirtiable#clearDirty(ObjectAdapter) clean} any
- * {@link Dirtiable} objects.
- */
- void clearAllDirty();
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusObjectStore.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusObjectStore.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusObjectStore.java
index 0098d29..aa0d2c7 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusObjectStore.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/DataNucleusObjectStore.java
@@ -44,7 +44,6 @@ import org.apache.isis.core.metamodel.adapter.oid.*;
import org.apache.isis.core.metamodel.spec.ObjectSpecId;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.metamodel.spec.SpecificationLoaderSpi;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
import org.apache.isis.core.runtime.persistence.ObjectNotFoundException;
import org.apache.isis.core.runtime.persistence.PojoRefreshException;
import org.apache.isis.core.runtime.persistence.UnsupportedFindException;
@@ -375,7 +374,7 @@ public class DataNucleusObjectStore implements ObjectStore {
}
final Object pojo = loadPojo(oid);
- return getPersistenceSession().mapRecreatedPojo(oid, pojo);
+ return getPersistenceSession().getAdapterManager().mapRecreatedPojo(oid, pojo);
}
@@ -497,32 +496,7 @@ public class DataNucleusObjectStore implements ObjectStore {
frameworkSynchronizer.postLoadProcessingFor((PersistenceCapable) domainObject, CalledFrom.OS_RESOLVE);
}
- /**
- * Walking the graph.
- */
- public void resolveField(final ObjectAdapter object, final ObjectAssociation association) {
- ensureOpened();
- ensureInTransaction();
-
- final ObjectAdapter referencedCollectionAdapter = association.get(object);
-
- // this code originally brought in from the JPA impl, but seems reasonable.
- if (association.isOneToManyAssociation()) {
- ensureThatState(referencedCollectionAdapter, is(notNullValue()));
- final Object referencedCollection = referencedCollectionAdapter.getObject();
- ensureThatState(referencedCollection, is(notNullValue()));
-
- // if a proxy collection, then force it to initialize. just 'touching' the object is sufficient.
- // REVIEW: I wonder if this is actually needed; does JDO use proxy collections?
- referencedCollection.hashCode();
- }
-
- // the JPA impl used to also call its lifecycle listener on the referenced collection object, eg List,
- // itself. I don't think this makes sense to do for JDO (the collection is not a PersistenceCapable).
- }
-
-
// ///////////////////////////////////////////////////////////////////////
// getInstances, hasInstances
// ///////////////////////////////////////////////////////////////////////
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/FrameworkSynchronizer.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/FrameworkSynchronizer.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/FrameworkSynchronizer.java
index 94e9c34..66b7f1c 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/FrameworkSynchronizer.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/FrameworkSynchronizer.java
@@ -37,6 +37,7 @@ import org.apache.isis.core.metamodel.adapter.version.ConcurrencyException;
import org.apache.isis.core.metamodel.adapter.version.Version;
import org.apache.isis.core.metamodel.facets.object.callbacks.*;
import org.apache.isis.core.runtime.persistence.PersistorUtil;
+import org.apache.isis.core.runtime.persistence.adaptermanager.AdapterManagerDefault;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.OidGenerator;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
@@ -89,7 +90,7 @@ public class FrameworkSynchronizer {
final Version originalVersion = adapter.getVersion();
// sync the pojo held by the adapter with that just loaded
- getPersistenceSession().remapRecreatedPojo(adapter, pojo);
+ getPersistenceSession().getAdapterManager() .remapRecreatedPojo(adapter, pojo);
// since there was already an adapter, do concurrency check
// (but don't set abort cause if checking is suppressed through thread-local)
@@ -119,9 +120,9 @@ public class FrameworkSynchronizer {
// ie from ObjectStore#resolveImmediately()
adapter = getAdapterManager().getAdapterFor(originalOid);
if(adapter != null) {
- getPersistenceSession().remapRecreatedPojo(adapter, pojo);
+ getPersistenceSession().getAdapterManager() .remapRecreatedPojo(adapter, pojo);
} else {
- adapter = getPersistenceSession().mapRecreatedPojo(originalOid, pojo);
+ adapter = getPersistenceSession().getAdapterManager().mapRecreatedPojo(originalOid, pojo);
CallbackFacet.Util.callCallback(adapter, LoadedCallbackFacet.class);
}
}
@@ -201,7 +202,7 @@ public class FrameworkSynchronizer {
// persisting
final RootOid persistentOid = getOidGenerator().createPersistentOrViewModelOid(pojo, isisOid);
- getPersistenceSession().remapAsPersistent(adapter, persistentOid);
+ getPersistenceSession().getAdapterManager().remapAsPersistent(adapter, persistentOid);
CallbackFacet.Util.callCallback(adapter, PersistedCallbackFacet.class);
@@ -272,7 +273,7 @@ public class FrameworkSynchronizer {
return null;
}
final RootOid oid = getPersistenceSession().getOidGenerator().createPersistentOrViewModelOid(pojo, null);
- final ObjectAdapter adapter = getPersistenceSession().mapRecreatedPojo(oid, pojo);
+ final ObjectAdapter adapter = getPersistenceSession().getAdapterManager().mapRecreatedPojo(oid, pojo);
return adapter;
}
}, calledFrom);
@@ -431,7 +432,7 @@ public class FrameworkSynchronizer {
// Dependencies (from context)
// /////////////////////////////////////////////////////////
- protected AdapterManager getAdapterManager() {
+ protected AdapterManagerDefault getAdapterManager() {
return getPersistenceSession().getAdapterManager();
}
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
index 119ea19..d6d3eeb 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryProcessorAbstract.java
@@ -19,22 +19,19 @@
package org.apache.isis.objectstore.jdo.datanucleus.persistence.queries;
import java.util.List;
-
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.listener.InstanceLifecycleEvent;
import javax.jdo.metadata.TypeMetadata;
import javax.jdo.spi.PersistenceCapable;
-
import com.google.common.collect.Lists;
-
import org.apache.isis.core.commons.ensure.Assert;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.PersistenceQuery;
-import org.apache.isis.core.runtime.system.persistence.Persistor;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.objectstore.jdo.datanucleus.DataNucleusObjectStore;
import org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer;
import org.apache.isis.objectstore.jdo.datanucleus.persistence.FrameworkSynchronizer.CalledFrom;
@@ -98,7 +95,7 @@ public abstract class PersistenceQueryProcessorAbstract<T extends PersistenceQue
// Dependencies (from context)
// /////////////////////////////////////////////////////////////
- protected Persistor getPersistenceSession() {
+ protected PersistenceSession getPersistenceSession() {
return IsisContext.getPersistenceSession();
}
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
index aad312f..7a3086b 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/algorithm/PersistAlgorithmContractTest.java
@@ -34,6 +34,7 @@ import org.apache.isis.core.runtime.persistence.adapter.PojoAdapter;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Type;
+import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
@@ -43,7 +44,7 @@ public abstract class PersistAlgorithmContractTest {
public JUnitRuleMockery2 context = JUnitRuleMockery2.createFor(Mode.INTERFACES_AND_CLASSES);
@Mock
- private ToPersistObjectSet mockAdder;
+ private PersistenceSession mockAdder;
@Mock
private ObjectSpecification objectSpec;
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java
index f9645c8..3cf5d3a 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/persistence/PersistenceSessionTest.java
@@ -167,7 +167,8 @@ public class PersistenceSessionTest {
}});
- transactionManager = new IsisTransactionManager(persistenceSession, mockObjectStore, servicesInjector) {
+ transactionManager = persistenceSession.getTransactionManager();
+ new IsisTransactionManager(persistenceSession, mockObjectStore, servicesInjector) {
@Override
public AuthenticationSession getAuthenticationSession() {
return mockAuthenticationSession;
http://git-wip-us.apache.org/repos/asf/isis/blob/5f8fca9b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java
----------------------------------------------------------------------
diff --git a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java
index 131c418..cd449c8 100644
--- a/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java
+++ b/tck/tck-integtests/src/test/java/org/apache/isis/core/integtestsupport/IsisSystemWithFixtures.java
@@ -46,7 +46,6 @@ import org.apache.isis.core.runtime.system.DeploymentType;
import org.apache.isis.core.runtime.system.context.IsisContext;
import org.apache.isis.core.runtime.system.persistence.ObjectStore;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
-import org.apache.isis.core.runtime.system.persistence.Persistor;
import org.apache.isis.core.runtime.system.transaction.IsisTransaction;
import org.apache.isis.core.runtime.system.transaction.IsisTransaction.State;
import org.apache.isis.core.runtime.system.transaction.IsisTransactionManager;
@@ -514,7 +513,7 @@ public class IsisSystemWithFixtures implements org.junit.rules.TestRule {
public ObjectAdapter reload(RootOid oid) {
ensureSessionInProgress();
- final Persistor persistenceSession = getPersistenceSession();
+ final PersistenceSession persistenceSession = getPersistenceSession();
return persistenceSession.loadObject(oid);
}
@@ -527,7 +526,7 @@ public class IsisSystemWithFixtures implements org.junit.rules.TestRule {
ensureSessionInProgress();
ensureObjectIsNotPersistent(pojo);
final ObjectAdapter adapter = adapterFor(pojo);
- getPersistenceSession().remapAsPersistent(adapter, persistentOid);
+ getPersistenceSession().getAdapterManager().remapAsPersistent(adapter, persistentOid);
return adapter;
}
@@ -658,7 +657,7 @@ public class IsisSystemWithFixtures implements org.junit.rules.TestRule {
return getPersistenceSession().getTransactionManager();
}
- public Persistor getPersistor() {
+ public PersistenceSession getPersistor() {
return getPersistenceSession();
}