You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by jc...@apache.org on 2014/04/03 12:38:19 UTC

[1/2] git commit: ISIS-760: refactor where Commands get persisted.

Repository: isis
Updated Branches:
  refs/heads/master 96f68770a -> 0fc370906
Updated Tags:  refs/tags/upstream/upstream/upstream/upstream/isis-0.1.2-incubating [created] 40c529018
  refs/tags/upstream/upstream/upstream/upstream/isis-0.2.0-incubating [created] 6dce716dd
  refs/tags/upstream/upstream/upstream/upstream/isis-1.0.0 [created] 53dddebcb
  refs/tags/upstream/upstream/upstream/upstream/isis-1.1.0 [created] 4859004d0
  refs/tags/upstream/upstream/upstream/upstream/isis-1.2.0 [created] 2241234dc
  refs/tags/upstream/upstream/upstream/upstream/isis-1.3.0 [created] 6141fb2f0
  refs/tags/upstream/upstream/upstream/upstream/isis-1.4.0 [created] c63925627
  refs/tags/upstream/upstream/upstream/upstream/isis-objectstore-jdo-1.0.0 [created] 423f7a110
  refs/tags/upstream/upstream/upstream/upstream/isis-objectstore-jdo-1.1.0 [created] 468d6f4ea
  refs/tags/upstream/upstream/upstream/upstream/isis-objectstore-jdo-1.3.0 [created] f5ff029aa
  refs/tags/upstream/upstream/upstream/upstream/isis-objectstore-jdo-1.4.0 [created] cc63fc46e
  refs/tags/upstream/upstream/upstream/upstream/isis-objectstore-jdo-1.4.1 [created] a92eeb98f
  refs/tags/upstream/upstream/upstream/upstream/isis-security-file-1.0.0 [created] b71ec3d05
  refs/tags/upstream/upstream/upstream/upstream/isis-security-file-1.0.1 [created] a2ee46dfb
  refs/tags/upstream/upstream/upstream/upstream/isis-security-file-1.4.0 [created] 91a8180ed
  refs/tags/upstream/upstream/upstream/upstream/isis-security-shiro-1.0.0 [created] d7afb7606
  refs/tags/upstream/upstream/upstream/upstream/isis-security-shiro-1.1.0 [created] 340f5709d
  refs/tags/upstream/upstream/upstream/upstream/isis-security-shiro-1.1.1 [created] 47dd14d9e
  refs/tags/upstream/upstream/upstream/upstream/isis-security-shiro-1.3.0 [created] ed21e0bc0
  refs/tags/upstream/upstream/upstream/upstream/isis-security-shiro-1.4.0 [created] ebfe33e2e
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-restfulobjects-1.0.0 [created] e21e1f19f
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-restfulobjects-2.0.0 [created] 61e41dac2
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-restfulobjects-2.1.0 [created] f09479a9d
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-restfulobjects-2.2.0 [created] dc1925cfe
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-wicket-1.0.0 [created] f12423d73
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-wicket-1.1.0 [created] e11c74411
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-wicket-1.2.0 [created] 5142ba9c2
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-wicket-1.3.0 [created] f16b2db6c
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-wicket-1.4.0 [created] 4b0985f7f
  refs/tags/upstream/upstream/upstream/upstream/isis-viewer-wicket-1.4.1 [created] cff8b21dc
  refs/tags/upstream/upstream/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.0.0 [created] cdb171f80
  refs/tags/upstream/upstream/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.0.1 [created] 86878f4c3
  refs/tags/upstream/upstream/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.0.2 [created] 87c2b682c
  refs/tags/upstream/upstream/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.0.3 [created] d13fdbf56
  refs/tags/upstream/upstream/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.3.0 [created] 34209efc7
  refs/tags/upstream/upstream/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.4.0 [created] 9de1db090
  refs/tags/upstream/upstream/upstream/upstream/quickstart_wicket_restful_jdo-archetype-1.4.1 [created] e5095a389
  refs/tags/upstream/upstream/upstream/upstream/simple_wicket_restful_jdo-archetype-1.3.0 [created] d33a79a75
  refs/tags/upstream/upstream/upstream/upstream/simple_wicket_restful_jdo-archetype-1.4.0 [created] 5b167f098
  refs/tags/upstream/upstream/upstream/upstream/simple_wicket_restful_jdo-archetype-1.4.1 [created] cff221ec1


