incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r815641 - in /sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl: PipelineImpl.java ProcessorWrapper.java RewriterResponse.java
Date Wed, 16 Sep 2009 07:28:04 GMT
Author: cziegeler
Date: Wed Sep 16 07:28:04 2009
New Revision: 815641

URL: http://svn.apache.org/viewvc?rev=815641&view=rev
Log:
Use request tracker logger to log used pipeline.

Modified:
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
    sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorWrapper.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/PipelineImpl.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java?rev=815641&r1=815640&r2=815641&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
Wed Sep 16 07:28:04 2009
@@ -202,4 +202,31 @@
             throw ioe;
         }
     }
+
+    @Override
+    public String toString() {
+        final StringBuilder sb = new StringBuilder();
+        sb.append("Pipeline Processor (");
+        sb.append(super.toString());
+        sb.append(") : ");
+        sb.append("generator: ");
+        sb.append(this.generator != null ? this.generator : "-");
+        sb.append(", transformers: [");
+        if ( this.transformers != null && this.transformers.length > 0 ) {
+            boolean first = true;
+            for(final Transformer t : this.transformers ) {
+                if ( !first ) {
+                    sb.append(", ");
+                }
+                first = false;
+                sb.append(t);
+            }
+            sb.append("]");
+        } else {
+            sb.append("-");
+        }
+        sb.append(", serializer: ");
+        sb.append(this.serializer != null ? this.serializer : "-");
+        return sb.toString();
+    }
 }

Modified: sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorWrapper.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorWrapper.java?rev=815641&r1=815640&r2=815641&view=diff
==============================================================================
--- sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorWrapper.java
(original)
+++ sling/trunk/contrib/extensions/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorWrapper.java
Wed Sep 16 07:28:04 2009
@@ -68,4 +68,9 @@
     throws IOException {
         delegatee.init(context, config);
     }
+
+    @Override
+    public String toString() {
+        return delegatee.toString();
+    }
 }

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=815641&r1=815640&r2=815641&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
Wed Sep 16 07:28:04 2009
@@ -101,18 +101,9 @@
              });
         }
         if (writer == null) {
-            final ProcessingContext processorContext = new ServletProcessingContext(this.request,
this, this.getSlingResponse(), this.contentType);
-            boolean found = false;
-            final List<ProcessorConfiguration> processorConfigs = this.processorManager.getProcessorConfigurations();
-            final Iterator<ProcessorConfiguration> i = processorConfigs.iterator();
-            while ( !found && i.hasNext() ) {
-                final ProcessorConfiguration config = i.next();
-                if ( config.match(processorContext) ) {
-                    found = true;
-
-                    this.processor = this.processorManager.getProcessor(config, processorContext);
-                    this.writer = this.processor.getWriter();
-                }
+            this.processor = this.getProcessor();
+            if ( this.processor != null ) {
+                this.writer = this.processor.getWriter();
             }
             if ( this.writer == null ) {
                 this.writer = super.getWriter();
@@ -151,18 +142,7 @@
     public <AdapterType> AdapterType adaptTo(Class<AdapterType> type) {
         if ( type == ContentHandler.class ) {
             try {
-                final ProcessingContext processorContext = new ServletProcessingContext(this.request,
this, this.getSlingResponse(), this.contentType);
-                boolean found = false;
-                final List<ProcessorConfiguration> processorConfigs = this.processorManager.getProcessorConfigurations();
-                final Iterator<ProcessorConfiguration> i = processorConfigs.iterator();
-                while ( !found && i.hasNext() ) {
-                    final ProcessorConfiguration config = i.next();
-                    if ( config.match(processorContext) ) {
-                        found = true;
-
-                        this.processor = this.processorManager.getProcessor(config, processorContext);
-                    }
-                }
+                this.processor = this.getProcessor();
             } catch (IOException e) {
                 throw new SlingException("Unable to setup pipeline: " + e.getMessage(), e);
             }
@@ -174,4 +154,22 @@
         }
         return super.adaptTo(type);
     }
+
+    /**
+     * Search the first matching processor
+     */
+    private Processor getProcessor() throws IOException {
+        final ProcessingContext processorContext = new ServletProcessingContext(this.request,
this, this.getSlingResponse(), this.contentType);
+        Processor found = null;
+        final List<ProcessorConfiguration> processorConfigs = this.processorManager.getProcessorConfigurations();
+        final Iterator<ProcessorConfiguration> i = processorConfigs.iterator();
+        while ( found == null && i.hasNext() ) {
+            final ProcessorConfiguration config = i.next();
+            if ( config.match(processorContext) ) {
+                found = this.processorManager.getProcessor(config, processorContext);
+                this.request.getRequestProgressTracker().log("Found processor for post processing
{}", found);
+            }
+        }
+        return found;
+    }
 }



Mime
View raw message