incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r883268 - in /sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl: ProcessingComponentConfigurationImpl.java ProcessorConfigurationImpl.java RewriterResponse.java
Date Mon, 23 Nov 2009 08:14:26 GMT
Author: cziegeler
Date: Mon Nov 23 08:14:24 2009
New Revision: 883268

URL: http://svn.apache.org/viewvc?rev=883268&view=rev
Log:
Implementing toString for configs for better results in the request log.

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
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/RewriterResponse.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=883268&r1=883267&r2=883268&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
Mon Nov 23 08:14:24 2009
@@ -40,6 +40,8 @@
     /** The configuration map. */
     private final ValueMap configuration;
 
+    private final String descText;
+
     /**
      * Create a new configuration.
      * @param type The type of the component.
@@ -48,6 +50,17 @@
     public ProcessingComponentConfigurationImpl(final String type, final Map<String, Object>
config) {
         this.type = type;
         this.configuration = (config == null ? EMPTY_CONFIG : new ValueMapDecorator(config));
+        final StringBuilder sb = new StringBuilder();
+        sb.append("Config(type=");
+        sb.append(this.type);
+        sb.append(", config=");
+        if ( config == null ) {
+            sb.append("{}");
+        } else {
+            sb.append(config);
+        }
+        sb.append(")");
+        this.descText = sb.toString();
     }
 
     /**
@@ -63,4 +76,10 @@
     public String getType() {
         return this.type;
     }
+
+    @Override
+    public String toString() {
+        return this.descText;
+    }
+
 }

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=883268&r1=883267&r2=883268&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
Mon Nov 23 08:14:24 2009
@@ -16,6 +16,7 @@
  */
 package org.apache.sling.rewriter.impl;
 
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -95,6 +96,8 @@
 
     private final boolean processErrorResponse;
 
+    private final String descString;
+
     /**
      * This is the constructor for a pipeline
      */
@@ -120,6 +123,7 @@
         this.isValid = true;
         this.isPipeline = true;
         this.processErrorResponse = processErrorResponse;
+        this.descString = this.buildDescString();
     }
 
     /**
@@ -169,6 +173,59 @@
         } else {
             this.isValid = (this.processorConfig != null);
         }
+        this.descString = this.buildDescString();
+    }
+
+    private String buildDescString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("ProcessorConfiguration: {");
+        if ( this.contentTypes != null ) {
+            sb.append("contentTypes=");
+            sb.append(Arrays.toString(this.contentTypes));
+            sb.append(',');
+        }
+        if ( this.resourceTypes != null ) {
+            sb.append("resourceTypes=");
+            sb.append(Arrays.toString(this.resourceTypes));
+            sb.append(", ");
+        }
+        if ( this.paths != null ) {
+            sb.append("paths=");
+            sb.append(Arrays.toString(this.paths));
+            sb.append(", ");
+        }
+        if ( this.extensions != null ) {
+            sb.append("extensions=");
+            sb.append(Arrays.toString(this.extensions));
+            sb.append(", ");
+        }
+        sb.append("order=");
+        sb.append(this.order);
+        sb.append(", active=");
+        sb.append(this.isActive);
+        sb.append(", valid=");
+        sb.append(this.isValid);
+        sb.append(", processErrorResponse=");
+        sb.append(this.processErrorResponse);
+        if ( this.isPipeline ) {
+            sb.append(", pipeline=(generator=");
+            sb.append(this.generatorConfiguration);
+            sb.append(", transformers=(");
+            for(int i=0; i<this.transformerConfigurations.length; i++) {
+                if ( i > 0 ) {
+                    sb.append(", ");
+                }
+                sb.append(this.transformerConfigurations[i]);
+            }
+            sb.append(", serializer=");
+            sb.append(this.serializerConfiguration);
+            sb.append(')');
+        } else {
+            sb.append(", config=");
+            sb.append(this.processorConfig);
+        }
+        sb.append("}");
+        return sb.toString();
     }
 
     protected ProcessingComponentConfiguration getComponentConfig(final Resource configResource,
@@ -363,4 +420,9 @@
         }
         return this.processorConfig.getType();
     }
+
+    @Override
+    public String toString() {
+        return this.descString;
+    }
 }

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/RewriterResponse.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/RewriterResponse.java?rev=883268&r1=883267&r2=883268&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/RewriterResponse.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/RewriterResponse.java
Mon Nov 23 08:14:24 2009
@@ -167,7 +167,7 @@
             final ProcessorConfiguration config = i.next();
             if ( config.match(processorContext) ) {
                 found = this.processorManager.getProcessor(config, processorContext);
-                this.request.getRequestProgressTracker().log("Found processor for post processing
{0}", found);
+                this.request.getRequestProgressTracker().log("Found processor for post processing
{0}", config);
             }
         }
         return found;



Mime
View raw message