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 2017/10/03 11:59:04 UTC

[isis] 21/24: ISIS-1742: simplifies the API of PublishingServiceInternalDefault.

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch dev/2.0.0/ISIS-1742-remove-deprecations
in repository https://gitbox.apache.org/repos/asf/isis.git

commit c90adb75bb9684ae32517ed38d03937e7e925b75
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Tue Oct 3 10:03:44 2017 +0100

    ISIS-1742: simplifies the API of PublishingServiceInternalDefault.
    
    Also deletes PublishingService.adoc
---
 ...vc_persistence-layer-spi_PublishingService.adoc | 199 ---------------------
 ...ctionInvocationFacetForDomainEventAbstract.java |   6 +-
 .../publishing/PublishingServiceInternal.java      |  11 +-
 .../publish/PublishingServiceInternalDefault.java  |   9 +-
 4 files changed, 4 insertions(+), 221 deletions(-)

diff --git a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_persistence-layer-spi_PublishingService.adoc b/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_persistence-layer-spi_PublishingService.adoc
deleted file mode 100644
index da4230d..0000000
--- a/adocs/documentation/src/main/asciidoc/guides/rgsvc/_rgsvc_persistence-layer-spi_PublishingService.adoc
+++ /dev/null
@@ -1,199 +0,0 @@
-[[_rgsvc_persistence-layer-spi_PublishingService]]
-= `PublishingService` (deprecated)
-:Notice: 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 ag [...]
-:_basedir: ../../
-:_imagesdir: images/
-
-
-
-The `PublishingService` API is intended for coarse-grained publish/subscribe for system-to-system interactions, from Apache Isis to some other system.  Here the only events published are those that action invocations and of changed objects.  A typical use case is to publish onto a pub/sub bus such as link:http://activemq.apache.org/[ActiveMQ] with link:http://camel.apache.org[Camel] to keep other systems up to date.
-
-
-[WARNING]
-====
-As of `1.13.0` this service is deprecated, replaced with xref:../rgsvc/rgsvc.adoc#_rgsvc_persistence-layer-spi_PublisherService[`PublisherService`].
-====
-
-
-
-== SPI
-
-The SPI defined by the service is:
-
-[source,java]
-----
-@Deprecated
-public interface PublishingService {
-    public void publish(
-        EventMetadata metadata,                                 // <1>
-        EventPayload payload);                                  // <2>
-    void setEventSerializer(EventSerializer eventSerializer);   // <3>
-}
-----
-<1> standard metadata about the event, such as the user, the xref:../rgcms/rgcms.adoc#_rgcms_classes_mixins_HasTransactionId[`transactionId`], date/time etc
-<2> for published actions, an `EventPayloadForActionInvocation` (or subclass thereof); for published objects, an `EventPayloadForObjectChanged` (or subclass thereof)
-<3> injects in the xref:../rgsvc/rgsvc.adoc#_rgsvc_persistence-layer-spi_EventSerializer[`EventSerializer`] service.  This is deprecated because not every implementation is required to use an `EventSerializer` so its inclusion within the SPI of `PublishingService` was in retrospect a mistake.
-
-
-Typically implementations will use the injected `EventSerializer` to convert the metadata and payload into a form to be published:
-
-[source,java]
-----
-public interface EventSerializer {
-    public Object serialize(EventMetadata metadata, EventPayload payload);
-}
-----
-
-The serialized form returned by `EventSerializer` must be in a form that the `PublishingService` implementation is able to handle. Strings are a good lowest common denominator, but (if custom implementations of both `EventSerializer` and `PublishingService` were in use) then it might also be some other type, for example an `org.w3c.dom.Document` or an `org.json.JSONObject` might be returned instead.
-
-
-
-== Implementation
-
-The (obsolete) http://github.com/isisaddons-legacy/isis-module-publishing[Isis addons' publishing] module provides an implementation (`org.isisaddons.module.publishing.dom.PublishingService`) that persists each event as a `PublishedEvent` entity.
-This holds the serialized form of the event metadata and payload as translated into a string by the injected `EventSerializer`.  The module also provides its own implementation of `EventSerializer`,
-namely `RestfulObjectsSpecEventSerializer`, which represents the event payload using the representation defined by the
-link:http://restfulobjects.org[Restful Objects spec] of (transient) objects, grafting on the metadata as additional
-JSON nodes.
-
-The `PublishedEvent` entity also has a `state` field taking the values either "QUEUED" or "PROCESSED".
-The intention here is that an event bus can poll this table to grab pending events and dispatch them to downstream systems.
-When ``PublishedEvent``s are persisted initially they always take the value "QUEUED".
-
-The framework provides no default implementations of this service.
-
-
-
-== Usage
-
-To indicate that an action invocation should be published, annotate it with the xref:../rgant/rgant.adoc#_rgant-Action_publishing[`@Action#publishing()`] annotation.
-
-To indicate that a changed object should be published is to annotate it with the xref:../rgant/rgant.adoc#_rgant-DomainObject_publishing[`@DomainObject#publishing()`] annotation.
-
-
-It is also possible to "fine-tune" the `EventPayload` using the `#publishingFactory()` attribute (for both annotations).  By default the `EventPayload` that is serialized identifies the object(s) being interacted with or changed, and in the case of the action invocation provides details of the action arguments and result (if any) of that action.  However, the payload does not (by default) include any information about the new state of these objects. It is therefore the responsibility of  [...]
-
-[NOTE]
-====
-The replacement xref:../rgsvc/rgsvc.adoc#_rgsvc_persistence-layer-spi_PublisherService[`PublisherService`] does __not__ support the concept of "payload factories" (but is otherwise more flexible).
-====
-
-
-Although the representations (if using the Restful Object serializer and Restful Objects viewer) does include hrefs
-for the objects, this nevertheless requires an additional network call to obtain this information).
-
-In some circumstances, then, it may make more sense to eagerly "push" information about the change to the subscriber by including that state within the payload.
-
-To accomplish this, an implementation of a "`PayloadFactory`" must be specified in the annotation.
-
-For actions, we implement the `PublishingPayloadFactoryForAction` (in `o.a.i.applib.annotation`):
-
-[source,java]
-----
-@Deprecated
-public interface PublishingPayloadFactoryForAction {
-    public EventPayload payloadFor(
-            Identifier actionIdentifier,
-            Object target,
-            List<Object> arguments,
-            Object result);
-}
-}
-----
-The `EventPayloadForActionInvocation` abstract class (in the Isis applib) should be used as the base class for the object instance returned from `payLoadFor(...)`.
-
-For objects, the interface to implement is `PublishingPayloadFactoryForObject`:
-
-[source,java]
-----
-@Deprecated
-public interface PublishingPayloadFactoryForObject {
-    public EventPayload payloadFor(
-        Object changedObject,
-        PublishingChangeKind publishingChangeKind);     // <1>
-}
-----
-<1> an enum taking the values `CREATE`, `UPDATE`, `DELETE`
-
-Similarly, the `EventPayloadForObjectChanged` abstract class should be used as the base class for the object returned from `payLoadFor(...)`.
-
-For example, the following will eagerly include a `ToDoItem`'s `description` property whenever it is changed:
-
-[source,java]
-----
-@DomainObject(publishingPayloadFactory=ToDoItemPayloadFactory.class)
-public class ToDoItem {
-    ...
-}
-----
-
-where `ToDoItemPayloadFactory` is defined as:
-
-[source,java]
-----
-public class ToDoItemChangedPayloadFactory implements PublishingPayloadFactoryForObject {
-    public static class ToDoItemPayload
-        extends EventPayloadForObjectChanged<ToDoItem> {
-      public ToDoItemPayload(ToDoItem changed) { super(changed); }
-      public String getDescription() { return getChanged().getDescription(); }
-    }
-    @Override
-    public EventPayload payloadFor(Object changedObject, PublishingChangeKind kind) {
-        return new ToDoItemPayload((ToDoItem) changedObject);
-    }
-}
-----
-
-
-
-
-== Registering the Services
-
-There is no default implementation of this service provided by the core Apache Isis framework.
-
-The (obsolete) Isis addons' http://github.com/isisaddons-legacy/isis-module-publishing[publishing] module provides an implementation of this service.
-Assuming that an `AppManifest` is being used to xref:../rgcms/rgcms.adoc#_rgcms_classes_AppManifest-bootstrapping[bootstrap the app]) then this can be activated by updating the `pom.xml` and updating the `AppManifest#getModules()` method.
-
-The module also provides services that contribute to the UI.
-If contributions are not required in the UI, these can be suppressed either using security or by implementing a xref:../ugbtb/ugbtb.adoc#_ugbtb_hints-and-tips_vetoing-visibility[vetoing subscriber].
-
-
-
-
-
-== Related Services
-
-The `PublishingService` is intended for coarse-grained publish/subscribe for system-to-system interactions, from
-Apache Isis to some other system. Here the only events published are those that action invocations (for actions
-annotated with xref:../rgant/rgant.adoc#_rgant-Action_publishing[`@Action#publishing()`]) and of changed objects (for objects
-annotated with xref:../rgant/rgant.adoc#_rgant-DomainObject_publishing[`@DomainObject#publishing()`].
-
-The xref:../rgsvc/rgsvc.adoc#_rgsvc_persistence-layer-spi_PublisherService[`PublisherService`] is intended as a replacement for this service.  The
-use case for `PublisherService` is the same: coarse-grained publishing of events for system-to-system interactions.  It
-is in most respects more flexible though: events are published both for action invocations (annotated with
-xref:../rgant/rgant.adoc#_rgant-Action_publishing[`@Action#publishing()`]) and also for property edits (annotated with
-xref:../rgant/rgant.adoc#_rgant-Property_publishing[`@Property#publishing()`].  It also publishes changed objects (for objects
-annotated with xref:../rgant/rgant.adoc#_rgant-DomainObject_publishing[`@DomainObject#publishing()`]).  However, rather than
-publishing one event for every changed objects, it publishes a single event that identifies all objects created,
-updated or deleted.
-
-Another significant difference between `PublishingService` and `PublisherService` is in the content of the events
-themselves.  While the former uses the xref:../rgsvc/rgsvc.adoc#_rgsvc_integration-api_MementoService[`MementoService`] to create an
-ad-hoc serialization of the action being invoked, the latter uses the xref:../rgcms/rgcms.adoc#_rgcms_schema[DTOs/XML schemas]
-as a formal specification of the nature of the interaction (action invocation, property edit or changed objects).
-
-The xref:../rgsvc/rgsvc.adoc#_rgsvc_core-domain-api_EventBusService[`EventBusService`] meanwhile differs from both `PublishingService` and
-xref:../rgsvc/rgsvc.adoc#_rgsvc_persistence-layer-spi_PublisherService[`PublisherService`] in that it is intended for fine-grained
-publish/subscribe for object-to-object interactions within an Apache Isis domain object model. The event propagation
-is strictly in-memory, and there are no restrictions on the object acting as the event; it need not be serializable,
-for example.  (That said, it is possible to obtain a serialization of the action invocation/property edit causing the
-current event to be raised using xref:../rgsvc/rgsvc.adoc#_rgsvc_application-layer-api_InteractionContext[`InteractionContext`] domain service).
-
-
-== Design Notes
-
-The following class diagram shows how the above components fit together:
-
-image::{_imagesdir}reference-services-spi/PublishingService/yuml.me-23db58a4.png[width="800px",link="{_imagesdir}reference-services-spi/PublishingService/yuml.me-23db58a4.png"]
-
-This yuml.me diagram was generated at http://yuml.me/edit/23db58a4[yuml.me].
\ No newline at end of file
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
index 38c7fe0..a967962 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/action/invocation/ActionInvocationFacetForDomainEventAbstract.java
@@ -341,10 +341,8 @@ public abstract class ActionInvocationFacetForDomainEventAbstract
                 final List<ObjectAdapter> parameterAdapters = Arrays.asList(argumentAdapters);
 
                 getPublishingServiceInternal().publishAction(
-                        priorExecution,
-                        owningAction, identifiedHolder,
-                        targetAdapter, parameterAdapters,
-                        returnedAdapter);
+                        priorExecution
+                );
             }
         }
 
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java
index 5e857be..bf9d14a 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/services/publishing/PublishingServiceInternal.java
@@ -18,13 +18,8 @@
  */
 package org.apache.isis.core.metamodel.services.publishing;
 
