You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by ah...@apache.org on 2018/09/04 20:25:54 UTC
[isis] 12/24: ISIS-1976: minor simplifications,
also reduce compiler warnings
This is an automated email from the ASF dual-hosted git repository.
ahuber pushed a commit to branch ISIS-1976-rethink-object-adapters
in repository https://gitbox.apache.org/repos/asf/isis.git
commit 5e59bd35fd62338db7926be6ceadd0e2405c174b
Author: Andi Huber <ah...@apache.org>
AuthorDate: Mon Sep 3 08:48:05 2018 +0200
ISIS-1976: minor simplifications, also reduce compiler warnings
Task-Url: https://issues.apache.org/jira/browse/ISIS-1976
---
.../runtime/system/persistence/PersistenceSession4.java | 16 +++++-----------
.../runtime/system/persistence/PersistenceSession5.java | 17 ++++++-----------
.../adaptermanager/ObjectAdapterContext.java | 7 +++++++
3 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java b/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
index 1d8cb9f..8c5c963 100644
--- a/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
+++ b/core/plugins/jdo-datanucleus-4/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession4.java
@@ -18,6 +18,7 @@
*/
package org.apache.isis.core.runtime.system.persistence;
+import static org.apache.isis.commons.internal.base._Casts.uncheckedCast;
import static org.apache.isis.commons.internal.functions._Predicates.equalTo;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
@@ -335,7 +336,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
// the guard is in case we're here as the result of a redirect following a previous exception;just ignore.
final Timestamp completedAt;
- final Interaction.Execution priorExecution = interaction.getPriorExecution();
+ final Interaction.Execution<?, ?> priorExecution = interaction.getPriorExecution();
if (priorExecution != null) {
// copy over from the most recent (which will be the top-level) interaction
completedAt = priorExecution.getCompletedAt();
@@ -585,6 +586,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
// -- helper: postEvent
+ @SuppressWarnings({ "unchecked", "rawtypes" })
void postLifecycleEventIfRequired(
final ObjectAdapter adapter,
final Class<? extends LifecycleEventFacet> lifecycleEventFacetClass) {
@@ -786,7 +788,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
fetchPlan.addGroup(FetchGroup.DEFAULT);
final List<Object> persistentPojos = Lists.newArrayList();
try {
- final Collection<Object> pojos = persistenceManager.getObjectsById(dnOids, true);
+ final Collection<Object> pojos = uncheckedCast(persistenceManager.getObjectsById(dnOids, true));
for (final Object pojo : pojos) {
try {
persistentPojos.add(pojo);
@@ -1542,18 +1544,10 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
@Override
public void removeAdapterFromCache(final ObjectAdapter adapter) {
ensureMapsConsistent(adapter);
-
- LOG.debug("removing adapter: {}", adapter);
-
- unmap(adapter);
- }
-
- private void unmap(final ObjectAdapter adapter) {
- ensureMapsConsistent(adapter);
-
objectAdapterContext.removeAdapter(adapter);
}
+
/**
* @deprecated https://issues.apache.org/jira/browse/ISIS-1976
*/
diff --git a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
index 8e7653f..9cd52e6 100644
--- a/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
+++ b/core/plugins/jdo-datanucleus-5/src/main/java/org/apache/isis/core/runtime/system/persistence/PersistenceSession5.java
@@ -18,6 +18,7 @@
*/
package org.apache.isis.core.runtime.system.persistence;
+import static org.apache.isis.commons.internal.base._Casts.uncheckedCast;
import static org.apache.isis.commons.internal.functions._Predicates.equalTo;
import static org.apache.isis.core.commons.ensure.Ensure.ensureThatArg;
@@ -55,6 +56,7 @@ import org.apache.isis.applib.services.bookmark.BookmarkService;
import org.apache.isis.applib.services.command.Command;
import org.apache.isis.applib.services.exceprecog.ExceptionRecognizer;
import org.apache.isis.applib.services.iactn.Interaction;
+import org.apache.isis.commons.internal.base._Casts;
import org.apache.isis.commons.internal.collections._Lists;
import org.apache.isis.commons.internal.collections._Maps;
import org.apache.isis.core.commons.authentication.AuthenticationSession;
@@ -333,7 +335,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
// the guard is in case we're here as the result of a redirect following a previous exception;just ignore.
final Timestamp completedAt;
- final Interaction.Execution priorExecution = interaction.getPriorExecution();
+ final Interaction.Execution<?, ?> priorExecution = interaction.getPriorExecution();
if (priorExecution != null) {
// copy over from the most recent (which will be the top-level) interaction
completedAt = priorExecution.getCompletedAt();
@@ -583,6 +585,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
// -- helper: postEvent
+ @SuppressWarnings({ "unchecked", "rawtypes" })
void postLifecycleEventIfRequired(
final ObjectAdapter adapter,
final Class<? extends LifecycleEventFacet> lifecycleEventFacetClass) {
@@ -784,7 +787,7 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
fetchPlan.addGroup(FetchGroup.DEFAULT);
final List<Object> persistentPojos = Lists.newArrayList();
try {
- final Collection<Object> pojos = persistenceManager.getObjectsById(dnOids, true);
+ final Collection<Object> pojos = uncheckedCast(persistenceManager.getObjectsById(dnOids, true));
for (final Object pojo : pojos) {
try {
persistentPojos.add(pojo);
@@ -1537,18 +1540,10 @@ implements IsisLifecycleListener.PersistenceSessionLifecycleManagement {
@Override
public void removeAdapterFromCache(final ObjectAdapter adapter) {
ensureMapsConsistent(adapter);
-
- LOG.debug("removing adapter: {}", adapter);
-
- unmap(adapter);
- }
-
- private void unmap(final ObjectAdapter adapter) {
- ensureMapsConsistent(adapter);
-
objectAdapterContext.removeAdapter(adapter);
}
+
/**
* @deprecated https://issues.apache.org/jira/browse/ISIS-1976
*/
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext.java
index ef6314c..7d9c90d 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/system/persistence/adaptermanager/ObjectAdapterContext.java
@@ -18,6 +18,9 @@
*/
package org.apache.isis.core.runtime.system.persistence.adaptermanager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.commons.ensure.IsisAssertException;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
@@ -39,6 +42,9 @@ import org.apache.isis.core.runtime.system.persistence.PersistenceSession;
* @since 2.0.0-M2
*/
public class ObjectAdapterContext {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ObjectAdapterContext.class);
+
private final PojoAdapterHashMap pojoAdapterMap = new PojoAdapterHashMap();
private final OidAdapterHashMap oidAdapterMap = new OidAdapterHashMap();
private final ServicesInjector servicesInjector;
@@ -110,6 +116,7 @@ public class ObjectAdapterContext {
@Deprecated // don't expose caching
public void removeAdapter(ObjectAdapter adapter) {
+ LOG.debug("removing adapter: {}", adapter);
if(adapter==null) {
return; // nothing to do
}