You are viewing a plain text version of this content. The canonical link for it is here.
Posted to svn@forrest.apache.org by th...@apache.org on 2008/12/02 12:57:24 UTC

svn commit: r722435 - /forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java

Author: thorsten
Date: Tue Dec  2 03:57:23 2008
New Revision: 722435

URL: http://svn.apache.org/viewvc?rev=722435&view=rev
Log:
white noise - formating changes

Modified:
    forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java

Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java
URL: http://svn.apache.org/viewvc/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java?rev=722435&r1=722434&r2=722435&view=diff
==============================================================================
--- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java (original)
+++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherWrapperTransformer.java Tue Dec  2 03:57:23 2008
@@ -77,8 +77,8 @@
  * @version 1.0
  * 
  */
-public class DispatcherWrapperTransformer extends AbstractSAXTransformer implements
-    Disposable, CacheableProcessingComponent, URIResolver {
+public class DispatcherWrapperTransformer extends AbstractSAXTransformer
+    implements Disposable, CacheableProcessingComponent, URIResolver {
 
   /**
    * The requested format.
@@ -143,11 +143,13 @@
   private WritableDispatcherBean config;
 
   /**
-   * Cocoon 2.2 compatible method.
-   * Allow that the ServiceManager is be set via e.g. spring
-   * @param manager manger to use in the context
+   * Cocoon 2.2 compatible method. Allow that the ServiceManager is be set via
+   * e.g. spring
+   * 
+   * @param manager
+   *          manger to use in the context
    */
-  public void setManager(ServiceManager manager){
+  public void setManager(ServiceManager manager) {
     this.manager = manager;
   }
 
@@ -162,7 +164,8 @@
   private String xpathSupport;
 
   /**
-   * @param xpathSupport the xpathSupport to set
+   * @param xpathSupport
+   *          the xpathSupport to set
    */
   public synchronized void setXpathSupport(String xpathSupport) {
     this.xpathSupport = xpathSupport;
@@ -185,10 +188,11 @@
   private static final String DEFAULT_VARIABLES = "defaultVariables";
 
   /**
-   * preparing the parser that will pick up the result and
-   * pass it to the consumer again. 
+   * preparing the parser that will pick up the result and pass it to the
+   * consumer again.
    */
   SAXParser parser = null;
+
   /*
    * @see
    * org.apache.cocoon.transformation.AbstractSAXTransformer#configure(org.apache
@@ -205,25 +209,29 @@
     config.setAllowXmlProperties(allowXml);
     contractUriPrefix = configuration.getChild("contractUriPrefix").getValue(
         "cocoon://resolve.contract.");
-    config.setContractUriSufix(configuration.getChild("contractUriSufix").getValue(""));
+    config.setContractUriSufix(configuration.getChild("contractUriSufix")
+        .getValue(""));
     xpathSupport = configuration.getChild("xpathSupport").getValue("basic");
     boolean shrink = configuration.getChild("shrink").getValueAsBoolean(true);
     config.setShrink(shrink);
     setNewTransformerFactory();
   }
-  
+
   /**
-   * Cocoon 2.2 compatible method.
-   * Allow that the WritableDispatcherBean is be set via e.g. spring
-   * @param config the configuration to use.
+   * Cocoon 2.2 compatible method. Allow that the WritableDispatcherBean is be
+   * set via e.g. spring
+   * 
+   * @param config
+   *          the configuration to use.
    */
   public void setConfig(WritableDispatcherBean config) {
     this.config = config;
-    if(config.getTransFact()==null){
+    if (config.getTransFact() == null) {
       setNewTransformerFactory();
     }
     contractUriPrefix = config.getContractUriPrefix();
   }
+
   private void setNewTransformerFactory()
       throws TransformerFactoryConfigurationError {
     // FIXME: is this the best way to get an instance in cocoon?
@@ -243,8 +251,9 @@
         .getParameter(DISPATCHER_REQUEST_ATTRIBUTE, null);
     this.cacheKey = parameters.getParameter(CACHE_PARAMETER, null);
     if (null == this.cacheKey)
-      getLogger().warn("Caching not activated! Declare the CACHE_KEY_PARAMETER="
-          + CACHE_PARAMETER + " in your sitemap.");
+      getLogger().warn(
+          "Caching not activated! Declare the CACHE_KEY_PARAMETER="
+              + CACHE_PARAMETER + " in your sitemap.");
     this.validityFile = parameters.getParameter(VALIDITY_PARAMETER, null);
     this.validityChecking = parameters.getParameter(
         VALIDITY_OVERRIDE_PARAMETER, "");
@@ -268,7 +277,7 @@
       throw new ProcessingException(error);
     }
     this.cacheKey += requestedFormat;
-    if (null == m_resolver){
+    if (null == m_resolver) {
       try {
         m_resolver = (org.apache.excalibur.source.SourceResolver) manager
             .lookup(SourceResolver.ROLE);
@@ -278,31 +287,31 @@
       }
     }
   }
-  
-/*
- * Here we just start recording to use them later on.
- * 
- * In the future we may want to implement a sax based 
- * structurer implementation again.
- * 
- * old transformer link @see
- * http://svn.apache.org/viewvc?view=rev&revision=694101
- * 
- * @see org.apache.cocoon.transformation.AbstractSAXTransformer#startDocument()
- */
+
+  /*
+   * Here we just start recording to use them later on.
+   * 
+   * In the future we may want to implement a sax based structurer
+   * implementation again.
+   * 
+   * old transformer link @see
+   * http://svn.apache.org/viewvc?view=rev&revision=694101
+   * 
+   * @see
+   * org.apache.cocoon.transformation.AbstractSAXTransformer#startDocument()
+   */
   public void startDocument() throws SAXException {
     // just start the recording
     startSerializedXMLRecording(null);
   }
 
   /*
-   * Here we pick up the recoreder result and start the
-   * processing on it.
+   * Here we pick up the recoreder result and start the processing on it.
    * 
    * @see org.apache.cocoon.transformation.AbstractSAXTransformer#endDocument()
    */
   public void endDocument() throws SAXException {
-    
+
     // start structurer routine
     Structurer structurer = null;
     // need to get the properties for this uri
@@ -312,28 +321,26 @@
       // get the source representation of the propertyURI
       Source propsSource = m_resolver.resolveURI(propertyURI);
       if (propsSource != null) {
-        // get the stream 
+        // get the stream
         InputStream stream = new BufferedInputStream(propsSource
             .getInputStream());
         /*
-         * we need either just the bytes of the stream (if we allow
-         * xml properties) or we need to process it extracting the 
-         * properties.  
+         * we need either just the bytes of the stream (if we allow xml
+         * properties) or we need to process it extracting the properties.
          */
         if (config.isAllowXmlProperties()) {
           // get the bytes from the stream
           byte[] properties = IOUtils.getStreamAsByteArray(stream);
           /*
-           *  add the bytes to the properties map
-           *  later on they will be picked up and
-           *  parsed to a dom node.
+           * add the bytes to the properties map later on they will be picked up
+           * and parsed to a dom node.
            */
           map.put(DEFAULT_VARIABLES, properties);
         } else {
           // extract the properties of the in coming stream
           XMLProperties.parseProperties(stream, map);
         }
-        // release source - you need to ALWAYS do this! 
+        // release source - you need to ALWAYS do this!
         release(propsSource);
       }
     } catch (Exception e) {
@@ -342,44 +349,43 @@
     // which implementation do we want
     if (xpathSupport.equals("enhanced")) {
       /*
-       * The axiom implementation is an object model
-       * approach to StAX. It allows you a dom like navigation
-       * (allocate xpath nodes), adding of child elements in
-       * this xpath statement and many more. 
+       * The axiom implementation is an object model approach to StAX. It allows
+       * you a dom like navigation (allocate xpath nodes), adding of child
+       * elements in this xpath statement and many more.
        */
-      structurer = new XMLStructurerAxiom((DispatcherBean)config, map);
+      structurer = new XMLStructurerAxiom((DispatcherBean) config, map);
     } else {
       /*
-       * The stax implementationis 100% StAX even the generation 
-       * of the resulting document is done with StAX.
-       * However it does not offer real support of xpath expressions.
+       * The stax implementationis 100% StAX even the generation of the
+       * resulting document is done with StAX. However it does not offer real
+       * support of xpath expressions.
        */
-      structurer = new XMLStructurer((DispatcherBean)config, map);
+      structurer = new XMLStructurer((DispatcherBean) config, map);
     }
-    
+
     try {
-     // the recorded document we just streamed
-        String document = null;
-        try {
-          // request the information from the recorder
-          document = super.endSerializedXMLRecording();
-        } catch (ProcessingException e) {
-          throw new SAXException(e);
-        }
-        // get the result of the structurer as stream
-        InputStream result = structurer.execute(new BufferedInputStream(
-            new ByteArrayInputStream(document.getBytes())), requestedFormat);
-     // requesting a parser
-        parser = (SAXParser) manager.lookup(SAXParser.ROLE);
-        // adding the result to the consumer
-        parser.parse(new InputSource(result), super.xmlConsumer); 
+      // the recorded document we just streamed
+      String document = null;
+      try {
+        // request the information from the recorder
+        document = super.endSerializedXMLRecording();
+      } catch (ProcessingException e) {
+        throw new SAXException(e);
+      }
+      // get the result of the structurer as stream
+      InputStream result = structurer.execute(new BufferedInputStream(
+          new ByteArrayInputStream(document.getBytes())), requestedFormat);
+      // requesting a parser
+      parser = (SAXParser) manager.lookup(SAXParser.ROLE);
+      // adding the result to the consumer
+      parser.parse(new InputSource(result), super.xmlConsumer);
     } catch (DispatcherException e) {
       throw new SAXException(e);
     } catch (Exception e) {
       throw new SAXException(e);
     } finally {
       if (null != parser) {
-     // release parser - you need to ALWAYS do this! 
+        // release parser - you need to ALWAYS do this!
         manager.release(parser);
       }
     }
@@ -458,9 +464,11 @@
 
   }
 
-  /* 
+  /*
    * From URIResolver, copied from TraxProcessor
-   * @see javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String)
+   * 
+   * @see javax.xml.transform.URIResolver#resolve(java.lang.String,
+   * java.lang.String)
    */
   public javax.xml.transform.Source resolve(String href, String base)
       throws TransformerException {