You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2015/09/11 00:09:11 UTC
[47/50] isis git commit: ISIS-1194: removed FrameworkSynchronizer
ISIS-1194: removed FrameworkSynchronizer
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/775871c2
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/775871c2
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/775871c2
Branch: refs/heads/master
Commit: 775871c22f61003044376eb4ad66f64d87fcab50
Parents: 1c2c625
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Thu Sep 10 17:29:55 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Thu Sep 10 17:29:55 2015 +0100
----------------------------------------------------------------------
.../persistence/FrameworkSynchronizer.java | 63 --------------------
.../persistence/IsisLifecycleListener2.java | 13 ++--
.../system/persistence/PersistenceSession.java | 47 ++++++++++-----
.../PersistenceQueryProcessorAbstract.java | 3 +-
4 files changed, 39 insertions(+), 87 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/775871c2/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java
deleted file mode 100644
index 33027f4..0000000
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/FrameworkSynchronizer.java
+++ /dev/null
@@ -1,63 +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.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
-
-public class FrameworkSynchronizer {
-
- private static final Logger LOG = LoggerFactory.getLogger(FrameworkSynchronizer.class);
-
- private final PersistenceSession persistenceSession;
- private final AuthenticationSession authenticationSession;
-
- public FrameworkSynchronizer(
- final PersistenceSession persistenceSession,
- final AuthenticationSession authenticationSession) {
- this.persistenceSession = persistenceSession;
- this.authenticationSession = authenticationSession;
-
- }
-
- /**
- * Categorises where called from.
- *
- * <p>
- * Just used for logging.
- */
- public enum CalledFrom {
- EVENT_LOAD,
- EVENT_PRESTORE,
- EVENT_POSTSTORE,
- EVENT_PREDIRTY,
- EVENT_POSTDIRTY,
- OS_QUERY,
- OS_RESOLVE,
- OS_LAZILYLOADED,
- EVENT_PREDELETE,
- EVENT_POSTDELETE
- }
-
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/775871c2/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IsisLifecycleListener2.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IsisLifecycleListener2.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IsisLifecycleListener2.java
index 57defda..2cdde35 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IsisLifecycleListener2.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/IsisLifecycleListener2.java
@@ -35,7 +35,6 @@ import com.google.common.collect.Maps;
import org.datanucleus.enhancement.Persistable;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.runtime.system.persistence.FrameworkSynchronizer.CalledFrom;
import org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener;
public class IsisLifecycleListener2
@@ -76,7 +75,7 @@ public class IsisLifecycleListener2
@Override
protected void doRun() {
final Persistable pojo = Utils.persistenceCapableFor(event);
- persistenceSession.postLoadProcessingFor(pojo, CalledFrom.EVENT_LOAD);
+ persistenceSession.postLoadProcessingFor(pojo, PersistenceSession.CalledFrom.EVENT_LOAD);
}});
}
@@ -86,7 +85,7 @@ public class IsisLifecycleListener2
@Override
protected void doRun() {
final Persistable pojo = Utils.persistenceCapableFor(event);
- persistenceSession.preStoreProcessingFor(pojo, CalledFrom.EVENT_PRESTORE);
+ persistenceSession.preStoreProcessingFor(pojo, PersistenceSession.CalledFrom.EVENT_PRESTORE);
}});
}
@@ -97,7 +96,7 @@ public class IsisLifecycleListener2
@Override
protected void doRun() {
final Persistable pojo = Utils.persistenceCapableFor(event);
- persistenceSession.postStoreProcessingFor(pojo, CalledFrom.EVENT_POSTSTORE);
+ persistenceSession.postStoreProcessingFor(pojo, PersistenceSession.CalledFrom.EVENT_POSTSTORE);
}});
}
@@ -107,7 +106,7 @@ public class IsisLifecycleListener2
@Override
protected void doRun() {
final Persistable pojo = Utils.persistenceCapableFor(event);
- persistenceSession.preDirtyProcessingFor(pojo, CalledFrom.EVENT_PREDIRTY);
+ persistenceSession.preDirtyProcessingFor(pojo, PersistenceSession.CalledFrom.EVENT_PREDIRTY);
}});
}
@@ -129,7 +128,7 @@ public class IsisLifecycleListener2
@Override
protected void doRun() {
final Persistable pojo = Utils.persistenceCapableFor(event);
- persistenceSession.preDeleteProcessingFor(pojo, CalledFrom.EVENT_PREDELETE);
+ persistenceSession.preDeleteProcessingFor(pojo, PersistenceSession.CalledFrom.EVENT_PREDELETE);
}
});
}
@@ -140,7 +139,7 @@ public class IsisLifecycleListener2
@Override
protected void doRun() {
final Persistable pojo = Utils.persistenceCapableFor(event);
- persistenceSession.postDeleteProcessingFor(pojo, CalledFrom.EVENT_POSTDELETE);
+ persistenceSession.postDeleteProcessingFor(pojo, PersistenceSession.CalledFrom.EVENT_POSTDELETE);
}
});
}
http://git-wip-us.apache.org/repos/asf/isis/blob/775871c2/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 19096f3..53ecf94 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
@@ -146,7 +146,6 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
// not final only for testing purposes
private IsisTransactionManager transactionManager;
- private final FrameworkSynchronizer frameworkSynchronizer;
private final OidMarshaller oidMarshaller;
/**
@@ -186,7 +185,6 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
// sub-components
this.oidMarshaller = new OidMarshaller();
- this.frameworkSynchronizer = new FrameworkSynchronizer(this, authenticationSession);
this.objectFactory = new ObjectFactory(this, servicesInjector);
this.oidGenerator = new OidGenerator(this, specificationLoader);
@@ -767,10 +765,10 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
return null;
}
final Persistable persistenceCapable = (Persistable) pojo;
- return lazilyLoaded(persistenceCapable, FrameworkSynchronizer.CalledFrom.OS_LAZILYLOADED);
+ return lazilyLoaded(persistenceCapable, CalledFrom.OS_LAZILYLOADED);
}
- private ObjectAdapter lazilyLoaded(final Persistable pojo, FrameworkSynchronizer.CalledFrom calledFrom) {
+ private ObjectAdapter lazilyLoaded(final Persistable pojo, CalledFrom calledFrom) {
return withLogging(pojo, new Callable<ObjectAdapter>() {
@Override
public ObjectAdapter call() {
@@ -838,7 +836,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
// possibly redundant because also called in the post-load event
// listener, but (with JPA impl) found it was required if we were ever to
// get an eager left-outer-join as the result of a refresh (sounds possible).
- postLoadProcessingFor((Persistable) domainObject, FrameworkSynchronizer.CalledFrom.OS_RESOLVE);
+ postLoadProcessingFor((Persistable) domainObject, CalledFrom.OS_RESOLVE);
}
//endregion
@@ -1226,7 +1224,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
//region > FrameworkSynchronizer delegate methods
- public void postDeleteProcessingFor(final Persistable pojo, final FrameworkSynchronizer.CalledFrom calledFrom) {
+ public void postDeleteProcessingFor(final Persistable pojo, final CalledFrom calledFrom) {
withLogging(pojo, new Runnable() {
@Override
public void run() {
@@ -1247,7 +1245,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
}
- public void preDeleteProcessingFor(final Persistable pojo, final FrameworkSynchronizer.CalledFrom calledFrom) {
+ public void preDeleteProcessingFor(final Persistable pojo, final CalledFrom calledFrom) {
withLogging(pojo, new Runnable() {
@Override
public void run() {
@@ -1263,7 +1261,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
}
- public void postLoadProcessingFor(final Persistable pojo, FrameworkSynchronizer.CalledFrom calledFrom) {
+ public void postLoadProcessingFor(final Persistable pojo, CalledFrom calledFrom) {
withLogging(pojo, new Runnable() {
@Override
@@ -1336,7 +1334,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
* The implementation therefore uses Isis' {@link org.apache.isis.core.metamodel.adapter.oid.Oid#isTransient() oid}
* to determine which callback to fire.
*/
- public void preStoreProcessingFor(final Persistable pojo, final FrameworkSynchronizer.CalledFrom calledFrom) {
+ public void preStoreProcessingFor(final Persistable pojo, final CalledFrom calledFrom) {
withLogging(pojo, new Runnable() {
@Override
public void run() {
@@ -1371,7 +1369,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
* The implementation therefore uses Isis' {@link org.apache.isis.core.metamodel.adapter.oid.Oid#isTransient() oid}
* to determine which callback to fire.
*/
- public void postStoreProcessingFor(final Persistable pojo, FrameworkSynchronizer.CalledFrom calledFrom) {
+ public void postStoreProcessingFor(final Persistable pojo, CalledFrom calledFrom) {
withLogging(pojo, new Runnable() {
@Override
public void run() {
@@ -1414,7 +1412,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
}
- public void preDirtyProcessingFor(final Persistable pojo, FrameworkSynchronizer.CalledFrom calledFrom) {
+ public void preDirtyProcessingFor(final Persistable pojo, CalledFrom calledFrom) {
withLogging(pojo, new Runnable() {
@Override
public void run() {
@@ -1427,7 +1425,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
// it seems reasonable in this case to simply map into Isis here ("just-in-time"); presumably
// DN would not be calling this callback if the pojo was not persistent.
- adapter = lazilyLoaded(pojo, FrameworkSynchronizer.CalledFrom.EVENT_PREDIRTY);
+ adapter = lazilyLoaded(pojo, CalledFrom.EVENT_PREDIRTY);
if (adapter == null) {
throw new RuntimeException(
"DN could not find objectId for pojo (unexpected) and so could not map into Isis; pojo=["
@@ -1454,7 +1452,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
}, calledFrom);
}
- private <T> T withLogging(Persistable pojo, Callable<T> runnable, FrameworkSynchronizer.CalledFrom calledFrom) {
+ private <T> T withLogging(Persistable pojo, Callable<T> runnable, CalledFrom calledFrom) {
if (LOG.isDebugEnabled()) {
LOG.debug(logString(calledFrom, LoggingLocation.ENTRY, pojo));
}
@@ -1469,7 +1467,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
}
}
- private void withLogging(Persistable pojo, final Runnable runnable, FrameworkSynchronizer.CalledFrom calledFrom) {
+ private void withLogging(Persistable pojo, final Runnable runnable, CalledFrom calledFrom) {
withLogging(pojo, new Callable<Void>() {
@Override
@@ -1481,7 +1479,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
}, calledFrom);
}
- private String logString(FrameworkSynchronizer.CalledFrom calledFrom, LoggingLocation location, Persistable pojo) {
+ private String logString(CalledFrom calledFrom, LoggingLocation location, Persistable pojo) {
final ObjectAdapter adapter = getAdapterFor(pojo);
// initial spaces just to look better in log when wrapped by IsisLifecycleListener...
return calledFrom.name() + " " + location.prefix + " oid=" + (adapter !=null? adapter.getOid(): "(null)") + " ,pojo " + pojo;
@@ -1498,6 +1496,25 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
}
}
+ /**
+ * Categorises where called from.
+ *
+ * <p>
+ * Just used for logging.
+ */
+ public enum CalledFrom {
+ EVENT_LOAD,
+ EVENT_PRESTORE,
+ EVENT_POSTSTORE,
+ EVENT_PREDIRTY,
+ EVENT_POSTDIRTY,
+ OS_QUERY,
+ OS_RESOLVE,
+ OS_LAZILYLOADED,
+ EVENT_PREDELETE,
+ EVENT_POSTDELETE
+ }
+
//endregion
}
http://git-wip-us.apache.org/repos/asf/isis/blob/775871c2/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 c144e11..9e6c01c 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
@@ -28,7 +28,6 @@ import org.datanucleus.enhancement.Persistable;
import org.apache.isis.core.commons.ensure.Assert;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.runtime.system.persistence.FrameworkSynchronizer.CalledFrom;
import org.apache.isis.core.runtime.system.persistence.PersistenceQuery;
import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.objectstore.jdo.datanucleus.persistence.IsisLifecycleListener;
@@ -60,7 +59,7 @@ public abstract class PersistenceQueryProcessorAbstract<T extends PersistenceQue
ObjectAdapter adapter;
if(pojo instanceof Persistable) {
// an entity
- persistenceSession.postLoadProcessingFor((Persistable) pojo, CalledFrom.OS_QUERY);
+ persistenceSession.postLoadProcessingFor((Persistable) pojo, PersistenceSession.CalledFrom.OS_QUERY);
adapter = persistenceSession.getAdapterFor(pojo);
} else {
// a value type