sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r931490 - in /sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl: ProcessingComponentConfigurationImpl.java ProcessorConfigurationImpl.java
Date Wed, 07 Apr 2010 10:17:06 GMT
Author: cziegeler
Date: Wed Apr  7 10:17:06 2010
New Revision: 931490

URL: http://svn.apache.org/viewvc?rev=931490&view=rev
Log:
Add web console plugin to display current rewriter configuration

Modified:
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java?rev=931490&r1=931489&r2=931490&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessingComponentConfigurationImpl.java
Wed Apr  7 10:17:06 2010
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.rewriter.impl;
 
+import java.io.PrintWriter;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -47,9 +48,9 @@ public class ProcessingComponentConfigur
      * @param type The type of the component.
      * @param config The configuration or null if no config is available.
      */
-    public ProcessingComponentConfigurationImpl(final String type, final Map<String, Object>
config) {
+    public ProcessingComponentConfigurationImpl(final String type, final ValueMap config)
{
         this.type = type;
-        this.configuration = (config == null ? EMPTY_CONFIG : new ValueMapDecorator(config));
+        this.configuration = (config == null ? EMPTY_CONFIG : config);
         final StringBuilder sb = new StringBuilder();
         sb.append("Config(type=");
         sb.append(this.type);
@@ -82,4 +83,15 @@ public class ProcessingComponentConfigur
         return this.descText;
     }
 
+    void printConfiguration(final PrintWriter pw) {
+        pw.print(this.type);
+        if ( this.configuration == null ) {
+            pw.println();
+        } else {
+            pw.print(" : ");
+            final Map<String, Object> map = new HashMap<String, Object>(this.configuration);
+            map.remove("jcr:primaryType");
+            pw.println(map);
+        }
+    }
 }

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java?rev=931490&r1=931489&r2=931490&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorConfigurationImpl.java
Wed Apr  7 10:17:06 2010
@@ -18,7 +18,6 @@ package org.apache.sling.rewriter.impl;
 
 import java.io.PrintWriter;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.sling.api.resource.Resource;
@@ -206,22 +205,30 @@ public class ProcessorConfigurationImpl 
             pw.println("Pipeline : ");
             pw.println("    Generator : ");
             pw.print("        ");
-            pw.println(this.generatorConfiguration);
+            printConfiguration(pw, this.generatorConfiguration);
             pw.println("    Transformers : ");
             for(int i=0; i<this.transformerConfigurations.length; i++) {
                 pw.print("        ");
-                pw.println(this.transformerConfigurations[i]);
+                printConfiguration(pw, this.transformerConfigurations[i]);
             }
             pw.println("    Serializer : ");
             pw.print("        ");
-            pw.println(this.serializerConfiguration);
+            printConfiguration(pw, this.serializerConfiguration);
         } else {
             pw.print("Configuration : ");
-            pw.println(this.processorConfig);
+            printConfiguration(pw, this.processorConfig);
         }
 
     }
 
+    private void printConfiguration(final PrintWriter pw, final ProcessingComponentConfiguration
config) {
+        if ( config instanceof ProcessingComponentConfigurationImpl ) {
+            ((ProcessingComponentConfigurationImpl)config).printConfiguration(pw);
+        } else {
+            pw.println(config);
+        }
+    }
+
     private String buildDescString() {
         final StringBuilder sb = new StringBuilder();
         sb.append("ProcessorConfiguration: {");
@@ -303,10 +310,10 @@ public class ProcessorConfigurationImpl 
                     final String secondResourceName = prefix + '-' + (i+1);
                     childResource = configResource.getResourceResolver().getResource(configResource,
secondResourceName);
                 }
-                final Map<String, Object> config;
+                final ValueMap config;
                 if ( childResource != null ) {
                     final ValueMap childProps = ResourceUtil.getValueMap(childResource);
-                    config = new HashMap<String, Object>(childProps);
+                    config = childProps;
                 } else {
                     config = null;
                 }



Mime
View raw message