-import java.util.List;
-
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.iactn.Interaction;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 
 public interface PublishingServiceInternal {
 
@@ -33,11 +28,7 @@ public interface PublishingServiceInternal {
 
     @Programmatic
     void publishAction(
-            final Interaction.Execution execution,
-            final ObjectAction objectAction, final IdentifiedHolder identifiedHolder,
-            final ObjectAdapter targetAdapter,
-            final List<ObjectAdapter> parameterAdapters,
-            final ObjectAdapter resultAdapter);
+            final Interaction.Execution execution);
 
     @Programmatic
     void publishProperty(final Interaction.Execution execution);
diff --git a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publish/PublishingServiceInternalDefault.java b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publish/PublishingServiceInternalDefault.java
index 72e75b7..0f88cb1 100644
--- a/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publish/PublishingServiceInternalDefault.java
+++ b/core/runtime/src/main/java/org/apache/isis/core/runtime/services/publish/PublishingServiceInternalDefault.java
@@ -42,10 +42,8 @@ import org.apache.isis.applib.services.publish.PublishedObjects;
 import org.apache.isis.applib.services.publish.PublisherService;
 import org.apache.isis.applib.services.user.UserService;
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
 import org.apache.isis.core.metamodel.facets.object.publishedobject.PublishedObjectFacet;
 import org.apache.isis.core.metamodel.services.publishing.PublishingServiceInternal;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
 import org.apache.isis.core.runtime.services.changes.ChangedObjectsServiceInternal;
 
 /**
@@ -114,12 +112,7 @@ public class PublishingServiceInternalDefault implements PublishingServiceIntern
 
     @Programmatic
     public void publishAction(
-            final Interaction.Execution execution,
-            final ObjectAction objectAction,
-            final IdentifiedHolder identifiedHolder,
-            final ObjectAdapter targetAdapter,
-            final List<ObjectAdapter> parameterAdapters,
-            final ObjectAdapter resultAdapter) {
+            final Interaction.Execution execution) {
 
         if(suppress) {
             return;

-- 
To stop receiving notification emails like this one, please contact
"commits@isis.apache.org" <co...@isis.apache.org>.