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 2014/03/08 09:43:01 UTC
svn commit: r900541 - in /websites/staging/isis/trunk: cgi-bin/ content/
content/components/objectstores/jdo/services/ content/reference/services/
Author: buildbot
Date: Sat Mar 8 08:43:00 2014
New Revision: 900541
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/components/objectstores/jdo/services/publishing-service-jdo.html
websites/staging/isis/trunk/content/reference/services/auditing-service.html
websites/staging/isis/trunk/content/reference/services/command-context.html
websites/staging/isis/trunk/content/reference/services/publishing-service.html
Propchange: websites/staging/isis/trunk/cgi-bin/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat Mar 8 08:43:00 2014
@@ -1 +1 @@
-1575239
+1575502
Propchange: websites/staging/isis/trunk/content/
------------------------------------------------------------------------------
--- cms:source-revision (original)
+++ cms:source-revision Sat Mar 8 08:43:00 2014
@@ -1 +1 @@
-1575239
+1575502
Modified: websites/staging/isis/trunk/content/components/objectstores/jdo/services/publishing-service-jdo.html
==============================================================================
--- websites/staging/isis/trunk/content/components/objectstores/jdo/services/publishing-service-jdo.html (original)
+++ websites/staging/isis/trunk/content/components/objectstores/jdo/services/publishing-service-jdo.html Sat Mar 8 08:43:00 2014
@@ -327,7 +327,7 @@
<p>Although a polling architecture introduces some overhead, it avoids the complexity of XA/JTA transactions which would otherwise be needed to ensure that events are only published atomically with committed changes to the database.</p>
-<h3>Register the Service</h3>
+<h2>Register the Service</h2>
<p>Register like any other service in <code>isis.properties</code>:</p>
@@ -338,6 +338,10 @@
<p>Assuming that you've also configured Isis to use the JDO objectstore, you should be good to go...</p>
+<h2>Related projects</h2>
+
+<p>Dan Haywood's <a href="https://github.com/danhaywood/camel-isis-pubsubjdo">camel-isis-pubsubjdo</a> project up on github shows how to poll and process the persisted <code>PublishedEvent</code> table using <a href="http://camel.apache.org">Apache Camel</a>.</p>
+
</div>
Modified: websites/staging/isis/trunk/content/reference/services/auditing-service.html
==============================================================================
--- websites/staging/isis/trunk/content/reference/services/auditing-service.html (original)
+++ websites/staging/isis/trunk/content/reference/services/auditing-service.html Sat Mar 8 08:43:00 2014
@@ -372,6 +372,8 @@
<h2>Usage</h2>
+<h4>Explicitly marking an object as audited</h4>
+
<p>The typical way to indicate that an object should be audited is to annotate it with the <a href="../recognized-annotations/Audited.html">@Audited</a> annotation, for example:</p>
<pre><code>@Audited
@@ -380,6 +382,8 @@ public class ToDoItem ... {
}
</code></pre>
+<h4>Making auditing the default</h4>
+
<p>As an alternative to annotating every object with <code>@Audited</code>, alternatively this can be configured as the default. Add the following to <code>isis.properties</code>:</p>
<pre><code>isis.services.audit.objects=all
Modified: websites/staging/isis/trunk/content/reference/services/command-context.html
==============================================================================
--- websites/staging/isis/trunk/content/reference/services/command-context.html (original)
+++ websites/staging/isis/trunk/content/reference/services/command-context.html Sat Mar 8 08:43:00 2014
@@ -465,7 +465,7 @@ public class CommandContext {
<pre><code>isis.services.command.actions=all
</code></pre>
-<p>To treat only non-query actions as commands (ie those annotated with <a href="../recognized-annotations/ActionSemantics.html">@ActionSemantics</a> of IDEMPOTENT or NON_IDEMPOTENT), use:</p>
+<p>For some applications it may be required only to record (as commands) only those actions that update objects; in other words queries and searches can be ignored. Put another way, only actions annotated (with <a href="../recognized-annotations/ActionSemantics.html">@ActionSemantics</a>) as IDEMPOTENT or NON_IDEMPOTENT should be treated as commands. In this case, use:</p>
<pre><code>isis.services.command.actions=ignoreQueryOnly
</code></pre>
Modified: websites/staging/isis/trunk/content/reference/services/publishing-service.html
==============================================================================
--- websites/staging/isis/trunk/content/reference/services/publishing-service.html (original)
+++ websites/staging/isis/trunk/content/reference/services/publishing-service.html Sat Mar 8 08:43:00 2014
@@ -338,7 +338,7 @@
<p>Publishing of action invocations is supported by all objectstores. Publishing of changed objects is currently only supported by the <a href="../../components/objectstores/jdo/about.html">JDO objectstore</a>.</p>
</blockquote>
-<h3>Annotating the Domain Model</h3>
+<h2>Annotating the Domain Model</h2>
<p>To indicate that an action should be published, use the <code>PublishedAction</code> annotation. For example:</p>
@@ -364,101 +364,28 @@
<p>As described further down in this article, it is possible to fine-tune the payload. However, simply using the above annotations will suffice in many cases.</p>
-<h3>Configuring the Publishing Service</h3>
+<h2>API</h2>
<p>The <code>PublishingService</code> interface is:</p>
-<pre>
- package org.apache.isis.applib.services.publish;
-
- public interface PublishingService {
-
- @Hidden
+<pre><code>public interface PublishingService {
public void publish(EventMetadata metadata, EventPayload payload);
-
void setEventSerializer(EventSerializer eventSerializer);
- }
-</pre>
+}
+</code></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;
-
- public interface EventSerializer {
+<pre><code>public interface EventSerializer {
public Object serialize(EventMetadata metadata, EventPayload payload);
- }
-</pre>
+}
+</code></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
Although not necessary to implement <code>EventSerializer</code>, typically one should also for maximum flexibility, but its important to make sure that the <code>PublishingService</code> is able to handle the serialized form. Strings are a good
lowest common denominator, but in some cases are type-safe equivalent, such as a
<code>org.w3c.dom.Document</code> or an <code>org.json.JSONObject</code> might be returned instead.</p>
-<h3>Default Implementations</h3>
-
-<p>A simple implementation of <code>PublishingService</code> (which must be configured as a domain service) is available; it simply writes to stderr.</p>
-
-<p>To configure a very simple form of publishing, add the following to <code>isis.properties</code>:</p>
-
-<pre>
-isis.services=<i>...other services...</i>,\
- org.apache.isis.applib.services.publish.PublishingService$StdErr
-</pre>
-
-<p>The implementation is as follows:</p>
-
-<pre>
- 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;
- }
- }
- ...
- }
-</pre>
-
-<p>As can be seen, the above implementation in turn uses a default implementation of <code>EventSerializer</code>, which simply concatenates the metadata and payload together into a single string:</p>
-
-<pre>
- 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();
- }
- }
- ...
- }
-</pre>
-
-<p>The default <code>PublishingService</code> (or indeed any implementation) can be configured to run with a different <code>EventSerializer</code> by configuring the serializer implementation in the <code>isis.properties</code> file. </p>
-
-<h3>Alternative Implementations</h3>
-
-<p>An alternative implementation of the <code>PublishingService</code> is provided by the <a href="../../components/objectstores/jdo/services/publishing-service-jdo.html">JDO Objectstore</a>. This implementation persists the events to a table.</p>
-
-<p>An alternative implementation of the <code>EventSerializer</code> is provided by the <a href="../../components/viewers/restfulobjects/event-serializer-rospec.html">Restful Objects viewer</a>. This implementation serializes the payload using the conventions of the <a href="http://restfulobjects.org">Restful Objects spec</a>.</p>
-
<h3>Fine-tuning the payload</h3>
<p>The <code>EventPayload</code> 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 include the new state of these objects. It is therefore the responsibility of the subscriber to call back to Isis to determine any information that has not been published.</p>
@@ -469,9 +396,7 @@ 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 {
-
+<pre><code>public @interface PublishedAction {
public interface PayloadFactory {
@Programmatic
public EventPayload payloadFor(
@@ -479,38 +404,33 @@ isis.services=<i>...other services...</i
Object target, List<Object> arguments, Object result);
}
Class<? extends PayloadFactory> value() default PayloadFactory.class;
- }
-</pre>
+}
+</code></pre>
<p>For objects, the interface to implement is <code>@PublishedObject.PayloadFactory</code>:</p>
-<pre>
- public @interface PublishedObject {
-
+<pre><code>public @interface PublishedObject {
public interface PayloadFactory {
@Programmatic
public EventPayload payloadFor(Object changed);
}
- Class<? extends PayloadFactory> value() default PayloadFactory.class;
- }
-</pre>
+ Class<? extends PayloadFactory> value() default PayloadFactory.class;
+}
+</code></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 {
+<pre><code>@PublishedObject(ToDoItemPayloadFactory.class)
+public class ToDoItem {
...
- }
-</pre>
+}
+</code></pre>
<p>where <code>ToDoItemPayloadFactory</code> is defined as:</p>
-<pre>
- public class ToDoItemChangedPayloadFactory implements PayloadFactory {
-
+<pre><code>public class ToDoItemChangedPayloadFactory implements PayloadFactory {
public static class ToDoItemPayload
- extends EventPayloadForChangedObject<ToDoItem> {
+ extends EventPayloadForChangedObject<ToDoItem> {
public ToDoItemPayload(ToDoItem changed) {
super(changed);
@@ -524,10 +444,76 @@ isis.services=<i>...other services...</i
public EventPayload payloadFor(Object changedObject) {
return new ToDoItemPayload((ToDoItem) changedObject);
}
- }
-</pre>
+}
+</code></pre>
+
+<h2>Default Implementations</h2>
+
+<p>A simple implementation of <code>PublishingService</code> (which must be configured as a domain service) is available; it simply writes to stderr.</p>
+
+<p>The implementation is as follows:</p>
+
+<pre><code>public interface PublishingService {
+...
+ public static class Stderr implements PublishingService {
+ private EventSerializer eventSerializer = new EventSerializer.Simple();
+ @Programmatic
+ @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;
+ }
+ }
+ ...
+}
+</code></pre>
+
+<p>As can be seen, the above implementation in turn uses a default implementation of <code>EventSerializer</code>, which simply concatenates the metadata and payload together into a single string:</p>
+
+<pre><code>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() + ":" +
+ payloads:\n" + payload.toString();
+ }
+ }
+ ...
+}
+</code></pre>
+
+<p>The default <code>PublishingService</code> (or indeed any implementation) can be configured to run with a different <code>EventSerializer</code> by configuring the serializer implementation in the <code>isis.properties</code> file. </p>
+
+<h4>Configuration</h4>
+
+<p>To configure the above, add the following to <code>isis.properties</code>:</p>
+
+<pre><code>isis.services=...,\
+ org.apache.isis.applib.services.publish.PublishingService$StdErr,\
+ ...
+</code></pre>
+
+<h2>Alternative Implementations</h2>
+
+<p>An alternative implementation of the <code>PublishingService</code> is provided by the <a href="../../components/objectstores/jdo/services/publishing-service-jdo.html">JDO Objectstore</a>. This implementation persists the events to a table.</p>
+
+<p>An alternative implementation of the <code>EventSerializer</code> is provided by the <a href="../../components/viewers/restfulobjects/event-serializer-rospec.html">Restful Objects viewer</a>. This implementation serializes the payload using the conventions of the <a href="http://restfulobjects.org">Restful Objects spec</a>.</p>
+
+<h4>Related Services</h4>
+
+<p>Dan Haywood's <a href="https://github.com/danhaywood/camel-isis-pubsubjdo">camel-isis-pubsubjdo</a> project up on github shows how to poll and process the persisted <code>PublishedEvent</code> table using <a href="http://camel.apache.org">Apache Camel</a>.</p>
-<h3>Class Diagram</h3>
+<h2>Class Diagram</h2>
<p>The following class diagram shows how the above components fit together:</p>