You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by bu...@apache.org on 2013/02/08 16:14:32 UTC

svn commit: r849891 - in /websites/staging/isis/trunk: cgi-bin/ content/ content/core/publishing-service.html

Author: buildbot
Date: Fri Feb  8 15:14:32 2013
New Revision: 849891

Log:
Staging update by buildbot for isis

Modified:
    websites/staging/isis/trunk/cgi-bin/   (props changed)
    websites/staging/isis/trunk/content/   (props changed)
    websites/staging/isis/trunk/content/core/publishing-service.html

Propchange: websites/staging/isis/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Feb  8 15:14:32 2013
@@ -1 +1 @@
-1444052
+1444057

Propchange: websites/staging/isis/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Fri Feb  8 15:14:32 2013
@@ -1 +1 @@
-1444052
+1444057

Modified: websites/staging/isis/trunk/content/core/publishing-service.html
==============================================================================
--- websites/staging/isis/trunk/content/core/publishing-service.html (original)
+++ websites/staging/isis/trunk/content/core/publishing-service.html Fri Feb  8 15:14:32 2013
@@ -268,10 +268,10 @@
 <p>Similarly, to indicate that any changes to an object should be published, use the <code>PublishedObject</code> annotation:</p>
 
 <pre>
-@PublishedObject
-public class ToDoItem {
+  @PublishedObject
+  public class ToDoItem {
     ...
-</div>}
+  }
 </pre>
 
 <p>Either or both of these annotations can be used.</p>
