incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r782627 - in /incubator/sling/whiteboard: portal/container/src/main/java/org/apache/sling/portal/container/internal/request/ rewriter/src/main/java/org/apache/sling/rewriter/impl/
Date Mon, 08 Jun 2009 13:57:07 GMT
Author: cziegeler
Date: Mon Jun  8 13:57:07 2009
New Revision: 782627

URL: http://svn.apache.org/viewvc?rev=782627&view=rev
Log:
Some bug fixes and minor enhancements; disable processor for now.

Modified:
    incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java
    incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java
    incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
    incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java

Modified: incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java?rev=782627&r1=782626&r2=782627&view=diff
==============================================================================
--- incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java
(original)
+++ incubator/sling/whiteboard/portal/container/src/main/java/org/apache/sling/portal/container/internal/request/LinkTransformerFactory.java
Mon Jun  8 13:57:07 2009
@@ -43,7 +43,7 @@
  * @scr.component metatype="no"
  * @scr.service
  * @scr.property name="pipeline.mode" value="global"
- * @scr.property name="service.ranking" value="999"
+ * @scr.property name="service.ranking" value="999" type="Integer"
  */
 public class LinkTransformerFactory implements TransformerFactory {
 

Modified: incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java?rev=782627&r1=782626&r2=782627&view=diff
==============================================================================
--- incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java
(original)
+++ incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/FactoryCache.java
Mon Jun  8 13:57:07 2009
@@ -156,7 +156,32 @@
      * all post transformers.
      */
     public Transformer[][] getRewriterTransformers() {
-        return this.transformerTracker.getTransformers();
+        final TransformerFactory[][] factories = this.transformerTracker.getTransformerFactories();
+        return createTransformers(factories);
+    }
+
+    protected Transformer[][] createTransformers(final TransformerFactory[][] factories)
{
+        if ( factories == EMPTY_DOUBLE_ARRAY ) {
+            return FactoryCache.EMPTY_DOUBLE_ARRAY;
+        }
+        final Transformer[][] transformers = new Transformer[2][];
+        if ( factories[0].length == 0 ) {
+            transformers[0] = FactoryCache.EMPTY_ARRAY;
+        } else {
+            transformers[0] = new Transformer[factories[0].length];
+            for(int i=0; i < factories[0].length; i++) {
+                transformers[0][i] = factories[0][i].createTransformer();
+            }
+        }
+        if ( factories[1].length == 0 ) {
+            transformers[1] = FactoryCache.EMPTY_ARRAY;
+        } else {
+            transformers[1] = new Transformer[factories[1].length];
+            for(int i=0; i < factories[1].length; i++) {
+                transformers[1][i] = factories[1][i].createTransformer();
+            }
+        }
+        return transformers;
     }
 
     /**
@@ -168,7 +193,7 @@
         private final Map<String, T> services = new HashMap<String, T>();
 
         /** The bundle context. */
-        private final BundleContext context;
+        protected final BundleContext context;
 
         public HashingServiceTrackerCustomizer(final BundleContext bc, final String serviceClassName)
{
             super(bc, serviceClassName, null);
@@ -235,13 +260,25 @@
         }
 
         /**
+         * Is this cache still valid?
+         */
+        public boolean isCacheValid() {
+            return this.cacheIsValid;
+        }
+
+        /**
          * @see org.osgi.util.tracker.ServiceTracker#addingService(org.osgi.framework.ServiceReference)
          */
         public Object addingService(ServiceReference reference) {
-            if ( isGlobal(reference) ) {
+            final boolean isGlobal = isGlobal(reference);
+            if ( isGlobal ) {
                 this.cacheIsValid = false;
             }
-            return super.addingService(reference);
+            Object obj = super.addingService(reference);
+            if ( obj == null && isGlobal ) {
+                obj = this.getService(reference);
+            }
+            return obj;
         }
 
         /**
@@ -254,7 +291,7 @@
             super.removedService(reference, service);
         }
 
-        private TransformerFactory[][] getTransformerFactories() {
+        public TransformerFactory[][] getTransformerFactories() {
             if ( !this.cacheIsValid ) {
                 synchronized ( this ) {
                     if ( !this.cacheIsValid ) {
@@ -307,31 +344,6 @@
             }
             return this.cached;
         }
-
-        public Transformer[][] getTransformers() {
-            final TransformerFactory[][] factories = this.getTransformerFactories();
-            if ( factories == EMPTY_DOUBLE_ARRAY ) {
-                return FactoryCache.EMPTY_DOUBLE_ARRAY;
-            }
-            final Transformer[][] transformers = new Transformer[2][];
-            if ( factories[0].length == 0 ) {
-                transformers[0] = FactoryCache.EMPTY_ARRAY;
-            } else {
-                transformers[0] = new Transformer[factories[0].length];
-                for(int i=0; i < factories[0].length; i++) {
-                    transformers[0][i] = factories[0][i].createTransformer();
-                }
-            }
-            if ( factories[1].length == 0 ) {
-                transformers[1] = FactoryCache.EMPTY_ARRAY;
-            } else {
-                transformers[1] = new Transformer[factories[1].length];
-                for(int i=0; i < factories[1].length; i++) {
-                    transformers[1][i] = factories[1][i].createTransformer();
-                }
-            }
-            return transformers;
-        }
     }
 
     /**

Modified: incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java?rev=782627&r1=782626&r2=782627&view=diff
==============================================================================
--- incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
(original)
+++ incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/PipelineImpl.java
Mon Jun  8 13:57:07 2009
@@ -27,6 +27,8 @@
 import org.apache.sling.rewriter.ProcessorConfiguration;
 import org.apache.sling.rewriter.Serializer;
 import org.apache.sling.rewriter.Transformer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.xml.sax.ContentHandler;
 import org.xml.sax.SAXException;
 
@@ -36,6 +38,8 @@
  */
 public class PipelineImpl implements Processor {
 
+    private static Logger LOGGER = LoggerFactory.getLogger(PipelineImpl.class);
+
     /** Empty array of transformers. */
     private static final Transformer[] EMPTY_TRANSFORMERS = new Transformer[0];
 
@@ -61,6 +65,7 @@
     public void init(ProcessingContext processingContext,
                      ProcessorConfiguration c)
     throws IOException {
+        LOGGER.debug("Setting up pipeline...");
         final PipelineConfiguration config = (PipelineConfiguration)c;
         final ProcessingComponentConfiguration[] transformerConfigs = config.getTransformerConfigurations();
 
@@ -71,6 +76,7 @@
 
         final ProcessingComponentConfiguration generatorConfig = config.getGeneratorConfiguration();
         final Generator generator = this.getPipelineComponent(Generator.class, generatorConfig.getType());
+        LOGGER.debug("Using generator type {}: {}.", generatorConfig.getType(), generator);
         generator.init(processingContext, generatorConfig);
 
         final int transformerCount = (transformerConfigs == null ? 0 : transformerConfigs.length)
+ rewriters[0].length + rewriters[1].length;
@@ -81,18 +87,21 @@
             int index = 0;
             for(int i=0; i< rewriters[0].length; i++) {
                 transformers[index] = rewriters[0][i];
+                LOGGER.debug("Using pre transformer: {}.", transformers[index]);
                 transformers[index].init(processingContext, ProcessingComponentConfigurationImpl.EMPTY);
                 index++;
             }
             if ( transformerConfigs != null ) {
                 for(int i=0; i< transformerConfigs.length;i++) {
                     transformers[index] = this.getPipelineComponent(Transformer.class, transformerConfigs[i].getType());
+                    LOGGER.debug("Using transformer type {}: {}.", transformerConfigs[i].getType(),
transformers[index]);
                     transformers[index].init(processingContext, transformerConfigs[i]);
                     index++;
                 }
             }
             for(int i=0; i< rewriters[1].length; i++) {
                 transformers[index] = rewriters[1][i];
+                LOGGER.debug("Using post transformer: {}.", transformers[index]);
                 transformers[index].init(processingContext, ProcessingComponentConfigurationImpl.EMPTY);
                 index++;
             }
@@ -102,6 +111,7 @@
 
         final ProcessingComponentConfiguration serializerConfig = config.getSerializerConfiguration();
         final Serializer serializer = this.getPipelineComponent(Serializer.class, serializerConfig.getType());
+        LOGGER.debug("Using serializer type {}: {}.", serializerConfig.getType(), serializer);
         serializer.init(processingContext, serializerConfig);
 
         ContentHandler pipelineComponent = serializer;
@@ -113,6 +123,7 @@
 
         this.firstContentHandler = pipelineComponent;
         generator.setContentHandler(this.firstContentHandler);
+        LOGGER.debug("Finished pipeline setup.");
     }
 
     /**

Modified: incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java?rev=782627&r1=782626&r2=782627&view=diff
==============================================================================
--- incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java
(original)
+++ incubator/sling/whiteboard/rewriter/src/main/java/org/apache/sling/rewriter/impl/ProcessorManagerImpl.java
Mon Jun  8 13:57:07 2009
@@ -52,8 +52,8 @@
 /**
  * This manager keeps track of configured processors.
  *
- * @scr.component metatype="no"
- * @scr.service interface="ProcessorManager"
+ * @scrs.component metatype="no"
+ * @scrs.service interface="ProcessorManager"
  */
 public class ProcessorManagerImpl implements ProcessorManager {
 



Mime
View raw message