incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1177860 [1/2] - in /incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer: representations/ resources/ resources/capabilities/ resources/domainobjects/ resources/domaintypes/ resources/home...
Date Fri, 30 Sep 2011 22:19:29 GMT
Author: danhaywood
Date: Fri Sep 30 22:19:28 2011
New Revision: 1177860

URL: http://svn.apache.org/viewvc?rev=1177860&view=rev
Log:
ISIS-109: now using RendererFactoryRegistry as a lookup for renderer's based upon RepresentationType (ie eat own dogfood for using conneg to determine the provided representation

Added:
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactory.java
      - copied, changed from r1177533, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactory.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactoryRegistry.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryRegistry.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRenderer.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererAbstract.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderAbstract.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererFactoryAbstract.java
      - copied, changed from r1177533, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryAbstract.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesReprRenderer.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprRenderer.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceAbstract.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ListReprRenderer.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectListReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprRenderer.java
      - copied, changed from r1176973, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndAction.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndCollection.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndMember.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectAndProperty.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprRenderer.java
      - copied, changed from r1176973, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprRenderer.java
      - copied, changed from r1176973, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarValueReprRenderer.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageReprRenderer.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprRenderer.java
      - copied, changed from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprBuilder.java
Removed:
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderAbstract.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactory.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryAbstract.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryRegistry.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectListReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprBuilderFactory.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceAbstract.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectActionReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectCollectionReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ObjectPropertyReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/ScalarReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserReprBuilderFactory.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceHelper.java
Modified:
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilderAbstract.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceHelper.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/MemberType.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/DomainTypeReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/DomainTypeResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypeActionReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypeCollectionReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domaintypes/TypePropertyReprBuilder.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/home/HomePageResourceServerside.java
    incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/user/UserResourceServerside.java

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkReprBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkReprBuilder.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/LinkReprBuilder.java Fri Sep 30 22:19:28 2011
@@ -55,7 +55,7 @@ public class LinkReprBuilder extends Rep
         return this;
     }
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
         representation.mapPut("rel", rel);
         representation.mapPut("href", resourceContext.urlFor(href));
         representation.mapPut("method", method);

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactory.java (from r1177533, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactory.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactory.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactory.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactory.java&r1=1177533&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactory.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactory.java Fri Sep 30 22:19:28 2011
@@ -1,12 +1,13 @@
 package org.apache.isis.viewer.json.viewer.representations;
 
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
 
-public interface TypedReprBuilderFactory {
+public interface RendererFactory {
 
     RepresentationType getRepresentationType();
 
-    TypedReprBuilder<?, ?> newBuilder(ResourceContext resourceContext);
+    ReprRenderer<?, ?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation);
     
 }
\ No newline at end of file

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactoryRegistry.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryRegistry.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactoryRegistry.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactoryRegistry.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryRegistry.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryRegistry.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/RendererFactoryRegistry.java Fri Sep 30 22:19:28 2011
@@ -23,34 +23,51 @@ import java.util.Map;
 import javax.ws.rs.core.MediaType;
 
 import org.apache.isis.viewer.json.applib.RepresentationType;
-import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainObjectReprBuilderFactory;
-import org.apache.isis.viewer.json.viewer.resources.user.UserReprBuilderFactory;
+import org.apache.isis.viewer.json.viewer.resources.capabilities.CapabilitiesReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainObjectReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.ListReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.ObjectActionReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.ObjectCollectionReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.ObjectPropertyReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.ScalarValueReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.home.HomePageReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.user.UserReprRenderer;
 
 import com.google.common.collect.Maps;
 
-public class TypedReprBuilderFactoryRegistry {
+public class RendererFactoryRegistry {
 
-    private final Map<MediaType, TypedReprBuilderFactory> factoryByReprType = Maps.newHashMap();
+    // TODO: get rid of this horrible singleton
+    public final static RendererFactoryRegistry instance = new RendererFactoryRegistry();
+
+    private final Map<MediaType, RendererFactory> factoryByReprType = Maps.newHashMap();
     
-    public TypedReprBuilderFactoryRegistry() {
+    RendererFactoryRegistry() {
         registerDefaults();
     }
     
     private void registerDefaults() {
-        register(new DomainObjectReprBuilderFactory());
-        register(new UserReprBuilderFactory());
+        register(new HomePageReprRenderer.Factory());
+        register(new UserReprRenderer.Factory());
+        register(new CapabilitiesReprRenderer.Factory());
+        register(new DomainObjectReprRenderer.Factory());
+        register(new ObjectPropertyReprRenderer.Factory());
+        register(new ObjectCollectionReprRenderer.Factory());
+        register(new ObjectActionReprRenderer.Factory());
+        register(new ListReprRenderer.Factory());
+        register(new ScalarValueReprRenderer.Factory());
     }
 
-    public void register(TypedReprBuilderFactory factory) {
+    public void register(RendererFactory factory) {
         final RepresentationType representationType = factory.getRepresentationType();
         factoryByReprType.put(representationType.getMediaType(), factory);
     }
     
-    public TypedReprBuilderFactory find(MediaType mediaType) {
+    public RendererFactory find(MediaType mediaType) {
         return factoryByReprType.get(mediaType);
     }
 
-    public TypedReprBuilderFactory find(RepresentationType representationType) {
+    public RendererFactory find(RepresentationType representationType) {
         return find(representationType.getMediaType());
     }
 

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilder.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilder.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilder.java Fri Sep 30 22:19:28 2011
@@ -20,6 +20,6 @@ import org.apache.isis.viewer.json.appli
 
 public interface ReprBuilder {
 
-    public JsonRepresentation build();
+    public JsonRepresentation render();
 
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilderAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilderAbstract.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilderAbstract.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprBuilderAbstract.java Fri Sep 30 22:19:28 2011
@@ -45,7 +45,7 @@ public abstract class ReprBuilderAbstrac
 
     public T withSelf(String href) {
         if(href != null) {
-            representation.mapPut("self", LinkReprBuilder.newBuilder(resourceContext, "self", href).build());
+            representation.mapPut("self", LinkReprBuilder.newBuilder(resourceContext, "self", href).render());
         }
         return cast(this);
     }
@@ -79,7 +79,7 @@ public abstract class ReprBuilderAbstrac
         return (T) builder;
     }
 
-    public abstract JsonRepresentation build();
+    public abstract JsonRepresentation render();
     
     protected OidStringifier getOidStringifier() {
         return getOidGenerator().getOidStringifier();

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRenderer.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilder.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRenderer.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilder.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -1,8 +1,12 @@
 package org.apache.isis.viewer.json.viewer.representations;
 
+import org.apache.isis.viewer.json.applib.RepresentationType;
 
-public interface TypedReprBuilder<R extends TypedReprBuilder<R, T>, T> extends ReprBuilder {
 
+public interface ReprRenderer<R extends ReprRenderer<R, T>, T> extends ReprBuilder {
+
+    RepresentationType getRepresentationType();
+    
     R with(T t);
 
 }

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererAbstract.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderAbstract.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererAbstract.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererAbstract.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderAbstract.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderAbstract.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererAbstract.java Fri Sep 30 22:19:28 2011
@@ -1,12 +1,30 @@
 package org.apache.isis.viewer.json.viewer.representations;
 
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
 
-public abstract class TypedReprBuilderAbstract<R extends TypedReprBuilderAbstract<R, T>, T> extends ReprBuilderAbstract<R>  implements TypedReprBuilder<R, T> {
+public abstract class ReprRendererAbstract<R extends ReprRendererAbstract<R, T>, T> extends ReprBuilderAbstract<R>  implements ReprRenderer<R, T> {
 
-    public TypedReprBuilderAbstract(ResourceContext resourceContext) {
-        super(resourceContext);
+    private final RepresentationType representationType;
+    
+    protected boolean includesSelf;
+
+    public ReprRendererAbstract(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representation);
+        this.representationType = representationType;
     }
     
+    @SuppressWarnings("unchecked")
+    public R includesSelf() {
+        this.includesSelf = true;
+        return (R) this;
+    }
 
+    @Override
+    public RepresentationType getRepresentationType() {
+        return representationType;
+    }
+
+    
 }

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererFactoryAbstract.java (from r1177533, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryAbstract.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererFactoryAbstract.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererFactoryAbstract.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryAbstract.java&r1=1177533&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/TypedReprBuilderFactoryAbstract.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/representations/ReprRendererFactoryAbstract.java Fri Sep 30 22:19:28 2011
@@ -1,13 +1,12 @@
 package org.apache.isis.viewer.json.viewer.representations;
 
 import org.apache.isis.viewer.json.applib.RepresentationType;
-import org.apache.isis.viewer.json.viewer.ResourceContext;
 
-public abstract class TypedReprBuilderFactoryAbstract implements TypedReprBuilderFactory {
+public abstract class ReprRendererFactoryAbstract implements RendererFactory {
 
     private final RepresentationType representationType;
 
-    public TypedReprBuilderFactoryAbstract(RepresentationType representationType) {
+    public ReprRendererFactoryAbstract(RepresentationType representationType) {
         this.representationType = representationType;
     }
     

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/ResourceAbstract.java Fri Sep 30 22:19:28 2011
@@ -55,8 +55,9 @@ import org.apache.isis.viewer.json.viewe
 import org.apache.isis.viewer.json.viewer.ResourceContext;
 import org.apache.isis.viewer.json.viewer.representations.ReprBuilderAbstract;
 import org.apache.isis.viewer.json.viewer.representations.ReprBuilder;
-import org.apache.isis.viewer.json.viewer.representations.TypedReprBuilderFactoryRegistry;
-import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainObjectReprBuilder;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainObjectReprRenderer;
 import org.apache.isis.viewer.json.viewer.util.OidUtils;
 import org.apache.isis.viewer.json.viewer.util.UrlDecoderUtils;
 import org.codehaus.jackson.JsonGenerationException;
@@ -96,8 +97,7 @@ public abstract class ResourceAbstract {
 	public final static ActionType[] ACTION_TYPES = { ActionType.USER, ActionType.DEBUG, ActionType.EXPLORATION };
 
 	// TODO: should inject this instead...
-	protected final static TypedReprBuilderFactoryRegistry builderFactoryRegistry = 
-	        new TypedReprBuilderFactoryRegistry();
+	protected final static RendererFactoryRegistry rendererFactoryRegistry = RendererFactoryRegistry.instance;
 
     @Context
     HttpHeaders httpHeaders;
@@ -135,7 +135,7 @@ public abstract class ResourceAbstract {
     // //////////////////////////////////////////////////////////////
 
     protected String jsonFor(ReprBuilderAbstract<?> builder) {
-        JsonRepresentation representation = builder.build();
+        JsonRepresentation representation = builder.render();
         return jsonFor(representation);
     }
 
@@ -168,8 +168,8 @@ public abstract class ResourceAbstract {
 		final ResourceContext representationContext = getResourceContext();
         
         return Functions.compose(
-            DomainObjectReprBuilder.selfOf(), 
-            DomainObjectReprBuilder.fromAdapter(representationContext));
+            DomainObjectReprRenderer.selfOf(), 
+            DomainObjectReprRenderer.fromAdapter(representationContext));
 	}
 
 
@@ -216,7 +216,7 @@ public abstract class ResourceAbstract {
     // Responses
     // //////////////////////////////////////////////////////////////
 
-    private static ResponseBuilder responseOf(HttpStatusCode httpStatusCode) {
+    public static ResponseBuilder responseOf(HttpStatusCode httpStatusCode) {
         return Response.status(httpStatusCode.getJaxrsStatusType()).type(MediaType.APPLICATION_JSON_TYPE);
     }
 
@@ -236,9 +236,13 @@ public abstract class ResourceAbstract {
     }
 
     public static ResponseBuilder responseOfOk(RepresentationType representationType, Caching caching, ReprBuilder representationBuilder) {
-        return responseOfOk(representationType, caching, representationBuilder.build());
+        return responseOfOk(representationType, caching, representationBuilder.render());
     }
 
+    public static ResponseBuilder responseOfOk(Caching caching, ReprRenderer<?,?> renderer) {
+        RepresentationType representationType = renderer.getRepresentationType();
+        return responseOfOk(representationType, caching, renderer.render());
+    }
 
 
     // //////////////////////////////////////////////////////////////

Added: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesReprRenderer.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesReprRenderer.java?rev=1177860&view=auto
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesReprRenderer.java (added)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -0,0 +1,60 @@
+package org.apache.isis.viewer.json.viewer.resources.capabilities;
+
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
+import org.apache.isis.viewer.json.viewer.ResourceContext;
+import org.apache.isis.viewer.json.viewer.representations.LinkReprBuilder;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererAbstract;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
+
+public class CapabilitiesReprRenderer extends ReprRendererAbstract<CapabilitiesReprRenderer, Void> {
+
+    public static class Factory extends ReprRendererFactoryAbstract {
+        public Factory() {
+            super(RepresentationType.CAPABILITIES);
+        }
+
+        @Override
+        public ReprRenderer<?, ?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new CapabilitiesReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
+    }
+    
+    private CapabilitiesReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
+        includesSelf();
+    }
+
+    @Override
+    public CapabilitiesReprRenderer with(Void t) {
+        return this;
+    }
+
+    @Override
+    public JsonRepresentation render() {
+
+        if(includesSelf) {
+            withSelf("capabilities/");
+        }
+
+        JsonRepresentation capabilities = JsonRepresentation.newMap();
+
+        capabilities.mapPut("concurrencyChecking", "no");
+        capabilities.mapPut("transientObjects", "no");
+        capabilities.mapPut("deleteObjects", "no");
+        capabilities.mapPut("simpleArguments", "no");
+        capabilities.mapPut("partialArguments", "no");
+        capabilities.mapPut("followLinks", "no");
+        capabilities.mapPut("validateOnly", "no");
+        capabilities.mapPut("pagination", "no");
+        capabilities.mapPut("sorting", "no");
+        capabilities.mapPut("domainModel", "rich");
+
+        representation.mapPut("capabilities", capabilities);
+        representation.mapPut("links", JsonRepresentation.newArray());
+        representation.mapPut("extensions", JsonRepresentation.newMap());
+
+        return representation;
+    }
+}
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesResourceServerside.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesResourceServerside.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesResourceServerside.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/capabilities/CapabilitiesResourceServerside.java Fri Sep 30 22:19:28 2011
@@ -32,7 +32,9 @@ import org.apache.isis.viewer.json.appli
 import org.apache.isis.viewer.json.applib.capabilities.CapabilitiesResource;
 import org.apache.isis.viewer.json.viewer.JsonApplicationException;
 import org.apache.isis.viewer.json.viewer.representations.LinkReprBuilder;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
 import org.apache.isis.viewer.json.viewer.resources.ResourceAbstract;
+import org.apache.isis.viewer.json.viewer.resources.home.HomePageReprRenderer;
 
 /**
  * Implementation note: it seems to be necessary to annotate the implementation with {@link Path} rather than the
@@ -48,27 +50,12 @@ public class CapabilitiesResourceServers
         init();
         fakeRuntimeExceptionIfXFail();
 
-        JsonRepresentation representation = JsonRepresentation.newMap();
-        representation.mapPut("self", LinkReprBuilder.newBuilder(getResourceContext(), "self", "capabilities/").build());
+        final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.CAPABILITIES);
+        final CapabilitiesReprRenderer renderer = 
+                (CapabilitiesReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+        renderer.includesSelf();
         
-        JsonRepresentation capabilities = JsonRepresentation.newMap();
-        representation.mapPut("capabilities", capabilities);
-
-        capabilities.mapPut("concurrencyChecking", "no");
-        capabilities.mapPut("transientObjects", "no");
-        capabilities.mapPut("deleteObjects", "no");
-        capabilities.mapPut("simpleArguments", "no");
-        capabilities.mapPut("partialArguments", "no");
-        capabilities.mapPut("followLinks", "no");
-        capabilities.mapPut("validateOnly", "no");
-        capabilities.mapPut("pagination", "no");
-        capabilities.mapPut("sorting", "no");
-        capabilities.mapPut("domainModel", "rich");
-
-        representation.mapPut("links", JsonRepresentation.newArray());
-        representation.mapPut("extensions", JsonRepresentation.newMap());
-        
-        return responseOfOk(RepresentationType.CAPABILITIES, Caching.ONE_DAY, representation).build();
+        return responseOfOk(Caching.ONE_DAY, renderer).build();
     }
 
     private void fakeRuntimeExceptionIfXFail() {

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprBuilder.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprBuilder.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/AbstractObjectMemberReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -22,32 +22,43 @@ import org.apache.isis.core.metamodel.fa
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.ReprBuilderAbstract;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererAbstract;
 
-public abstract class AbstractObjectMemberReprBuilder<R extends ReprBuilderAbstract<R>, T extends ObjectMember> extends ReprBuilderAbstract<R> {
+public abstract class AbstractObjectMemberReprRenderer<R extends ReprRendererAbstract<R, ObjectAndMember<T>>, T extends ObjectMember> 
+        extends ReprRendererAbstract<R, ObjectAndMember<T>> {
 
     protected ObjectAdapterLinkToBuilder linkToBuilder;
     
-    protected final ObjectAdapter objectAdapter;
-    protected final MemberType memberType;
-    protected final T objectMember;
-
-    public AbstractObjectMemberReprBuilder(ResourceContext resourceContext, ObjectAdapter objectAdapter, MemberType memberType, T objectMember) {
-        super(resourceContext);
-        this.objectAdapter = objectAdapter;
-        this.memberType = memberType;
-        this.objectMember = objectMember;
+    protected ObjectAdapter objectAdapter;
+    protected MemberType memberType;
+    protected T objectMember;
+
+
+    public AbstractObjectMemberReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
+    }
+    
+    @Override
+    public R with(ObjectAndMember<T> objectAndMember) {
+        this.objectAdapter = objectAndMember.getObjectAdapter();
+        this.objectMember = objectAndMember.getMember();
+        this.memberType = MemberType.determineFrom(objectMember);
         usingLinkToBuilder(new DomainObjectLinkToBuilder());
+        return cast(this);
     }
 
+    /**
+     * Must be called after {@link #with(ObjectAndMember)} (which provides the {@link #objectAdapter}).
+     */
     public R usingLinkToBuilder(ObjectAdapterLinkToBuilder linkToBuilder) {
         this.linkToBuilder = linkToBuilder.usingResourceContext(resourceContext).with(objectAdapter);
         return cast(this);
     }
 
     public R withSelf() {
-        representation.mapPut("self", linkToBuilder.linkToMember("self", memberType, objectMember).build());
+        representation.mapPut("self", linkToBuilder.linkToMember("self", memberType, objectMember).render());
         return cast(this);
     }
 
@@ -83,7 +94,7 @@ public abstract class AbstractObjectMemb
 
     public R withDetailsLink() {
         representation.mapPut(memberType.getDetailsRel(), 
-                linkToBuilder.linkToMember(memberType.getDetailsRel(), memberType, objectMember).build());
+                linkToBuilder.linkToMember(memberType.getDetailsRel(), memberType, objectMember).render());
         return cast(this);
     }
 

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprRenderer.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprBuilder.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprRenderer.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprRenderer.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprBuilder.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprBuilder.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectReprRenderer.java Fri Sep 30 22:19:28 2011
@@ -31,19 +31,32 @@ import org.apache.isis.core.metamodel.sp
 import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
 import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
 import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
 import org.apache.isis.viewer.json.viewer.representations.LinkReprBuilder;
-import org.apache.isis.viewer.json.viewer.representations.TypedReprBuilderAbstract;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererAbstract;
+import org.apache.isis.viewer.json.viewer.representations.ReprRendererFactoryAbstract;
 import org.apache.isis.viewer.json.viewer.util.OidUtils;
 
 import com.google.common.base.Function;
 
-public class DomainObjectReprBuilder extends TypedReprBuilderAbstract<DomainObjectReprBuilder, ObjectAdapter>{
+public class DomainObjectReprRenderer extends ReprRendererAbstract<DomainObjectReprRenderer, ObjectAdapter>{
 
-    public static DomainObjectReprBuilder newBuilder(ResourceContext resourceContext) {
-        return new DomainObjectReprBuilder(resourceContext);
-    }
+    public static class Factory extends ReprRendererFactoryAbstract {
+
+        public Factory() {
+            super(RepresentationType.DOMAIN_OBJECT);
+        }
 
+        @Override
+        public ReprRenderer<?,?> newRenderer(ResourceContext resourceContext, JsonRepresentation representation) {
+            return new DomainObjectReprRenderer(resourceContext, getRepresentationType(), representation);
+        }
+    }
+    
     public static LinkReprBuilder newLinkToBuilder(ResourceContext resourceContext, String rel, ObjectAdapter elementAdapter) {
         String oidStr = resourceContext.getOidStringifier().enString(elementAdapter.getOid());
         String url = "objects/" + oidStr;
@@ -51,10 +64,9 @@ public class DomainObjectReprBuilder ext
     }
 
     private ObjectAdapterLinkToBuilder linkToBuilder;
-    private boolean includeSelf;
 
-    public DomainObjectReprBuilder(ResourceContext resourceContext) {
-        super(resourceContext);
+    private DomainObjectReprRenderer(ResourceContext resourceContext, RepresentationType representationType, JsonRepresentation representation) {
+        super(resourceContext, representationType, representation);
         usingLinkToBuilder(new DomainObjectLinkToBuilder());
     }
 
@@ -62,19 +74,14 @@ public class DomainObjectReprBuilder ext
      * Override the default {@link ObjectAdapterLinkToBuilder} (that is used for generating links in
      * {@link #linkTo(ObjectAdapter)}).
      */
-    public DomainObjectReprBuilder usingLinkToBuilder(ObjectAdapterLinkToBuilder objectAdapterLinkToBuilder) {
+    public DomainObjectReprRenderer usingLinkToBuilder(ObjectAdapterLinkToBuilder objectAdapterLinkToBuilder) {
         this.linkToBuilder = objectAdapterLinkToBuilder.usingResourceContext(resourceContext);
         return this;
     }
 
-    public DomainObjectReprBuilder withSelf() {
-        this.includeSelf = true;
-        return this;
-    }
-
-    public DomainObjectReprBuilder with(ObjectAdapter objectAdapter) {
-        if(includeSelf) {
-            JsonRepresentation self = linkToBuilder.with(objectAdapter).linkToAdapter().build();
+    public DomainObjectReprRenderer with(ObjectAdapter objectAdapter) {
+        if(includesSelf) {
+            JsonRepresentation self = linkToBuilder.with(objectAdapter).linkToAdapter().render();
             representation.mapPut("self", self);
         }
 
@@ -85,7 +92,7 @@ public class DomainObjectReprBuilder ext
         return this;
     }
 
-    private DomainObjectReprBuilder withMembers(ObjectAdapter objectAdapter) {
+    private DomainObjectReprRenderer withMembers(ObjectAdapter objectAdapter) {
         JsonRepresentation members = JsonRepresentation.newArray();
         List<ObjectAssociation> associations = objectAdapter.getSpecification().getAssociations();
         addAssociations(objectAdapter, members, associations);
@@ -104,21 +111,29 @@ public class DomainObjectReprBuilder ext
             } 
             if(assoc instanceof OneToOneAssociation) {
                 OneToOneAssociation property = (OneToOneAssociation)assoc;
-                JsonRepresentation propertyRep = 
-                        ObjectPropertyReprBuilder.newBuilder(resourceContext, objectAdapter, property)
+                
+                RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_PROPERTY);
+                final ObjectPropertyReprRenderer renderer = 
+                        (ObjectPropertyReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+                
+                renderer.with(new ObjectAndProperty(objectAdapter, property))
                         .usingLinkToBuilder(linkToBuilder)
-                        .withDetailsLink()
-                        .build();
-                members.arrayAdd(propertyRep);
+                        .withDetailsLink();
+                
+                members.arrayAdd(renderer.render());
             }
             if(assoc instanceof OneToManyAssociation) {
                 OneToManyAssociation collection = (OneToManyAssociation) assoc;
-                JsonRepresentation collectionRep = 
-                        ObjectCollectionReprBuilder.newBuilder(resourceContext, objectAdapter, collection)
-                        .usingLinkToBuilder(linkToBuilder)
-                        .withDetailsLink()
-                        .build();
-                members.arrayAdd(collectionRep);
+
+                RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_COLLECTION);
+                final ObjectCollectionReprRenderer renderer = 
+                        (ObjectCollectionReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+
+                renderer.with(new ObjectAndCollection(objectAdapter, collection))
+                    .usingLinkToBuilder(linkToBuilder)
+                    .withDetailsLink();
+                
+                members.arrayAdd(renderer.render());
             }
         }
     }
@@ -134,18 +149,23 @@ public class DomainObjectReprBuilder ext
         		ObjectActionSet objectActionSet = (ObjectActionSet) action;
         		List<ObjectAction> subactions = objectActionSet.getActions();
         		addActions(objectAdapter, subactions, members);
+
         	} else {
-                JsonRepresentation actionRep = 
-                        ObjectActionReprBuilder.newBuilder(resourceContext, objectAdapter, action)
+        	    
+                RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_ACTION);
+                final ObjectActionReprRenderer renderer = 
+                        (ObjectActionReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+                
+                renderer.with(new ObjectAndAction(objectAdapter, action))
                         .usingLinkToBuilder(linkToBuilder)
-                        .withDetailsLink()
-                        .build();
-                members.arrayAdd(actionRep);
+                        .withDetailsLink();
+
+                members.arrayAdd(renderer.render());
         	}
         }
 	}
 
-    public JsonRepresentation build() {
+    public JsonRepresentation render() {
         withLinks();
         withExtensions();
         return representation;
@@ -157,10 +177,13 @@ public class DomainObjectReprBuilder ext
     /////////////////////////////////////////////////////////////////////
 
     public static Function<ObjectAdapter, JsonRepresentation> fromAdapter(final ResourceContext resourceContext) {
+        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.DOMAIN_OBJECT);
         return new Function<ObjectAdapter, JsonRepresentation>() {
             @Override
             public JsonRepresentation apply(ObjectAdapter adapter) {
-                return newBuilder(resourceContext).with(adapter).build();
+                DomainObjectReprRenderer renderer = 
+                        (DomainObjectReprRenderer) factory.newRenderer(resourceContext, JsonRepresentation.newMap());
+                return renderer.with(adapter).render();
             }
         };
     }
@@ -187,10 +210,8 @@ public class DomainObjectReprBuilder ext
 		}
 		TitleFacet titleFacet = objectSpec.getFacet(TitleFacet.class);
 		String title = titleFacet.title(objectAdapter, resourceContext.getLocalization());
-		return DomainObjectReprBuilder.newLinkToBuilder(resourceContext, "object", objectAdapter)
-		            .withTitle(title).build();
+		return DomainObjectReprRenderer.newLinkToBuilder(resourceContext, "object", objectAdapter)
+		            .withTitle(title).render();
 	}
 
-
-
 }
\ No newline at end of file

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainObjectResourceServerside.java Fri Sep 30 22:19:28 2011
@@ -39,18 +39,20 @@ import org.apache.isis.core.metamodel.co
 import org.apache.isis.core.metamodel.spec.ObjectSpecification;
 import org.apache.isis.core.metamodel.spec.feature.OneToManyAssociation;
 import org.apache.isis.core.metamodel.spec.feature.OneToOneAssociation;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
 import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.applib.RestfulMediaType;
 import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
 import org.apache.isis.viewer.json.applib.domainobjects.DomainObjectResource;
 import org.apache.isis.viewer.json.viewer.JsonApplicationException;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.ReprBuilderAbstract;
-import org.apache.isis.viewer.json.viewer.representations.TypedReprBuilder;
-import org.apache.isis.viewer.json.viewer.representations.TypedReprBuilderFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
+import org.apache.isis.viewer.json.viewer.resources.ResourceAbstract;
+import org.apache.isis.viewer.json.viewer.resources.domainobjects.DomainResourceHelper.Intent;
 
 @Path("/objects")
-public class DomainObjectResourceServerside extends DomainResourceAbstract implements
+public class DomainObjectResourceServerside extends ResourceAbstract implements
         DomainObjectResource {
 
     private static final DateFormat ETAG_FORMAT = 
@@ -60,8 +62,6 @@ public class DomainObjectResourceServers
     // domain object
     ////////////////////////////////////////////////////////////
     
-
-
     @GET
     @Path("/{oid}")
     @Produces({ MediaType.APPLICATION_JSON, RestfulMediaType.APPLICATION_JSON_DOMAIN_OBJECT, RestfulMediaType.APPLICATION_JSON_ERROR })
@@ -71,15 +71,15 @@ public class DomainObjectResourceServers
 
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
         
-        final TypedReprBuilderFactory reprBuilderBuilder = 
-                builderFactoryRegistry.find(RepresentationType.DOMAIN_OBJECT);
+        final RendererFactory rendererFactory = 
+                rendererFactoryRegistry.find(RepresentationType.DOMAIN_OBJECT);
         
-        final DomainObjectReprBuilder repBuilder = 
-                (DomainObjectReprBuilder) reprBuilderBuilder.newBuilder(getResourceContext());
-        repBuilder.with(objectAdapter);
+        final DomainObjectReprRenderer renderer = 
+                (DomainObjectReprRenderer) rendererFactory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+        renderer.with(objectAdapter);
         
         ResponseBuilder respBuilder = 
-                responseOfOk(RepresentationType.DOMAIN_OBJECT, Caching.NONE, repBuilder);
+                responseOfOk(RepresentationType.DOMAIN_OBJECT, Caching.NONE, renderer);
         
         Version version = objectAdapter.getVersion();
         if (version != null && version.getTime() != null) {
@@ -114,15 +114,20 @@ public class DomainObjectResourceServers
             @PathParam("propertyId") final String propertyId) {
         init();
         
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
+        final RendererFactory rendererFactory = 
+                rendererFactoryRegistry.find(RepresentationType.OBJECT_PROPERTY);
+        
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final OneToOneAssociation property = getPropertyThatIsVisibleAndUsable(
+        final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(
                 objectAdapter, propertyId, Intent.ACCESS);
-
-        ResourceContext resourceContext = getResourceContext();
-        final ObjectPropertyReprBuilder builder = ObjectPropertyReprBuilder.newBuilder(
-                resourceContext, objectAdapter, property);
         
-        return responseOfOk(RepresentationType.OBJECT_PROPERTY, Caching.NONE, builder).build();
+        final ObjectPropertyReprRenderer renderer = 
+                (ObjectPropertyReprRenderer) rendererFactory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+        renderer.with(new ObjectAndProperty(objectAdapter, property));
+
+        return responseOfOk(RepresentationType.OBJECT_PROPERTY, Caching.NONE, renderer).build();
     }
 
     @PUT
@@ -134,14 +139,16 @@ public class DomainObjectResourceServers
             final InputStream body) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+        
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final OneToOneAssociation property = getPropertyThatIsVisibleAndUsable(
+        final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(
                 objectAdapter, propertyId, Intent.MUTATE);
 
         ObjectSpecification propertySpec = property.getSpecification();
-        String bodyAsString = asStringUtf8(body);
+        String bodyAsString = DomainResourceHelper.asStringUtf8(body);
 
-        ObjectAdapter argAdapter = parseBodyAsMapWithSingleValue(propertySpec, bodyAsString);
+        ObjectAdapter argAdapter = helper.parseBodyAsMapWithSingleValue(propertySpec, bodyAsString);
 
         Consent consent = property.isAssociationValid(objectAdapter, argAdapter);
         if (consent.isVetoed()) {
@@ -164,8 +171,10 @@ public class DomainObjectResourceServers
             @PathParam("propertyId") final String propertyId) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final OneToOneAssociation property = getPropertyThatIsVisibleAndUsable(
+        final OneToOneAssociation property = helper.getPropertyThatIsVisibleAndUsable(
                 objectAdapter, propertyId, Intent.MUTATE);
 
         Consent consent = property.isAssociationValid(objectAdapter, null);
@@ -191,15 +200,20 @@ public class DomainObjectResourceServers
         @PathParam("oid") final String oidStr,
         @PathParam("collectionId") final String collectionId) {
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final OneToManyAssociation collection = getCollectionThatIsVisibleAndUsable(
+        final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(
                 objectAdapter, collectionId, Intent.ACCESS);
 
-        final ObjectCollectionReprBuilder builder = ObjectCollectionReprBuilder.newBuilder(
-                getResourceContext(), objectAdapter, collection);
+        RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_COLLECTION);
+        final ObjectCollectionReprRenderer renderer = 
+                (ObjectCollectionReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+
+        renderer.with(new ObjectAndCollection(objectAdapter, collection));
         
         return Response.status(HttpStatusCode.OK.getJaxrsStatusType())
-                .entity(jsonFor(builder))
+                .entity(jsonFor(renderer))
                 .type(MediaType.APPLICATION_JSON_TYPE)
                 .build();
     }
@@ -213,8 +227,10 @@ public class DomainObjectResourceServers
             final InputStream body) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final OneToManyAssociation collection = getCollectionThatIsVisibleAndUsable(
+        final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(
                 objectAdapter, collectionId, Intent.MUTATE);
 
         if (!collection.getCollectionSemantics().isSet()) {
@@ -224,8 +240,8 @@ public class DomainObjectResourceServers
         }
 
         ObjectSpecification collectionSpec = collection.getSpecification();
-        String bodyAsString = asStringUtf8(body);
-        ObjectAdapter argAdapter = parseBodyAsMapWithSingleValue(collectionSpec, bodyAsString);
+        String bodyAsString = DomainResourceHelper.asStringUtf8(body);
+        ObjectAdapter argAdapter = helper.parseBodyAsMapWithSingleValue(collectionSpec, bodyAsString);
 
         Consent consent = collection.isValidToAdd(objectAdapter, argAdapter);
         if (consent.isVetoed()) {
@@ -248,8 +264,10 @@ public class DomainObjectResourceServers
             final InputStream body) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final OneToManyAssociation collection = getCollectionThatIsVisibleAndUsable(
+        final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(
                 objectAdapter, collectionId, Intent.MUTATE);
 
         if (!collection.getCollectionSemantics().isListOrArray()) {
@@ -259,8 +277,8 @@ public class DomainObjectResourceServers
         }
 
         ObjectSpecification collectionSpec = collection.getSpecification();
-        String bodyAsString = asStringUtf8(body);
-        ObjectAdapter argAdapter = parseBodyAsMapWithSingleValue(collectionSpec, bodyAsString);
+        String bodyAsString = DomainResourceHelper.asStringUtf8(body);
+        ObjectAdapter argAdapter = helper.parseBodyAsMapWithSingleValue(collectionSpec, bodyAsString);
 
         Consent consent = collection.isValidToAdd(objectAdapter, argAdapter);
         if (consent.isVetoed()) {
@@ -282,13 +300,17 @@ public class DomainObjectResourceServers
         @PathParam("collectionId") final String collectionId,
         final InputStream body) {
 
+        init();
+        
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        final OneToManyAssociation collection = getCollectionThatIsVisibleAndUsable(
+        final OneToManyAssociation collection = helper.getCollectionThatIsVisibleAndUsable(
                 objectAdapter, collectionId, Intent.MUTATE);
 
         ObjectSpecification collectionSpec = collection.getSpecification();
-        String bodyAsString = asStringUtf8(body);
-        ObjectAdapter argAdapter = parseBodyAsMapWithSingleValue(collectionSpec, bodyAsString);
+        String bodyAsString = DomainResourceHelper.asStringUtf8(body);
+        ObjectAdapter argAdapter = helper.parseBodyAsMapWithSingleValue(collectionSpec, bodyAsString);
 
         Consent consent = collection.isValidToRemove(objectAdapter, argAdapter);
         if (consent.isVetoed()) {
@@ -314,8 +336,11 @@ public class DomainObjectResourceServers
             @PathParam("actionId") final String actionId) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        return actionPrompt(actionId, objectAdapter);
+        
+        return helper.actionPrompt(actionId, objectAdapter);
     }
 
 
@@ -333,9 +358,11 @@ public class DomainObjectResourceServers
             @QueryParam("args") final String arguments) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
 
-        return invokeActionQueryOnly(objectAdapter, actionId, arguments);
+        return helper.invokeActionQueryOnly(objectAdapter, actionId, arguments);
     }
 
     @PUT
@@ -347,8 +374,11 @@ public class DomainObjectResourceServers
             final InputStream arguments) {
         init();
 
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
+
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        return invokeActionIdempotent(objectAdapter, actionId, arguments);
+        
+        return helper.invokeActionIdempotent(objectAdapter, actionId, arguments);
     }
 
 
@@ -360,9 +390,12 @@ public class DomainObjectResourceServers
             @PathParam("actionId") final String actionId,
             final InputStream body) {
         init();
+        
+        final DomainResourceHelper helper = new DomainResourceHelper(getResourceContext());
 
         final ObjectAdapter objectAdapter = getObjectAdapter(oidStr);
-        return invokeAction(objectAdapter, actionId, body);
+        
+        return helper.invokeAction(objectAdapter, actionId, body);
     }
 
 

Copied: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java (from r1177294, incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceAbstract.java)
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java?p2=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java&p1=incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceAbstract.java&r1=1177294&r2=1177860&rev=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceAbstract.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainResourceHelper.java Fri Sep 30 22:19:28 2011
@@ -42,11 +42,15 @@ import org.apache.isis.viewer.json.appli
 import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.applib.RestfulResponse.HttpStatusCode;
 import org.apache.isis.viewer.json.applib.blocks.Link;
+import org.apache.isis.viewer.json.applib.util.JsonMapper;
 import org.apache.isis.viewer.json.viewer.JsonApplicationException;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.ReprBuilderAbstract;
 import org.apache.isis.viewer.json.viewer.representations.LinkReprBuilder;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
+import org.apache.isis.viewer.json.viewer.representations.ReprRenderer;
 import org.apache.isis.viewer.json.viewer.resources.ResourceAbstract;
+import org.apache.isis.viewer.json.viewer.resources.ResourceAbstract.Caching;
 import org.apache.isis.viewer.json.viewer.util.OidUtils;
 import org.apache.isis.viewer.json.viewer.util.UrlDecoderUtils;
 import org.apache.isis.viewer.json.viewer.util.UrlParserUtils;
@@ -57,44 +61,34 @@ import com.google.common.base.Charsets;
 import com.google.common.collect.Lists;
 import com.google.common.io.ByteStreams;
 
-public abstract class DomainResourceAbstract extends ResourceAbstract {
-
-    // //////////////////////////////////////////////////////////////
-    // object
-    // //////////////////////////////////////////////////////////////
-
-    protected Response object(final ObjectAdapter objectAdapter) {
-        ResourceContext resourceContext = getResourceContext();
-        final ReprBuilderAbstract<?> repBuilder =
-                DomainObjectReprBuilder.newBuilder(resourceContext)
-                        .with(objectAdapter);
+public class DomainResourceHelper {
+    
+    private final ResourceContext resourceContext;
 
-        ResponseBuilder respBuilder = 
-                responseOfOk(RepresentationType.DOMAIN_OBJECT, Caching.NONE, repBuilder);
+    // TODO: inject somehow instead
+    private final RendererFactoryRegistry rendererFactoryRegistry = RendererFactoryRegistry.instance;
 
-        Version version = objectAdapter.getVersion();
-        if (version != null && version.getTime() != null) {
-            respBuilder.tag(""+version.getTime());
-        }
-        return respBuilder.build();
+    public DomainResourceHelper(ResourceContext resourceContext) {
+        this.resourceContext = resourceContext;
     }
 
-
-    
     // //////////////////////////////////////////////////////////////
     // action Prompt
     // //////////////////////////////////////////////////////////////
 
-    protected Response actionPrompt(final String actionId, final ObjectAdapter serviceAdapter) {
+    Response actionPrompt(final String actionId, final ObjectAdapter serviceAdapter) {
         final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
                 serviceAdapter, actionId, Intent.ACCESS);
 
-        ObjectActionReprBuilder repBuilder = 
-                ObjectActionReprBuilder.newBuilder(getResourceContext(), serviceAdapter, action)
+        RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.OBJECT_ACTION);
+        final ObjectActionReprRenderer renderer = 
+                (ObjectActionReprRenderer) factory.newRenderer(resourceContext, JsonRepresentation.newMap());
+        
+        renderer.with(new ObjectAndAction(serviceAdapter, action))
                 .withSelf()
                 .withMutatorsIfEnabled();
-        
-        return responseOfOk(RepresentationType.OBJECT_ACTION, Caching.NONE, repBuilder)
+
+        return ResourceAbstract.responseOfOk(RepresentationType.OBJECT_ACTION, Caching.NONE, renderer.render())
                 .build();
     }
 
@@ -111,14 +105,14 @@ public abstract class DomainResourceAbst
         }
     }
 
-    protected Response invokeActionQueryOnly(
+    Response invokeActionQueryOnly(
             final ObjectAdapter objectAdapter, 
             final String actionId, 
             final String arguments) {
         final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
                 objectAdapter, actionId, Intent.ACCESS);
 
-        final ActionSemantics actionSemantics = ActionSemantics.determine(getResourceContext(), action);
+        final ActionSemantics actionSemantics = ActionSemantics.determine(resourceContext, action);
         if(!actionSemantics.isQueryOnly()) {
             throw JsonApplicationException.create(HttpStatusCode.METHOD_NOT_ALLOWED,
                     "Method not allowed; action '%s' is not query only", action.getId());
@@ -146,7 +140,7 @@ public abstract class DomainResourceAbst
     }
 
 
-    protected Response invokeActionIdempotent(
+    Response invokeActionIdempotent(
             final ObjectAdapter objectAdapter, 
             final String actionId, 
             final InputStream body) {
@@ -154,7 +148,7 @@ public abstract class DomainResourceAbst
         final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
                 objectAdapter, actionId, Intent.MUTATE);
 
-        final ActionSemantics actionSemantics = ActionSemantics.determine(getResourceContext(), action);
+        final ActionSemantics actionSemantics = ActionSemantics.determine(resourceContext, action);
         if(!actionSemantics.isIdempotent()) {
             throw JsonApplicationException.create(
                     HttpStatusCode.METHOD_NOT_ALLOWED,
@@ -170,7 +164,7 @@ public abstract class DomainResourceAbst
                 argumentAdapters, representationWithSelf);
     }
 
-    protected Response invokeAction(final ObjectAdapter objectAdapter, final String actionId, final InputStream body) {
+    Response invokeAction(final ObjectAdapter objectAdapter, final String actionId, final InputStream body) {
         final ObjectAction action = getObjectActionThatIsVisibleAndUsable(
                 objectAdapter, actionId, Intent.MUTATE);
         
@@ -184,11 +178,11 @@ public abstract class DomainResourceAbst
                 argumentAdapters, representationWithSelf);
     }
 
-    protected Response invokeActionUsingAdapters(
+    Response invokeActionUsingAdapters(
         final ObjectAdapter objectAdapter,
         final ObjectAction action,
         final List<ObjectAdapter> argAdapters, 
-        final JsonRepresentation representationWithSelf) {
+        final JsonRepresentation representation) {
         
         // validate
         List<ObjectActionParameter> parameters = action.getParameters();
@@ -215,27 +209,47 @@ public abstract class DomainResourceAbst
 
         // response
         if (returnedAdapter == null) {
-            return responseOfNoContent(objectAdapter.getVersion()).build();
+            return ResourceAbstract.responseOfNoContent(objectAdapter.getVersion()).build();
         }
 
         final CollectionFacet collectionFacet = returnedAdapter.getSpecification().getFacet(CollectionFacet.class);
         if (collectionFacet != null) {
             final Collection<ObjectAdapter> collectionAdapters = collectionFacet
                     .collection(returnedAdapter);
-            DomainObjectListReprBuilder repBuilder = DomainObjectListReprBuilder.newBuilder(getResourceContext(), representationWithSelf).withAdapters(collectionAdapters);
-            return responseOfOk(RepresentationType.LIST, Caching.NONE, repBuilder).build();
+
+            final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.LIST);
+            final ListReprRenderer renderer = (ListReprRenderer) factory.newRenderer(resourceContext, representation);
+            renderer.with(collectionAdapters);
+            
+            return ResourceAbstract.responseOfOk(Caching.NONE, renderer).build();
         }
 
+        
         final EncodableFacet encodableFacet = returnedAdapter.getSpecification().getFacet(EncodableFacet.class);
         if(encodableFacet != null) {
-            ScalarReprBuilder repBuilder = ScalarReprBuilder.newBuilder(getResourceContext(), representationWithSelf).withAdapter(objectAdapter);
-            return responseOfOk(RepresentationType.SCALAR_VALUE, Caching.NONE, repBuilder).build();
+            
+            final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.SCALAR_VALUE);
+
+            ScalarValueReprRenderer renderer = (ScalarValueReprRenderer) factory.newRenderer(resourceContext, representation);
+            renderer.with(objectAdapter);
+            return ResourceAbstract.responseOfOk(RepresentationType.SCALAR_VALUE, Caching.NONE, renderer).build();
         }
 
-        return object(returnedAdapter);
+        final RendererFactory factory = rendererFactoryRegistry.find(RepresentationType.DOMAIN_OBJECT);
+        final DomainObjectReprRenderer renderer = (DomainObjectReprRenderer) factory.newRenderer(resourceContext, representation);
+        renderer.with(returnedAdapter);
+        
+        ResponseBuilder respBuilder = ResourceAbstract.responseOfOk(Caching.NONE, renderer);
+        
+        Version version = returnedAdapter.getVersion();
+        if (version != null && version.getTime() != null) {
+            respBuilder.tag(""+version.getTime());
+        }
+        return respBuilder.build();
     }
 
 
+
     private JsonRepresentation representationWithSelfFor(final ObjectAdapter objectAdapter, final ObjectAction action, final String queryArgs) {
         JsonRepresentation representationWithSelf = representationWithSelfFor(objectAdapter, action);
         final String href = representationWithSelf.getString("self.href");
@@ -252,8 +266,8 @@ public abstract class DomainResourceAbst
     
     private JsonRepresentation representationWithSelfFor(final ObjectAdapter objectAdapter, final ObjectAction action) {
         JsonRepresentation representation = JsonRepresentation.newMap();
-        String oid = getOidStr(objectAdapter);
-        final JsonRepresentation repBuilder = LinkReprBuilder.newBuilder(getResourceContext(), "self", "objects/%s/actions/%s/invoke", oid, action.getId()).build();
+        String oid = OidUtils.getOidStr(resourceContext, objectAdapter);
+        final JsonRepresentation repBuilder = LinkReprBuilder.newBuilder(resourceContext, "self", "objects/%s/actions/%s/invoke", oid, action.getId()).render();
         representation.mapPut("self", repBuilder);
         return representation;
     }
@@ -338,8 +352,8 @@ public abstract class DomainResourceAbst
             final String urlEncodedJson) throws JsonParseException, JsonMappingException, IOException {
 
         final String json = UrlDecoderUtils.urlDecode(urlEncodedJson);
-        JsonRepresentation representation = jsonMapper.read(json);
-        return objectAdapterFor(getResourceContext(), spec, representation);
+        JsonRepresentation representation = JsonMapper.instance().read(json);
+        return objectAdapterFor(resourceContext, spec, representation);
     }
 
     private static class ExpectedStringRepresentingValueException extends IllegalArgumentException {
@@ -408,7 +422,7 @@ public abstract class DomainResourceAbst
         T objectMember, final MemberType memberType,
         final Intent intent) {
         String memberId = objectMember.getId();
-        AuthenticationSession authenticationSession = getResourceContext().getAuthenticationSession();
+        AuthenticationSession authenticationSession = resourceContext.getAuthenticationSession();
         if (objectMember.isVisible(authenticationSession, objectAdapter).isVetoed()) {
             throwNotFoundException(memberId, memberType);
         }
@@ -447,7 +461,7 @@ public abstract class DomainResourceAbst
      * @param bodyAsString - as per {@link #asStringUtf8(InputStream)}
      * @return
      */
-    protected ObjectAdapter parseBodyAsMapWithSingleValue(
+    ObjectAdapter parseBodyAsMapWithSingleValue(
             final ObjectSpecification objectSpec, 
             final String bodyAsString) {
         JsonRepresentation arguments = readBodyAsMap(bodyAsString);
@@ -460,7 +474,7 @@ public abstract class DomainResourceAbst
                     resourceFor(objectSpec));
         }
 
-        ObjectAdapter proposedValueAdapter = objectAdapterFor(getResourceContext(), objectSpec, arguments);
+        ObjectAdapter proposedValueAdapter = objectAdapterFor(resourceContext, objectSpec, arguments);
         return proposedValueAdapter;
     }
 
@@ -491,7 +505,7 @@ public abstract class DomainResourceAbst
             final JsonRepresentation arg = argList.get(i);
             final ObjectSpecification paramSpec = parameters.get(i).getSpecification();
             try {
-                final ObjectAdapter objectAdapter = objectAdapterFor(getResourceContext(), paramSpec, arg);
+                final ObjectAdapter objectAdapter = objectAdapterFor(resourceContext, paramSpec, arg);
                 argAdapters.add(objectAdapter);
             } catch (ExpectedStringRepresentingValueException e) {
                 throw JsonApplicationException.create(
@@ -537,7 +551,7 @@ public abstract class DomainResourceAbst
 
     private JsonRepresentation readBodyAsMap(String bodyAsString) {
         try {
-            final JsonRepresentation jsonRepr = jsonMapper.read(bodyAsString);
+            final JsonRepresentation jsonRepr = JsonMapper.instance().read(bodyAsString);
             if(!jsonRepr.isMap()) {
                 throw JsonApplicationException.create(
                     HttpStatusCode.BAD_REQUEST,
@@ -559,7 +573,7 @@ public abstract class DomainResourceAbst
         }
     }
 
-    protected String asStringUtf8(final InputStream body) {
+    static String asStringUtf8(final InputStream body) {
         try {
             byte[] byteArray = ByteStreams.toByteArray(body);
             return new String(byteArray, Charsets.UTF_8);

Modified: incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceHelper.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceHelper.java?rev=1177860&r1=1177859&r2=1177860&view=diff
==============================================================================
--- incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceHelper.java (original)
+++ incubator/isis/trunk/framework/viewer/json/json-viewer/src/main/java/org/apache/isis/viewer/json/viewer/resources/domainobjects/DomainServiceResourceHelper.java Fri Sep 30 22:19:28 2011
@@ -21,8 +21,11 @@ package org.apache.isis.viewer.json.view
 import java.util.List;
 
 import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
+import org.apache.isis.viewer.json.applib.JsonRepresentation;
+import org.apache.isis.viewer.json.applib.RepresentationType;
 import org.apache.isis.viewer.json.viewer.ResourceContext;
-import org.apache.isis.viewer.json.viewer.representations.ReprBuilder;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactory;
+import org.apache.isis.viewer.json.viewer.representations.RendererFactoryRegistry;
 import org.apache.isis.viewer.json.viewer.resources.AbstractResourceHelper;
 
 public class DomainServiceResourceHelper extends AbstractResourceHelper {
@@ -35,17 +38,18 @@ public class DomainServiceResourceHelper
         super(resourceContext, selfRef);
     }
 
-    public ReprBuilder services() {
+    public ListReprRenderer services() {
 
         final List<ObjectAdapter> serviceAdapters = getResourceContext().getPersistenceSession().getServices();
 
-        DomainObjectListReprBuilder builder = 
-                DomainObjectListReprBuilder.newBuilder(getResourceContext())
-                    .usingLinkToBuilder(new DomainServiceLinkToBuilder())
-                    .withSelf("services")
-                    .withAdapters(serviceAdapters);
+        final RendererFactory factory = RendererFactoryRegistry.instance.find(RepresentationType.LIST);
         
-        return builder;
+        final ListReprRenderer renderer = (ListReprRenderer) factory.newRenderer(getResourceContext(), JsonRepresentation.newMap());
+        renderer.usingLinkToBuilder(new DomainServiceLinkToBuilder())
+                .withSelf("services")
+                .with(serviceAdapters);
+        
+        return renderer;
     }
 
 



Mime
View raw message