@@ -283,25 +283,25 @@ public class ToDoItem {
 <p>The <code>PublishingService</code> interface is:</p>
 
 <pre>
-package org.apache.isis.applib.services.publish;
+  package org.apache.isis.applib.services.publish;
 
-public interface PublishingService {
+  public interface PublishingService {
 
     @Hidden
     public void publish(EventMetadata metadata, EventPayload payload);
 
     void setEventSerializer(EventSerializer eventSerializer);
-</div>}
+  }
 </pre>
 
 <p>Typically implementations will use the injected <code>EventSerializer</code> to convert the metadata and payload into a form to be published:</p>
 
 <pre>
-package org.apache.isis.applib.services.publish;
+  package org.apache.isis.applib.services.publish;
 
-public interface EventSerializer {
+  public interface EventSerializer {
     public Object serialize(EventMetadata metadata, EventPayload payload);
-</div>}
+  }
 </pre>
 
 <p>The serialized form returned by <code>EventSerializer</code> will typically be something like JSON, XML or a string.  The signature of <code>serialize(...)</code> returns an object 
@@ -314,47 +314,47 @@ lowest common denominator, but in some c
 <p>A default implementation of <code>EventSerializer</code> will be supplied to the <code>PublishingService</code> if none has been specified as a domain service.  This default implementation simply concatenates the metadata and payload together into a single string:</p>
 
 <pre>
-public interface EventSerializer {
+  public interface EventSerializer {
     ...
     public static class Simple implements EventSerializer {
 
-        @Programmatic
-        @Override
-        public Object serialize(EventMetadata metadata, EventPayload payload) {
-            return "PUBLISHED: \n    metadata: " + 
-                      metadata.getGuid() + ":" + 
-                      metadata.getUser() + ":" + 
-                      metadata.getTimestamp() + 
-                   ":    payload:s\n" + 
-                      payload.toString();
-        }
+      @Programmatic
+      @Override
+      public Object serialize(EventMetadata metadata, EventPayload payload) {
+          return "PUBLISHED: \n    metadata: " + 
+                    metadata.getGuid() + ":" + 
+                    metadata.getUser() + ":" + 
+                    metadata.getTimestamp() + 
+                 ":    payload:s\n" + 
+                    payload.toString();
+      }
     }
     ...
-</div>}
+  }
 </pre>
 
 <p>A simple implementation of <code>PublishingService</code> (which must be configured as a domain service) is also available; this simply writes to stderr is also provided:</p>
 
 <pre>
-public interface PublishingService {
-    ...
+  public interface PublishingService {
+  ...
     public static class Stderr implements PublishingService {
     private EventSerializer eventSerializer = new EventSerializer.Simple();
-        @Hidden
-        @Override
-        public void publish(EventMetadata metadata, EventPayload payload) {
-            Object serializedEvent = eventSerializer.serialize(
-                metadata, payload);
-            System.err.println(serializedEvent);
-        }
-
-        @Override
-        public void setEventSerializer(EventSerializer eventSerializer) {
-            this.eventSerializer = eventSerializer;
-        }
+      @Hidden
+      @Override
+      public void publish(EventMetadata metadata, EventPayload payload) {
+        Object serializedEvent = eventSerializer.serialize(
+          metadata, payload);
+        System.err.println(serializedEvent);
+      }
+
+      @Override
+      public void setEventSerializer(EventSerializer eventSerializer) {
+        this.eventSerializer = eventSerializer;
+      }
     }
     ...
-</div>}
+  }
 </pre>
 
 <p>Thus, to configure a very simple form of publishing, add the following to <code>isis.properties</code>:</p>
@@ -388,61 +388,61 @@ isis.services=<i>...other services...</i
 <p>To accomplish this, an implementation of a "<code>PayloadFactory</code>" must be specified in the annotation.  For actions, implement <code>@PublishedAction.PayloadFactory</code>:</p>
 
 <pre>
-public @interface PublishedAction {
+  public @interface PublishedAction {
 
     public interface PayloadFactory {
-        @Programmatic
-        public EventPayload payloadFor(
-            Identifier actionIdentifier, 
-            Object target, List&lt;Object&gt; arguments, Object result);
+      @Programmatic
+      public EventPayload payloadFor(
+          Identifier actionIdentifier, 
+          Object target, List&lt;Object&gt; arguments, Object result);
     }
     Class&lt;? extends PayloadFactory&gt; value()  default PayloadFactory.class;
-</div>}
+  }
 </pre>
 
 <p>For objects, the interface to implement is <code>@PublishedObject.PayloadFactory</code>:</p>
 
 <pre>
-public @interface PublishedObject {
+  public @interface PublishedObject {
 
     public interface PayloadFactory {
-        @Programmatic
-        public EventPayload payloadFor(Object changed);
+      @Programmatic
+      public EventPayload payloadFor(Object changed);
     }
     Class&lt;? extends PayloadFactory&gt; value()  default PayloadFactory.class;
-</div>}
+  }
 </pre>
 
 <p>For example, the following will eagerly include the <code>ToDoItem</code>'s <code>description</code> property whenever it is changed:</p>
 
 <pre>
-@PublishedObject(ToDoItemPayloadFactory.class)
-public class ToDoItem {
+  @PublishedObject(ToDoItemPayloadFactory.class)
+  public class ToDoItem {
     ...
-</div>}
+  }
 </pre>
 
 <p>where <code>ToDoItemPayloadFactory</code> is defined as:</p>
 
 <pre>
-public class ToDoItemChangedPayloadFactory implements PayloadFactory {
+  public class ToDoItemChangedPayloadFactory implements PayloadFactory {
 
     public static class ToDoItemPayload 
-            extends EventPayloadForChangedObject<ToDoItem> {
+        extends EventPayloadForChangedObject<ToDoItem> {
 
-        public ToDoItemPayload(ToDoItem changed) {
-            super(changed);
-        }
-
-        public String getDescription() {
-            return getChanged().getDescription();
-        }
+      public ToDoItemPayload(ToDoItem changed) {
+          super(changed);
+      }
+
+      public String getDescription() {
+          return getChanged().getDescription();
+      }
     }
     @Override
     public EventPayload payloadFor(Object changedObject) {
-        return new ToDoItemPayload((ToDoItem) changedObject);
+      return new ToDoItemPayload((ToDoItem) changedObject);
     }
-</div>}
+  }
 </pre>
 
 <h3>Class Diagram</h3>