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/10/24 12:47:44 UTC
isis git commit: ISIS-830: introduced new ObjectXxxEvent into applib,
also AbstractLifecycleEvent superclass,
updated PersistenceSession to call these events.
Repository: isis
Updated Branches:
refs/heads/master b118fffb0 -> e5a1faa8e
ISIS-830: introduced new ObjectXxxEvent into applib, also AbstractLifecycleEvent superclass, updated PersistenceSession to call these events.
also:
- fixed toString for AbstractDomainEvent
- factored out internal interfaces for the interactions between:
- PersistenceSession and IsisLifecycleListener2
- PersistenceSession and IsisTransactionManager
- PersistenceSession and PersistenceQueryProcessorAbstract implementations
Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/e5a1faa8
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/e5a1faa8
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/e5a1faa8
Branch: refs/heads/master
Commit: e5a1faa8e07c6f617223811b9490f0074b4825fa
Parents: b118fff
Author: Dan Haywood <da...@haywood-associates.co.uk>
Authored: Sat Oct 24 11:47:32 2015 +0100
Committer: Dan Haywood <da...@haywood-associates.co.uk>
Committed: Sat Oct 24 11:47:32 2015 +0100
----------------------------------------------------------------------
.../services/eventbus/AbstractDomainEvent.java | 2 +-
.../eventbus/AbstractLifecycleEvent.java | 37 ++++++++++++
.../services/eventbus/ObjectCreatedEvent.java | 29 ++++++++++
.../services/eventbus/ObjectLoadedEvent.java | 29 ++++++++++
.../services/eventbus/ObjectPersistedEvent.java | 29 ++++++++++
.../eventbus/ObjectPersistingEvent.java | 29 ++++++++++
.../services/eventbus/ObjectRemovingEvent.java | 29 ++++++++++
.../services/eventbus/ObjectUpdatedEvent.java | 29 ++++++++++
.../services/eventbus/ObjectUpdatingEvent.java | 29 ++++++++++
.../metamodel/adapter/mgr/AdapterManager.java | 19 +------
.../adapter/mgr/AdapterManagerBase.java | 47 ++++++++++++++++
.../persistence/IsisLifecycleListener2.java | 22 +++++++-
.../system/persistence/PersistenceSession.java | 59 ++++++++++++++++----
.../system/transaction/IsisTransaction.java | 11 ++--
.../transaction/IsisTransactionManager.java | 27 +++++++--
.../persistence/IsisLifecycleListener.java | 1 +
...rsistenceQueryFindAllInstancesProcessor.java | 3 +-
...tenceQueryFindUsingApplibQueryProcessor.java | 4 +-
.../PersistenceQueryProcessorAbstract.java | 23 +++++---
19 files changed, 403 insertions(+), 55 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractDomainEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractDomainEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractDomainEvent.java
index cab9149..aa81a4b 100644
--- a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractDomainEvent.java
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractDomainEvent.java
@@ -299,7 +299,7 @@ public abstract class AbstractDomainEvent<S> extends java.util.EventObject {
//region > toString
@Override
public String toString() {
- return ObjectContracts.toString(this, "source,identifier,mode");
+ return ObjectContracts.toString(this, "source","identifier","eventPhase");
}
//endregion
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractLifecycleEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractLifecycleEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractLifecycleEvent.java
new file mode 100644
index 0000000..bd3dbe5
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/AbstractLifecycleEvent.java
@@ -0,0 +1,37 @@
+/*
+ * 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.applib.services.eventbus;
+
+import java.util.EventObject;
+
+import org.apache.isis.applib.util.ObjectContracts;
+
+public abstract class AbstractLifecycleEvent<S> extends EventObject {
+
+ private static final long serialVersionUID = 1L;
+
+ public AbstractLifecycleEvent(final S source) {
+ super(source);
+ }
+
+ @Override
+ public String toString() {
+ return ObjectContracts.toString(this, "source");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectCreatedEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectCreatedEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectCreatedEvent.java
new file mode 100644
index 0000000..7742c40
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectCreatedEvent.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.applib.services.eventbus;
+
+public class ObjectCreatedEvent<S> extends AbstractLifecycleEvent<S> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ObjectCreatedEvent(final S source) {
+ super(source);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectLoadedEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectLoadedEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectLoadedEvent.java
new file mode 100644
index 0000000..507b42c
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectLoadedEvent.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.applib.services.eventbus;
+
+public class ObjectLoadedEvent<S> extends AbstractLifecycleEvent<S> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ObjectLoadedEvent(final S source) {
+ super(source);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectPersistedEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectPersistedEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectPersistedEvent.java
new file mode 100644
index 0000000..2b50fb8
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectPersistedEvent.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.applib.services.eventbus;
+
+public class ObjectPersistedEvent<S> extends AbstractLifecycleEvent<S> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ObjectPersistedEvent(final S source) {
+ super(source);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectPersistingEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectPersistingEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectPersistingEvent.java
new file mode 100644
index 0000000..d0a936f
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectPersistingEvent.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.applib.services.eventbus;
+
+public class ObjectPersistingEvent<S> extends AbstractLifecycleEvent<S> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ObjectPersistingEvent(final S source) {
+ super(source);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectRemovingEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectRemovingEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectRemovingEvent.java
new file mode 100644
index 0000000..44cf62f
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectRemovingEvent.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.applib.services.eventbus;
+
+public class ObjectRemovingEvent<S> extends AbstractLifecycleEvent<S> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ObjectRemovingEvent(final S source) {
+ super(source);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectUpdatedEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectUpdatedEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectUpdatedEvent.java
new file mode 100644
index 0000000..f5bd631
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectUpdatedEvent.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.applib.services.eventbus;
+
+public class ObjectUpdatedEvent<S> extends AbstractLifecycleEvent<S> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ObjectUpdatedEvent(final S source) {
+ super(source);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectUpdatingEvent.java
----------------------------------------------------------------------
diff --git a/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectUpdatingEvent.java b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectUpdatingEvent.java
new file mode 100644
index 0000000..ed03930
--- /dev/null
+++ b/core/applib/src/main/java/org/apache/isis/applib/services/eventbus/ObjectUpdatingEvent.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.applib.services.eventbus;
+
+public class ObjectUpdatingEvent<S> extends AbstractLifecycleEvent<S> {
+
+ private static final long serialVersionUID = 1L;
+
+ public ObjectUpdatingEvent(final S source) {
+ super(source);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManager.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManager.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManager.java
index 4a66f50..ec2aaeb 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManager.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManager.java
@@ -26,7 +26,7 @@ import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.adapter.oid.Oid;
import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
-public interface AdapterManager {
+public interface AdapterManager extends AdapterManagerBase {
/**
* Gets the {@link ObjectAdapter adapter} for the {@link Oid} if it exists
@@ -38,18 +38,6 @@ public interface AdapterManager {
*/
ObjectAdapter getAdapterFor(Oid oid);
- /**
- * Gets the {@link ObjectAdapter adapter} for the specified domain object if
- * it exists in the identity map.
- *
- * <p>
- * Provided by the <tt>AdapterManager</tt> when used by framework.
- *
- * @param pojo
- * - must not be <tt>null</tt>
- * @return adapter, or <tt>null</tt> if doesn't exist.
- */
- ObjectAdapter getAdapterFor(Object pojo);
public enum ConcurrencyChecking {
@@ -122,11 +110,6 @@ public interface AdapterManager {
/**
- * Looks up or creates a standalone (value) or root adapter.
- */
- ObjectAdapter adapterFor(Object domainObject);
-
- /**
* Looks up or creates a collection adapter.
*/
public ObjectAdapter adapterFor(
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManagerBase.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManagerBase.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManagerBase.java
new file mode 100644
index 0000000..9dc900a
--- /dev/null
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/adapter/mgr/AdapterManagerBase.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.core.metamodel.adapter.mgr;
+
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+
+public interface AdapterManagerBase {
+
+ /**
+ * Gets the {@link ObjectAdapter adapter} for the specified domain object if
+ * it exists in the identity map.
+ *
+ * <p>
+ * Provided by the <tt>AdapterManager</tt> when used by framework.
+ *
+ * @param pojo
+ * - must not be <tt>null</tt>
+ * @return adapter, or <tt>null</tt> if doesn't exist.
+ */
+ ObjectAdapter getAdapterFor(Object pojo);
+
+
+
+ /**
+ * Looks up or creates a standalone (value) or root adapter.
+ */
+ ObjectAdapter adapterFor(Object domainObject);
+
+
+}
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/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 42cb9ff..2ee44dd 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,16 +35,30 @@ import com.google.common.collect.Maps;
import org.datanucleus.enhancement.Persistable;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManagerBase;
public class IsisLifecycleListener2
implements AttachLifecycleListener, ClearLifecycleListener, CreateLifecycleListener, DeleteLifecycleListener,
DetachLifecycleListener, DirtyLifecycleListener, LoadLifecycleListener, StoreLifecycleListener,
SuspendableListener {
- private final PersistenceSession persistenceSession;
+ /**
+ * The internal contract between PersistenceSession and this class.
+ */
+ interface PersistenceSessionLifecycleManagement extends AdapterManagerBase {
+
+ void ensureRootObject(Persistable pojo);
+ void initializeMapAndCheckConcurrency(Persistable pojo);
+
+ void enlistCreatedAndRemapIfRequiredThenInvokeIsisInvokePersistingOrUpdatedCallback(Persistable pojo);
+ void invokeIsisPersistingCallback(Persistable pojo);
+ void enlistUpdatingAndInvokeIsisUpdatingCallback(Persistable pojo);
+ void enlistDeletingAndInvokeIsisRemovingCallbackFacet(Persistable pojo);
+ }
+
+ private final PersistenceSessionLifecycleManagement persistenceSession;
- public IsisLifecycleListener2(
- final PersistenceSession persistenceSession) {
+ public IsisLifecycleListener2(final PersistenceSessionLifecycleManagement persistenceSession) {
this.persistenceSession = persistenceSession;
}
@@ -109,6 +123,8 @@ public class IsisLifecycleListener2
public void preDelete(InstanceLifecycleEvent event) {
final Persistable pojo = Utils.persistenceCapableFor(event);
persistenceSession.enlistDeletingAndInvokeIsisRemovingCallbackFacet(pojo);
+
+
}
@Override
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/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 598ade2..418d0c5 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
@@ -41,6 +41,15 @@ import org.apache.isis.applib.RecoverableException;
import org.apache.isis.applib.profiles.Localization;
import org.apache.isis.applib.query.Query;
import org.apache.isis.applib.services.bookmark.Bookmark;
+import org.apache.isis.applib.services.eventbus.AbstractLifecycleEvent;
+import org.apache.isis.applib.services.eventbus.EventBusService;
+import org.apache.isis.applib.services.eventbus.ObjectCreatedEvent;
+import org.apache.isis.applib.services.eventbus.ObjectLoadedEvent;
+import org.apache.isis.applib.services.eventbus.ObjectPersistedEvent;
+import org.apache.isis.applib.services.eventbus.ObjectPersistingEvent;
+import org.apache.isis.applib.services.eventbus.ObjectRemovingEvent;
+import org.apache.isis.applib.services.eventbus.ObjectUpdatedEvent;
+import org.apache.isis.applib.services.eventbus.ObjectUpdatingEvent;
import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer;
import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer2;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
@@ -122,6 +131,7 @@ import org.apache.isis.objectstore.jdo.datanucleus.persistence.commands.DataNucl
import org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindAllInstancesProcessor;
import org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryFindUsingApplibQueryProcessor;
import org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryProcessor;
+import org.apache.isis.objectstore.jdo.datanucleus.persistence.queries.PersistenceQueryProcessorAbstract;
import org.apache.isis.objectstore.jdo.datanucleus.persistence.spi.JdoObjectIdSerializer;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
@@ -137,8 +147,17 @@ import static org.hamcrest.CoreMatchers.nullValue;
* and maintains an identity map of {@link ObjectAdapter adapter}s and {@link Oid
* identities} for each and every POJO that is being used by the framework.
*/
-public class PersistenceSession implements TransactionalResource, SessionScopedComponent, DebuggableWithTitle, AdapterManager,
- MessageBrokerService, PersistenceSessionService, ConfigurationService {
+public class PersistenceSession implements
+ TransactionalResource,
+ SessionScopedComponent,
+ DebuggableWithTitle,
+ AdapterManager,
+ MessageBrokerService,
+ PersistenceSessionService,
+ ConfigurationService,
+ IsisLifecycleListener2.PersistenceSessionLifecycleManagement,
+ IsisTransactionManager.PersistenceSessionTransactionManagement,
+ PersistenceQueryProcessorAbstract.PersistenceSessionQueryProcessorManagement {
private static final Logger LOG = LoggerFactory.getLogger(PersistenceSession.class);
@@ -216,8 +235,10 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
this.jdoPersistenceManagerFactory = jdoPersistenceManagerFactory;
// sub-components
- this.persistenceQueryFactory = new PersistenceQueryFactory(this, this.specificationLoader);
- this.transactionManager = new IsisTransactionManager(this, this.servicesInjector);
+ final AdapterManager adapterManager = this;
+ this.persistenceQueryFactory = new PersistenceQueryFactory(adapterManager, specificationLoader);
+ final IsisTransactionManager.PersistenceSessionTransactionManagement psTranManagement = this;
+ this.transactionManager = new IsisTransactionManager(psTranManagement, servicesInjector);
setState(State.NOT_INITIALIZED);
@@ -260,15 +281,17 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
persistenceManager = jdoPersistenceManagerFactory.getPersistenceManager();
- final IsisLifecycleListener2 isisLifecycleListener = new IsisLifecycleListener2(this);
+ final IsisLifecycleListener2.PersistenceSessionLifecycleManagement psLifecycleMgmt = this;
+ final IsisLifecycleListener2 isisLifecycleListener = new IsisLifecycleListener2(psLifecycleMgmt);
persistenceManager.addInstanceLifecycleListener(isisLifecycleListener, (Class[]) null);
+ final PersistenceQueryProcessorAbstract.PersistenceSessionQueryProcessorManagement psQueryProcessorMgmt = this;
persistenceQueryProcessorByClass.put(
PersistenceQueryFindAllInstances.class,
- new PersistenceQueryFindAllInstancesProcessor(this));
+ new PersistenceQueryFindAllInstancesProcessor(psQueryProcessorMgmt));
persistenceQueryProcessorByClass.put(
PersistenceQueryFindUsingApplibQueryDefault.class,
- new PersistenceQueryFindUsingApplibQueryProcessor(this));
+ new PersistenceQueryFindUsingApplibQueryProcessor(psQueryProcessorMgmt));
initServices();
@@ -605,9 +628,11 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
for (ObjectAssociation field : fields) {
field.toDefault(adapter);
}
- servicesInjector.injectServicesInto(adapter.getObject());
+ final Object pojo = adapter.getObject();
+ servicesInjector.injectServicesInto(pojo);
CallbackFacet.Util.callCallback(adapter, CreatedCallbackFacet.class);
+ postEvent(new ObjectCreatedEvent<>(pojo));
return adapter;
}
@@ -617,7 +642,6 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
//region > getServices, getService
- // REVIEW why does this get called multiple times when starting up
public List<ObjectAdapter> getServices() {
final List<Object> services = servicesInjector.getRegisteredServices();
final List<ObjectAdapter> serviceAdapters = Lists.newArrayList();
@@ -649,6 +673,15 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
//endregion
+ //region > helper: postEvent
+ void postEvent(final AbstractLifecycleEvent<?> event) {
+ final EventBusService eventBusService = getServicesInjector().lookupService(EventBusService.class);
+ eventBusService.post(event);
+ }
+ //endregion
+
+
+
//region > fixture installation
/**
@@ -1945,8 +1978,10 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
transaction.enlistDeleting(adapter);
CallbackFacet.Util.callCallback(adapter, RemovingCallbackFacet.class);
+ postEvent(new ObjectRemovingEvent<>(pojo));
}
+
public void initializeMapAndCheckConcurrency(final Persistable pojo) {
final Persistable pc = pojo;
@@ -2000,6 +2035,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
} else {
adapter = mapRecreatedPojo(originalOid, pojo);
CallbackFacet.Util.callCallback(adapter, LoadedCallbackFacet.class);
+ postEvent(new ObjectLoadedEvent<>(pojo));
}
}
@@ -2095,6 +2131,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
// persisting
// previously this was performed in the DataNucleusSimplePersistAlgorithm.
CallbackFacet.Util.callCallback(adapter, PersistingCallbackFacet.class);
+ postEvent(new ObjectPersistingEvent<>(pojo));
} else {
// updating
@@ -2125,6 +2162,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
remapAsPersistent(adapter, persistentOid);
CallbackFacet.Util.callCallback(adapter, PersistedCallbackFacet.class);
+ postEvent(new ObjectPersistedEvent<>(pojo));
final IsisTransaction transaction = getCurrentTransaction();
transaction.enlistCreated(adapter);
@@ -2134,13 +2172,13 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
// the callback and transaction.enlist are done in the preDirty callback
// (can't be done here, as the enlist requires to capture the 'before' values)
CallbackFacet.Util.callCallback(adapter, UpdatedCallbackFacet.class);
+ postEvent(new ObjectUpdatedEvent<>(pojo));
}
Version versionIfAny = getVersionIfAny(pojo);
adapter.setVersion(versionIfAny);
}
-
public void enlistUpdatingAndInvokeIsisUpdatingCallback(final Persistable pojo) {
ObjectAdapter adapter = getAdapterFor(pojo);
if (adapter == null) {
@@ -2169,6 +2207,7 @@ public class PersistenceSession implements TransactionalResource, SessionScopedC
}
CallbackFacet.Util.callCallback(adapter, UpdatingCallbackFacet.class);
+ postEvent(new ObjectUpdatingEvent<>(pojo));
getCurrentTransaction().enlistUpdating(adapter);
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
index 01b1253..028c186 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransaction.java
@@ -95,7 +95,6 @@ import org.apache.isis.core.runtime.persistence.objectstore.transaction.DestroyO
import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.PublishingServiceWithDefaultPayloadFactories;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatState;
@@ -233,7 +232,7 @@ public class IsisTransaction implements TransactionScopedComponent {
private static final Logger LOG = LoggerFactory.getLogger(IsisTransaction.class);
- private final PersistenceSession persistenceSession;
+ private final IsisTransactionManager.PersistenceSessionTransactionManagement persistenceSession;
private final List<PersistenceCommand> persistenceCommands = Lists.newArrayList();
private final IsisTransactionManager transactionManager;
private final MessageBroker messageBroker;
@@ -272,7 +271,7 @@ public class IsisTransaction implements TransactionScopedComponent {
public IsisTransaction(
final IsisTransactionManager transactionManager,
final MessageBroker messageBroker,
- final PersistenceSession persistenceSession,
+ final IsisTransactionManager.PersistenceSessionTransactionManagement persistenceSession,
final ServicesInjector servicesInjector) {
ensureThatArg(transactionManager, is(not(nullValue())), "transaction manager is required");
@@ -1411,14 +1410,14 @@ public class IsisTransaction implements TransactionScopedComponent {
////////////////////////////////////////////////////////////////////////
protected OidMarshaller getOidMarshaller() {
- return persistenceSession.getOidMarshaller();
+ return IsisContext.getOidMarshaller();
}
protected IsisConfiguration getConfiguration() {
- return persistenceSession.getConfiguration();
+ return IsisContext.getConfiguration();
}
- protected PersistenceSession getPersistenceSession() {
+ protected IsisTransactionManager.PersistenceSessionTransactionManagement getPersistenceSession() {
return persistenceSession;
}
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
index b0ef78f..677393d 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionManager.java
@@ -36,12 +36,13 @@ import org.apache.isis.core.commons.authentication.MessageBroker;
import org.apache.isis.core.commons.components.SessionScopedComponent;
import org.apache.isis.core.commons.debug.DebugBuilder;
import org.apache.isis.core.commons.exceptions.IsisException;
+import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.adapter.mgr.AdapterManagerBase;
import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
import org.apache.isis.core.runtime.services.RequestScopedService;
import org.apache.isis.core.runtime.system.context.IsisContext;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.core.runtime.system.session.IsisSession;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
@@ -55,7 +56,7 @@ public class IsisTransactionManager implements SessionScopedComponent {
private static final Logger LOG = LoggerFactory.getLogger(IsisTransactionManager.class);
- private final PersistenceSession persistenceSession;
+ private final PersistenceSessionTransactionManagement persistenceSession;
private int transactionLevel;
@@ -73,14 +74,28 @@ public class IsisTransactionManager implements SessionScopedComponent {
// constructor
// ////////////////////////////////////////////////////////////////
+ /**
+ * The internal contract between PersistenceSession and this class.
+ */
+ public interface PersistenceSessionTransactionManagement extends AdapterManagerBase {
+
+ void startTransaction();
+ void endTransaction();
+ void abortTransaction();
+
+ void execute(List<PersistenceCommand> persistenceCommandList);
+
+ ObjectAdapter adapterFor(Object object);
+ }
+
public IsisTransactionManager(
- final PersistenceSession persistenceSession,
+ final PersistenceSessionTransactionManagement persistenceSession,
final ServicesInjector servicesInjector) {
this.persistenceSession = persistenceSession;
this.servicesInjector = servicesInjector;
}
- public PersistenceSession getPersistenceSession() {
+ public PersistenceSessionTransactionManagement getPersistenceSession() {
return persistenceSession;
}
@@ -241,7 +256,7 @@ public class IsisTransactionManager implements SessionScopedComponent {
*/
private IsisTransaction createTransaction(
final MessageBroker messageBroker,
- final PersistenceSession persistenceSession) {
+ final PersistenceSessionTransactionManagement persistenceSession) {
ensureThatArg(messageBroker, is(not(nullValue())));
return new IsisTransaction(this, messageBroker, persistenceSession, servicesInjector);
@@ -538,7 +553,7 @@ public class IsisTransactionManager implements SessionScopedComponent {
/**
* Overridable hook, used in
- * {@link #createTransaction(org.apache.isis.core.commons.authentication.MessageBroker, PersistenceSession)}
+ * {@link #createTransaction(MessageBroker, PersistenceSessionTransactionManagement)}
*
* <p> Called when a new {@link IsisTransaction} is created.
*/
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/IsisLifecycleListener.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/IsisLifecycleListener.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/IsisLifecycleListener.java
index 3d71527..47fd736 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/IsisLifecycleListener.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/IsisLifecycleListener.java
@@ -34,5 +34,6 @@ public class IsisLifecycleListener extends IsisLifecycleListener2 {
public IsisLifecycleListener(final PersistenceSession persistenceSession) {
super(persistenceSession);
+ throw new RuntimeException("Use IsisLifecycleListener2 instead");
}
}
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java
index c9830e6..122d59d 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindAllInstancesProcessor.java
@@ -28,13 +28,12 @@ import org.slf4j.LoggerFactory;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.spec.ObjectSpecification;
import org.apache.isis.core.runtime.persistence.query.PersistenceQueryFindAllInstances;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
public class PersistenceQueryFindAllInstancesProcessor extends PersistenceQueryProcessorAbstract<PersistenceQueryFindAllInstances> {
private static final Logger LOG = LoggerFactory.getLogger(PersistenceQueryFindAllInstancesProcessor.class);
- public PersistenceQueryFindAllInstancesProcessor(final PersistenceSession persistenceSession) {
+ public PersistenceQueryFindAllInstancesProcessor(final PersistenceSessionQueryProcessorManagement persistenceSession) {
super(persistenceSession);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
index d5a65b7..0181331 100644
--- a/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
+++ b/core/runtime/src/main/java/org/apache/isis/objectstore/jdo/datanucleus/persistence/queries/PersistenceQueryFindUsingApplibQueryProcessor.java
@@ -35,14 +35,14 @@ 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.OneToOneAssociation;
import org.apache.isis.core.runtime.persistence.query.PersistenceQueryFindUsingApplibQueryDefault;
-import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
import org.apache.isis.objectstore.jdo.datanucleus.metamodel.JdoPropertyUtils;
public class PersistenceQueryFindUsingApplibQueryProcessor extends PersistenceQueryProcessorAbstract<PersistenceQueryFindUsingApplibQueryDefault> {
private static final Logger LOG = LoggerFactory.getLogger(PersistenceQueryFindUsingApplibQueryProcessor.class);
- public PersistenceQueryFindUsingApplibQueryProcessor(final PersistenceSession persistenceSession) {
+ public PersistenceQueryFindUsingApplibQueryProcessor(
+ final PersistenceSessionQueryProcessorManagement persistenceSession) {
super(persistenceSession);
}
http://git-wip-us.apache.org/repos/asf/isis/blob/e5a1faa8/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 434acc5..80a85fc 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
@@ -20,6 +20,7 @@ package org.apache.isis.objectstore.jdo.datanucleus.persistence.queries;
import java.util.List;
+import javax.jdo.Query;
import javax.jdo.listener.InstanceLifecycleEvent;
import com.google.common.collect.Lists;
@@ -28,23 +29,31 @@ 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.metamodel.adapter.mgr.AdapterManagerBase;
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;
public abstract class PersistenceQueryProcessorAbstract<T extends PersistenceQuery>
implements PersistenceQueryProcessor<T> {
- final PersistenceSession persistenceSession;
+ /**
+ * The internal contract between PersistenceSession and this class.
+ */
+ public interface PersistenceSessionQueryProcessorManagement extends AdapterManagerBase {
+ void initializeMapAndCheckConcurrency(Persistable pojo);
- protected PersistenceQueryProcessorAbstract(final PersistenceSession persistenceSession) {
- this.persistenceSession = persistenceSession;
+ Query newJdoQuery(Class<?> cls);
+ Query newJdoQuery(Class<?> cls, String filter);
+ Query newJdoNamedQuery(Class<?> cls, String queryName);
}
- // /////////////////////////////////////////////////////////////
- // helpers for subclasses
- // /////////////////////////////////////////////////////////////
+ final PersistenceSessionQueryProcessorManagement persistenceSession;
+
+ protected PersistenceQueryProcessorAbstract(final PersistenceSessionQueryProcessorManagement persistenceSession) {
+ this.persistenceSession = persistenceSession;
+ }
+
/**
* Traversing the provided list causes (or should cause) the