ISIS-760: refactor where Commands get persisted.

previously was in the closing of the PersistenceSession.  Are now within the IsisTransaction.commit() functionality.  This means that the usual error recovery processing can be used if (as there currently is with CommandService) there happens to be a defect in the implementation of one of these services.

In detail:
- PersistenceSession no longer calls closeServices() in its own close() method.  Instead, this functionality has been moved to IsisTransaction.
- IsisTransaction#commit now does the closeServices (to persist the command) instead.
- IsisTransaction now looks up the services from ServicesInjector, rather than have them handed to it by IsisTransactionManager.
- CommandServiceJdo#complete now has a guard to only attempt the complete (ie persist the CommandJdo object) if not previously done.
  This guard is required because - if there was an exception - then Wicket will restart the interaction on the same thread (but a new xactn) in order to render the error page and if the command is still present then (without the guard) Isis was trying to commit once more (ie an infinite loop)


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/c957bdc4
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/c957bdc4
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/c957bdc4

Branch: refs/heads/master
Commit: c957bdc44a2800c8178709c7095c8af88743c82b
Parents: 96f6877
Author: Jeroen van der Wal <je...@stromboli.it>
Authored: Thu Apr 3 12:05:10 2014 +0200
Committer: Jeroen van der Wal <je...@stromboli.it>
Committed: Thu Apr 3 12:34:25 2014 +0200

----------------------------------------------------------------------
 .../service/command/CommandServiceJdo.java      |   6 +
 .../system/persistence/PersistenceSession.java  |  36 +-----
 .../system/transaction/IsisTransaction.java     | 127 ++++++++++++++++++-
 .../transaction/IsisTransactionManager.java     |  80 +-----------
 .../PersistenceSessionObjectStoreTest.java      |   9 ++
 ...reTransactionManager_EndTransactionTest.java |   4 +-
 .../system/transaction/IsisTransactionTest.java |  81 +++++++++++-
 7 files changed, 226 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/c957bdc4/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java
index 53f98eb..96a6016 100644
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/command/CommandServiceJdo.java
@@ -72,6 +72,12 @@ public class CommandServiceJdo extends AbstractService implements CommandService
         if(commandJdo == null) {
             return;
         }
+        if(commandJdo.getCompletedAt() != null) {
+            // already attempted to complete.
+            // chances are, we're here as the result of a redirect following a previous exception
+            // so just ignore.
+            return;
+        }
             
         commandJdo.setCompletedAt(Clock.getTimeAsJavaSqlTimestamp());
         persistIfNotAlready(commandJdo);

http://git-wip-us.apache.org/repos/asf/isis/blob/c957bdc4/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 8e8f9f3..3d81609 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
@@ -368,9 +368,7 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
         if (LOG.isDebugEnabled()) {
             LOG.debug("closing " + this);
         }
-
-        closeServices();
-
+        
         try {
             objectStore.close();
         } catch(RuntimeException ex) {
@@ -389,39 +387,11 @@ public class PersistenceSession implements Persistor, EnlistedObjectDirtying, To
             // ignore
         }
 
-        setState(State.CLOSED);
-    }
-
-    private void closeServices() {
-
-        closeOtherApplibServicesIfConfigured();
-
-        completeCommandIfConfigured();
-
         endRequestOnRequestScopeServices();
+        
+        setState(State.CLOSED);
     }
 
-    private void closeOtherApplibServicesIfConfigured() {
-        Bulk.InteractionContext bic = getServiceOrNull(Bulk.InteractionContext.class);
-        if(bic != null) {
-            Bulk.InteractionContext.current.set(null);
-        }
-        EventBusServiceDefault ebs = getServiceOrNull(EventBusServiceDefault.class);
-        if(ebs != null) {
-            ebs.close();
-        }
-    }
-
-    private void completeCommandIfConfigured() {
-        final CommandContext commandContext = getServiceOrNull(CommandContext.class);
-        if(commandContext != null) {
-            final CommandService commandService = getServiceOrNull(CommandService.class);
-            if(commandService != null) {
-                final Command command = commandContext.getCommand();
-                commandService.complete(command);
-            }
-        }
-    }
 
     private void endRequestOnRequestScopeServices() {
         for (final Object service : servicesInjector.getRegisteredServices()) {

http://git-wip-us.apache.org/repos/asf/isis/blob/c957bdc4/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 6d2a5bd..a60f64f 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
@@ -43,6 +43,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.isis.applib.Identifier;
+import org.apache.isis.applib.annotation.Bulk;
 import org.apache.isis.applib.annotation.PublishedAction;
 import org.apache.isis.applib.annotation.PublishedObject;
 import org.apache.isis.applib.annotation.PublishedObject.ChangeKind;
@@ -51,9 +52,15 @@ import org.apache.isis.applib.services.audit.AuditingService3;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.services.command.Command;
 import org.apache.isis.applib.services.command.CommandContext;
+import org.apache.isis.applib.services.command.spi.CommandService;
 import org.apache.isis.applib.services.publish.EventMetadata;
+import org.apache.isis.applib.services.publish.EventPayload;
+import org.apache.isis.applib.services.publish.EventPayloadForActionInvocation;
+import org.apache.isis.applib.services.publish.EventPayloadForObjectChanged;
+import org.apache.isis.applib.services.publish.EventSerializer;
 import org.apache.isis.applib.services.publish.EventType;
 import org.apache.isis.applib.services.publish.ObjectStringifier;
+import org.apache.isis.applib.services.publish.PublishingService;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.components.TransactionScopedComponent;
 import org.apache.isis.core.commons.ensure.Ensure;
@@ -73,6 +80,7 @@ import org.apache.isis.core.metamodel.facets.object.audit.AuditableFacet;
 import org.apache.isis.core.metamodel.facets.object.encodeable.EncodableFacet;
 import org.apache.isis.core.metamodel.facets.object.publish.PublishedObjectFacet;
 import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext.TransactionState;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
 import org.apache.isis.core.metamodel.spec.feature.Contributed;
 import org.apache.isis.core.metamodel.spec.feature.ObjectAssociation;
 import org.apache.isis.core.progmodel.facets.actions.invoke.CommandUtil;
@@ -83,6 +91,8 @@ import org.apache.isis.core.runtime.persistence.objectstore.transaction.Persiste
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PublishingServiceWithDefaultPayloadFactories;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.SaveObjectCommand;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.TransactionalResource;
+import org.apache.isis.core.runtime.services.RequestScopedService;
+import org.apache.isis.core.runtime.services.eventbus.EventBusServiceDefault;
 import org.apache.isis.core.runtime.system.context.IsisContext;
 
 /**
@@ -201,12 +211,18 @@ public class IsisTransaction implements TransactionScopedComponent {
     private final org.apache.isis.core.commons.authentication.MessageBroker messageBroker;
     private final UpdateNotifier updateNotifier;
 
+    private final ServicesInjector servicesInjector;
+
     /**
      * the 'owning' command, (if service configured).
      */
     private final Command command;
 
     /**
+     * Could be null if not configured as a domain service.
+     */
+    private final CommandContext commandContext;
+    /**
      * could be null if none has been registered.
      */
     private final AuditingService3 auditingService3;
@@ -223,25 +239,29 @@ public class IsisTransaction implements TransactionScopedComponent {
     private State state;
     private IsisException abortCause;
 
+
+
+
     public IsisTransaction(
             final IsisTransactionManager transactionManager, 
             final org.apache.isis.core.commons.authentication.MessageBroker messageBroker, 
             final UpdateNotifier updateNotifier, 
             final TransactionalResource objectStore, 
-            final CommandContext commandContext, 
-            final AuditingService3 auditingService3, 
-            final PublishingServiceWithDefaultPayloadFactories publishingService) {
+            final ServicesInjector servicesInjector) {
         
         ensureThatArg(transactionManager, is(not(nullValue())), "transaction manager is required");
         ensureThatArg(messageBroker, is(not(nullValue())), "message broker is required");
         ensureThatArg(updateNotifier, is(not(nullValue())), "update notifier is required");
+        ensureThatArg(servicesInjector, is(not(nullValue())), "services injector is required");
 
         this.transactionManager = transactionManager;
         this.messageBroker = messageBroker;
         this.updateNotifier = updateNotifier;
+        this.servicesInjector = servicesInjector;
         
-        this.auditingService3 = auditingService3;
-        this.publishingService = publishingService;
+        this.commandContext = servicesInjector.lookupService(CommandContext.class);
+        this.auditingService3 = servicesInjector.lookupService(AuditingService3.class);
+        this.publishingService = getPublishingServiceIfAny(servicesInjector);
 
         // determine whether this xactn is taking place in the context of an
         // existing command in which a previous xactn has already occurred.
@@ -267,6 +287,63 @@ public class IsisTransaction implements TransactionScopedComponent {
         }
     }
 
+    
+    // ///////////////////////////////////////////
+    // Publishing service
+    // ///////////////////////////////////////////
+
+    private PublishingServiceWithDefaultPayloadFactories getPublishingServiceIfAny(ServicesInjector servicesInjector) {
+        final PublishingService publishingService = servicesInjector.lookupService(PublishingService.class);
+        if(publishingService == null) {
+            return null;
+        }
+
+        EventSerializer eventSerializer = servicesInjector.lookupService(EventSerializer.class);
+        if(eventSerializer == null) {
+            eventSerializer = newSimpleEventSerializer();
+        }
+
+        PublishedObject.PayloadFactory objectPayloadFactory = servicesInjector.lookupService(PublishedObject.PayloadFactory.class);
+        if(objectPayloadFactory == null) {
+            objectPayloadFactory = newDefaultObjectPayloadFactory();
+        }
+        
+        PublishedAction.PayloadFactory actionPayloadFactory = servicesInjector.lookupService(PublishedAction.PayloadFactory.class);
+        if(actionPayloadFactory == null) {
+            actionPayloadFactory = newDefaultActionPayloadFactory();
+        }
+        
+        return new PublishingServiceWithDefaultPayloadFactories(publishingService, objectPayloadFactory, actionPayloadFactory);
+    }
+    
+
+    protected EventSerializer newSimpleEventSerializer() {
+        return new EventSerializer.Simple();
+    }
+
+
+    protected PublishedObject.PayloadFactory newDefaultObjectPayloadFactory() {
+        return new PublishedObject.PayloadFactory() {
+            @Override
+            public EventPayload payloadFor(final Object changedObject, ChangeKind changeKind) {
+                return new EventPayloadForObjectChanged<Object>(changedObject);
+            }
+        };
+    }
+
+    protected PublishedAction.PayloadFactory newDefaultActionPayloadFactory() {
+        return new PublishedAction.PayloadFactory(){
+            @Override
+            public EventPayload payloadFor(Identifier actionIdentifier, Object target, List<Object> arguments, Object result) {
+                return new EventPayloadForActionInvocation<Object>(
+                        actionIdentifier, 
+                        target, 
+                        arguments, 
+                        result);
+            }
+        };
+    }
+    
     // ////////////////////////////////////////////////////////////////
     // GUID
     // ////////////////////////////////////////////////////////////////
@@ -660,16 +737,56 @@ public class IsisTransaction implements TransactionScopedComponent {
             publishedChangedObjectsIfRequired(currentUser, endTimestamp);
             doFlush();
             
+            closeServices();
+            doFlush();
+            
             setState(State.COMMITTED);
         } catch (final RuntimeException ex) {
             setAbortCause(new IsisTransactionManagerException(ex));
+            clearCommandServiceIfConfigured();
             throw ex;
         }
     }
 
     
+    private void clearCommandServiceIfConfigured() {
+        completeCommandIfConfigured();
+    }
+
+
+    private void closeServices() {
+        closeOtherApplibServicesIfConfigured();
+        completeCommandIfConfigured();
+    }
+
+    /**
+     * @return - the service, or <tt>null</tt> if no service registered of specified type.
+     */
+    public <T> T getServiceOrNull(Class<T> serviceType) {
+        return servicesInjector.lookupService(serviceType);
+    }
 
+    private void closeOtherApplibServicesIfConfigured() {
+        Bulk.InteractionContext bic = getServiceOrNull(Bulk.InteractionContext.class);
+        if(bic != null) {
+            Bulk.InteractionContext.current.set(null);
+        }
+        EventBusServiceDefault ebs = getServiceOrNull(EventBusServiceDefault.class);
+        if(ebs != null) {
+            ebs.close();
+        }
+    }
 
+    private void completeCommandIfConfigured() {
+        final CommandContext commandContext = getServiceOrNull(CommandContext.class);
+        if(commandContext != null) {
+            final CommandService commandService = getServiceOrNull(CommandService.class);
+            if(commandService != null) {
+                final Command command = commandContext.getCommand();
+                commandService.complete(command);
+            }
+        }
+    }
 
     // ////////////////////////////////////////////////////////////////
     // markAsAborted

http://git-wip-us.apache.org/repos/asf/isis/blob/c957bdc4/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 102706d..6c867ff 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
@@ -48,6 +48,7 @@ import org.apache.isis.core.commons.debug.DebugBuilder;
 import org.apache.isis.core.commons.exceptions.IsisException;
 import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
 import org.apache.isis.core.metamodel.adapter.oid.OidMarshaller;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
 import org.apache.isis.core.metamodel.services.ServicesInjectorSpi;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PersistenceCommand;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PublishingServiceWithDefaultPayloadFactories;
@@ -64,19 +65,6 @@ public class IsisTransactionManager implements SessionScopedComponent {
 
     private int transactionLevel;
     
-    /**
-     * Could be null if not configured as a domain service.
-     */
-    private final CommandContext commandContext;
-    /**
-     * Could be null if not configured as a domain service.
-     */
-    private final AuditingService3 auditingService3;
-    /**
-     * Could be null if not configured as a domain service.
-     */
-    private final PublishingServiceWithDefaultPayloadFactories publishingService;
-
     private IsisSession session;
 
     /**
@@ -86,18 +74,17 @@ public class IsisTransactionManager implements SessionScopedComponent {
 
     private final TransactionalResource transactionalResource;
 
+    private final ServicesInjector servicesInjector;
+
 
     // ////////////////////////////////////////////////////////////////
     // constructor
     // ////////////////////////////////////////////////////////////////
 
-    public IsisTransactionManager(final PersistenceSession persistenceSession, final TransactionalResource transactionalResource, final ServicesInjectorSpi servicesInjectorSpi) {
+    public IsisTransactionManager(final PersistenceSession persistenceSession, final TransactionalResource transactionalResource, final ServicesInjector servicesInjector) {
         this.persistenceSession = persistenceSession;
         this.transactionalResource = transactionalResource;
-        
-        this.commandContext = servicesInjectorSpi.lookupService(CommandContext.class);
-        this.auditingService3 = servicesInjectorSpi.lookupService(AuditingService3.class);
-        this.publishingService = getPublishingServiceIfAny(servicesInjectorSpi);
+        this.servicesInjector = servicesInjector;
     }
     
     
@@ -270,7 +257,7 @@ public class IsisTransactionManager implements SessionScopedComponent {
         ensureThatArg(messageBroker, is(not(nullValue())));
         ensureThatArg(updateNotifier, is(not(nullValue())));
 
-        return new IsisTransaction(this, messageBroker, updateNotifier, transactionalResource, commandContext, auditingService3, publishingService);
+        return new IsisTransaction(this, messageBroker, updateNotifier, transactionalResource, servicesInjector);
     }
     
 
@@ -450,61 +437,6 @@ public class IsisTransactionManager implements SessionScopedComponent {
     }
 
     
-    // ///////////////////////////////////////////
-    // Publishing service
-    // ///////////////////////////////////////////
-
-    public PublishingServiceWithDefaultPayloadFactories getPublishingServiceIfAny(ServicesInjectorSpi servicesInjectorSpi) {
-        final PublishingService publishingService = servicesInjectorSpi.lookupService(PublishingService.class);
-        if(publishingService == null) {
-            return null;
-        }
-
-        EventSerializer eventSerializer = servicesInjectorSpi.lookupService(EventSerializer.class);
-        if(eventSerializer == null) {
-            eventSerializer = newSimpleEventSerializer();
-        }
-
-        PublishedObject.PayloadFactory objectPayloadFactory = servicesInjectorSpi.lookupService(PublishedObject.PayloadFactory.class);
-        if(objectPayloadFactory == null) {
-            objectPayloadFactory = newDefaultObjectPayloadFactory();
-        }
-        
-        PublishedAction.PayloadFactory actionPayloadFactory = servicesInjectorSpi.lookupService(PublishedAction.PayloadFactory.class);
-        if(actionPayloadFactory == null) {
-            actionPayloadFactory = newDefaultActionPayloadFactory();
-        }
-        
-        return new PublishingServiceWithDefaultPayloadFactories(publishingService, objectPayloadFactory, actionPayloadFactory);
-    }
-
-    protected EventSerializer newSimpleEventSerializer() {
-        return new EventSerializer.Simple();
-    }
-
-
-    protected PublishedObject.PayloadFactory newDefaultObjectPayloadFactory() {
-        return new PublishedObject.PayloadFactory() {
-            @Override
-            public EventPayload payloadFor(final Object changedObject, ChangeKind changeKind) {
-                return new EventPayloadForObjectChanged<Object>(changedObject);
-            }
-        };
-    }
-
-    protected PublishedAction.PayloadFactory newDefaultActionPayloadFactory() {
-        return new PublishedAction.PayloadFactory(){
-            @Override
-            public EventPayload payloadFor(Identifier actionIdentifier, Object target, List<Object> arguments, Object result) {
-                return new EventPayloadForActionInvocation<Object>(
-                        actionIdentifier, 
-                        target, 
-                        arguments, 
-                        result);
-            }
-        };
-    }
-
 
     // //////////////////////////////////////////////////////////////
     // Hooks

http://git-wip-us.apache.org/repos/asf/isis/blob/c957bdc4/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
index 5c58c8b..203bb85 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/PersistenceSessionObjectStoreTest.java
@@ -241,6 +241,10 @@ public class PersistenceSessionObjectStoreTest {
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
                 inSequence(tran);
 
+                // third flush after commands
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                inSequence(tran);
+
                 oneOf(mockObjectStore).endTransaction();
                 inSequence(tran);
             }
@@ -260,6 +264,7 @@ public class PersistenceSessionObjectStoreTest {
             {
                 oneOf(mockObjectStore).startTransaction();
                 inSequence(tran);
+
                 oneOf(mockPersistAlgorithm).makePersistent(transientAdapter, persistenceSession);
                 inSequence(tran);
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
@@ -267,6 +272,10 @@ public class PersistenceSessionObjectStoreTest {
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
                 inSequence(tran);
+                // third flush after commands
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                inSequence(tran);
+
                 oneOf(mockObjectStore).endTransaction();
                 inSequence(tran);
             }

http://git-wip-us.apache.org/repos/asf/isis/blob/c957bdc4/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java
index 5de2f06..68eca35 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/persistence/objectstore/transaction/ObjectStoreTransactionManager_EndTransactionTest.java
@@ -154,10 +154,10 @@ public class ObjectStoreTransactionManager_EndTransactionTest {
                 inSequence(transactionOrdering);
 
                 // flushed twice, once before publishing, once after
-                exactly(2).of(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                exactly(3).of(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
                 inSequence(transactionOrdering);
 
-                one(mockObjectStore).endTransaction();
+                oneOf(mockObjectStore).endTransaction();
                 inSequence(transactionOrdering);
             }
         });

http://git-wip-us.apache.org/repos/asf/isis/blob/c957bdc4/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java
----------------------------------------------------------------------
diff --git a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java
index e79dd33..e8484d7 100644
--- a/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java
+++ b/core/runtime/src/test/java/org/apache/isis/core/runtime/system/transaction/IsisTransactionTest.java
@@ -29,11 +29,18 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 
+import org.apache.isis.applib.annotation.Bulk;
+import org.apache.isis.applib.annotation.PublishedAction;
+import org.apache.isis.applib.annotation.PublishedObject;
 import org.apache.isis.applib.services.audit.AuditingService3;
 import org.apache.isis.applib.services.command.CommandContext;
+import org.apache.isis.applib.services.command.spi.CommandService;
+import org.apache.isis.applib.services.publish.EventSerializer;
+import org.apache.isis.applib.services.publish.PublishingService;
 import org.apache.isis.core.commons.authentication.AuthenticationSession;
 import org.apache.isis.core.commons.matchers.IsisMatchers;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
 import org.apache.isis.core.runtime.persistence.ObjectPersistenceException;
 import org.apache.isis.core.runtime.persistence.objectstore.ObjectStoreSpi;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.CreateObjectCommand;
@@ -44,6 +51,7 @@ import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdap
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PojoAdapterBuilder.Persistence;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.PublishingServiceWithDefaultPayloadFactories;
 import org.apache.isis.core.runtime.persistence.objectstore.transaction.SaveObjectCommand;
+import org.apache.isis.core.runtime.services.eventbus.EventBusServiceDefault;
 import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2;
 import org.apache.isis.core.unittestsupport.jmocking.JUnitRuleMockery2.Mode;
 
@@ -74,14 +82,29 @@ public class IsisTransactionTest {
     @Mock
     private CommandContext mockCommandContext;
     @Mock
+    private CommandService mockCommandService;
+    @Mock
     private AuditingService3 mockAuditingService3;
     @Mock
-    private PublishingServiceWithDefaultPayloadFactories mockPublishingService;
+    private PublishingService mockPublishingService;
+    @Mock
+    private EventSerializer mockEventSerializer;
+    @Mock
+    private ServicesInjector mockServicesInjector;
+    @Mock
+    private PublishedObject.PayloadFactory mockPublishedObjectPayloadFactory;
+    @Mock
+    private PublishedAction.PayloadFactory mockPublishedActionPayloadFactory;
+    @Mock
+    private Bulk.InteractionContext mockBulkInteractionContext;
+    @Mock
+    private EventBusServiceDefault mockEventBusServiceDefault;
 
     private PersistenceCommand command;
     private PersistenceCommand command2;
     private PersistenceCommand command3;
 
+
     private CreateObjectCommand createCreateCommand(final ObjectAdapter object, final String name) {
         return new CreateObjectCommand() {
 
@@ -162,8 +185,44 @@ public class IsisTransactionTest {
         org.apache.log4j.Logger.getRootLogger().setLevel(org.apache.log4j.Level.OFF);
 
         context.ignoring(mockCommandContext);
+        context.ignoring(mockCommandService);
         context.ignoring(mockAuditingService3);
-        
+        context.ignoring(mockEventBusServiceDefault);
+
+        context.checking(new Expectations(){{
+            allowing(mockServicesInjector).lookupService(CommandContext.class);
+            will(returnValue(mockCommandContext));
+
+            allowing(mockServicesInjector).lookupService(CommandService.class);
+            will(returnValue(mockCommandService));
+
+            allowing(mockServicesInjector).lookupService(AuditingService3.class);
+            will(returnValue(mockAuditingService3));
+
+            allowing(mockServicesInjector).lookupService(PublishingService.class);
+            will(returnValue(mockPublishingService));
+            
+            allowing(mockServicesInjector).lookupService(EventSerializer.class);
+            will(returnValue(mockEventSerializer));
+            
+            allowing(mockServicesInjector).lookupService(PublishedObject.PayloadFactory.class);
+            will(returnValue(mockPublishedObjectPayloadFactory));
+            
+            allowing(mockServicesInjector).lookupService(PublishedAction.PayloadFactory.class);
+            will(returnValue(mockPublishedActionPayloadFactory));
+            
+            allowing(mockServicesInjector).lookupService(Bulk.InteractionContext.class);
+            will(returnValue(mockBulkInteractionContext));
+            
+            allowing(mockServicesInjector).lookupService(EventBusServiceDefault.class);
+            will(returnValue(mockEventBusServiceDefault));
+            
+            allowing(mockServicesInjector).getRegisteredServices();
+            will(returnValue(Collections.emptyList())); // close enough...
+
+        }});
+
+
         context.checking(new Expectations(){{
             allowing(mockTransactionManager).getAuthenticationSession();
             will(returnValue(mockAuthenticationSession));
@@ -174,7 +233,7 @@ public class IsisTransactionTest {
             will(returnValue("sven"));
         }});
         
-        transaction = new IsisTransaction(mockTransactionManager, mockMessageBroker, mockUpdateNotifier, mockObjectStore, mockCommandContext, mockAuditingService3, mockPublishingService);
+        transaction = new IsisTransaction(mockTransactionManager, mockMessageBroker, mockUpdateNotifier, mockObjectStore, mockServicesInjector);
         
         transientAdapter1 = PojoAdapterBuilder.create().with(Persistence.TRANSIENT).withIdentifier("1").build();
         transientAdapter2 = PojoAdapterBuilder.create().with(Persistence.TRANSIENT).withIdentifier("2").build();
@@ -211,6 +270,8 @@ public class IsisTransactionTest {
                 oneOf(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command, command2)));
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                // and for command
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
             }
         });
         
@@ -230,6 +291,8 @@ public class IsisTransactionTest {
                 oneOf(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command)));
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                // and for command
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
             }
         });
         
@@ -250,6 +313,8 @@ public class IsisTransactionTest {
                 oneOf(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command)));
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                // and for command
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
             }
         });
         
@@ -270,6 +335,8 @@ public class IsisTransactionTest {
                 oneOf(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command2, command3)));
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                // and for command
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
             }
         });
         
@@ -291,6 +358,8 @@ public class IsisTransactionTest {
                 oneOf(mockObjectStore).execute(with(IsisMatchers.listContainingAll(command2)));
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                // and for command
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
             }
         });
         
@@ -308,6 +377,8 @@ public class IsisTransactionTest {
                 oneOf(mockObjectStore).execute(with(Collections.<PersistenceCommand>emptyList()));
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                // and for command
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
             }
         });
 
@@ -336,6 +407,8 @@ public class IsisTransactionTest {
                 oneOf(mockObjectStore).execute(with(Collections.<PersistenceCommand>emptyList()));
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                // and for command
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
             }
         });
 
@@ -351,6 +424,8 @@ public class IsisTransactionTest {
                 oneOf(mockObjectStore).execute(with(Collections.<PersistenceCommand>emptyList()));
                 // second flush after publish
                 oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
+                // and for command
+                oneOf(mockObjectStore).execute(with(equalTo(Collections.<PersistenceCommand>emptyList())));
             }
         });
         transaction.commit();


[2/2] git commit: ISIS-760: increased column length for target

Posted by jc...@apache.org.
ISIS-760: increased column length for target

from 255 to 2000 (to cope with the longer OIDs of view models).  Chose 2000 as a defacto length allowed for request URLs (since OIDs of view models appear in the URL of web browsers in both Wicket and Restful Objects viewers).


Project: http://git-wip-us.apache.org/repos/asf/isis/repo
Commit: http://git-wip-us.apache.org/repos/asf/isis/commit/0fc37090
Tree: http://git-wip-us.apache.org/repos/asf/isis/tree/0fc37090
Diff: http://git-wip-us.apache.org/repos/asf/isis/diff/0fc37090

Branch: refs/heads/master
Commit: 0fc3709066cb012cb33363252bd752874d034e3b
Parents: c957bdc
Author: Jeroen van der Wal <je...@stromboli.it>
Authored: Thu Apr 3 12:22:53 2014 +0200
Committer: Jeroen van der Wal <je...@stromboli.it>
Committed: Thu Apr 3 12:34:26 2014 +0200

----------------------------------------------------------------------
 .../isis/objectstore/jdo/applib/service/JdoColumnLength.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/isis/blob/0fc37090/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java
----------------------------------------------------------------------
diff --git a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java
index 55917e0..6375ab0 100644
--- a/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java
+++ b/component/objectstore/jdo/jdo-applib/src/main/java/org/apache/isis/objectstore/jdo/applib/service/JdoColumnLength.java
@@ -24,8 +24,8 @@ public final class JdoColumnLength {
     }
 
     public final static int TRANSACTION_ID = 36;
-    // ie OID str
-    public final static int BOOKMARK = 255; 
+    // ie OID str (based on the defacto limit of a request URL in web browsers such as IE8)
+    public final static int BOOKMARK = 2000; 
     public static final int MEMBER_IDENTIFIER = 255;
     public static final int USER_NAME = 50;
     public final static int TARGET_CLASS = 50;