forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r703160 - in /forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher: config/DispatcherBean.java transformation/DispatcherTransformer.java
Date Thu, 09 Oct 2008 13:09:21 GMT
Author: thorsten
Date: Thu Oct  9 06:09:21 2008
New Revision: 703160

URL: http://svn.apache.org/viewvc?rev=703160&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/config/DispatcherBean.java
    forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java

Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/config/DispatcherBean.java
URL: http://svn.apache.org/viewvc/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/config/DispatcherBean.java?rev=703160&r1=703159&r2=703160&view=diff
==============================================================================
--- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/config/DispatcherBean.java
(original)
+++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/config/DispatcherBean.java
Thu Oct  9 06:09:21 2008
@@ -21,150 +21,185 @@
 import org.apache.forrest.dispatcher.api.Resolver;
 
 /**
- * The dispatcherBean is holding all configuration information 
- * that are needed for the different dispatcher components. 
+ * The dispatcherBean is holding all configuration information that are needed
+ * for the different dispatcher components.
  * 
  * @version 1.0
- *
+ * 
  */
 public class DispatcherBean {
-  
-  private boolean shrink=true;
+
+  private boolean shrink = true;
+
   /**
-   * If you use properties like 
-   * <code>&lt;forrest:property name="theme" value="pelt"/></code><p>
-   * There is no real need to pass the element as whole it is sufficient 
-   * to pass a simple string (@value). <p>
-   * If you set it to true we will pass a simple string to the transformation
-   * in the form of key=@name, value=@value.<p>
+   * If you use properties like
+   * <code>&lt;forrest:property name="theme" value="pelt"/></code>
+   * <p>
+   * There is no real need to pass the element as whole it is sufficient to pass
+   * a simple string (@value).
+   * <p>
+   * If you set it to true we will pass a simple string to the transformation in
+   * the form of key=@name, value=@value.
+   * <p>
    * If set to false then we pass the whole element.
-   * @return whether we pass empty properties element as simple string (true) or as w3c element
(false)
+   * 
+   * @return whether we pass empty properties element as simple string (true) or
+   *         as w3c element (false)
    */
   public boolean isShrink() {
     return shrink;
   }
 
   /**
-   * If you use properties like 
-   * <code>&lt;forrest:property name="theme" value="pelt"/></code><p>
-   * There is no real need to pass the element as whole it is sufficient 
-   * to pass a simple string (@value). <p>
-   * If you set it to true we will pass a simple string to the transformation
-   * in the form of key=@name, value=@value.<p>
+   * If you use properties like
+   * <code>&lt;forrest:property name="theme" value="pelt"/></code>
+   * <p>
+   * There is no real need to pass the element as whole it is sufficient to pass
+   * a simple string (@value).
+   * <p>
+   * If you set it to true we will pass a simple string to the transformation in
+   * the form of key=@name, value=@value.
+   * <p>
    * If set to false then we pass the whole element.
-   * @param shrink whether we pass empty properties element as simple string (true) or as
w3c element (false)
+   * 
+   * @param shrink
+   *          whether we pass empty properties element as simple string (true)
+   *          or as w3c element (false)
    */
   public void setShrink(boolean shrink) {
     this.shrink = shrink;
   }
-  
-  
+
   private boolean allowXmlProperties = false;
+
   /**
-   * If you want to use inline xml for contract properties be aware that setting 
-   * this properties to true will have negative influence on performance since 
-   * this feature needs to use DOM parsing!<p>
-   *
-   * We strongly recommend to rewrite your contracts and structurer to use simple 
-   * string for the properties.<p>
+   * If you want to use inline xml for contract properties be aware that setting
+   * this properties to true will have negative influence on performance since
+   * this feature needs to use DOM parsing!
+   * <p>
+   * 
+   * We strongly recommend to rewrite your contracts and structurer to use
+   * simple string for the properties.
+   * <p>
    * Whether we allow that <code>&lt;forrest:property> elements can
-   * have children or not. 
-   * @return Whether we allow that <code>&lt;forrest:property> elements can
-   * have children or not. 
+   * have children or not.
+   * 
+   * @return Whether we allow that <code>&lt;forrest:property> elements can
have
+   *         children or not.
    */
   public boolean isAllowXmlProperties() {
     return allowXmlProperties;
   }
+
   /**
-   * If you want to use inline xml for contract properties be aware that setting 
-   * this properties to true will have negative influence on performance since 
+   * If you want to use inline xml for contract properties be aware that setting
+   * this properties to true will have negative influence on performance since
    * this feature needs to use DOM parsing!<p>
-   *
-   * We strongly recommend to rewrite your contracts and structurer to use simple 
-   * string for the properties.<p>
-   * Whether we allow that <code>&lt;forrest:property> elements can
-   * have children or not. 
-   * @param Whether we allow that <code>&lt;forrest:property> elements can
-   * have children or not. 
+   * 
+   * We strongly recommend to rewrite your contracts and structurer to use
+   * simple string for the properties.<p> Whether we allow that
+   * <code>&lt;forrest:property> elements can have children or not.
+   * 
+   * @param Whether
+   *          we allow that <code>&lt;forrest:property> elements can have
+   *          children or not.
    */
   public void setAllowXmlProperties(boolean allowXmlProperties) {
     this.allowXmlProperties = allowXmlProperties;
   }
-  
 
   private Resolver resolver = null;
+
   /**
    * Wrapper interface to enable multible resolver implementation this makes it
- * possible to use the dispatcher outside of cocoon as standalone application
- * without any mayor rewrites.
+   * possible to use the dispatcher outside of cocoon as standalone application
+   * without any mayor rewrites.
+   * 
    * @return the currently configured resolver
    */
   public Resolver getResolver() {
     return resolver;
   }
+
   /**
    * Wrapper interface to enable multible resolver implementation this makes it
- * possible to use the dispatcher outside of cocoon as standalone application
- * without any mayor rewrites.
-   * @param the currently configured resolver
+   * possible to use the dispatcher outside of cocoon as standalone application
+   * without any mayor rewrites.
+   * 
+   * @param the
+   *          currently configured resolver
    */
   public void setResolver(Resolver resolver) {
     this.resolver = resolver;
   }
 
-  
   private String contractUriPrefix = "";
+
   /**
-   * If you want to change the uri prefix of the contracts. 
-   * This may be interesting if you work with a contract repository rather then
-   * with the ones from the themer plugin. 
+   * If you want to change the uri prefix of the contracts. This may be
+   * interesting if you work with a contract repository rather then with the
+   * ones from the themer plugin.
+   * 
    * @return prefix of the contracts
    */
   public String getContractUriPrefix() {
     return contractUriPrefix;
   }
+
   /**
-   * If you want to change the uri prefix of the contracts. 
-   * This may be interesting if you work with a contract repository rather then
-   * with the ones from the themer plugin. 
-   * @param prefix of the contracts
+   * If you want to change the uri prefix of the contracts. This may be
+   * interesting if you work with a contract repository rather then with the
+   * ones from the themer plugin.
+   * 
+   * @param prefix
+   *          of the contracts
    */
   public void setContractUriPrefix(String contractUriPrefix) {
     this.contractUriPrefix = contractUriPrefix;
   }
-  
+
   private String contractUriSufix = ".contract.xml";
+
   /**
-   * If you want to change the uri suffix of the contracts. 
-   * This may be interesting if you work with a contract repository rather then
-   * with the ones from the themer plugin. 
+   * If you want to change the uri suffix of the contracts. This may be
+   * interesting if you work with a contract repository rather then with the
+   * ones from the themer plugin.
+   * 
    * @return suffix of the contracts
    */
   public String getContractUriSufix() {
     return contractUriSufix;
   }
+
   /**
-   * If you want to change the uri suffix of the contracts. 
-   * This may be interesting if you work with a contract repository rather then
-   * with the ones from the themer plugin. 
-   * @param suffix of the contracts
+   * If you want to change the uri suffix of the contracts. This may be
+   * interesting if you work with a contract repository rather then with the
+   * ones from the themer plugin.
+   * 
+   * @param suffix
+   *          of the contracts
    */
   public void setContractUriSufix(String contractUriSufix) {
     this.contractUriSufix = contractUriSufix;
   }
 
   private URIResolver uriResolver = null;
+
   /**
-   * <p>An object that can be called by the xsl processor
-   * to turn a URI used in document(), xsl:import, or xsl:include into a Source object.
-   * @param uriResolver the uriResolver currently configured
+   * <p>An object that can be called by the xsl processor to turn a URI used in
+   * document(), xsl:import, or xsl:include into a Source object.
+   * 
+   * @param uriResolver
+   *          the uriResolver currently configured
    */
   public void setUriResolver(URIResolver uriResolver) {
     this.uriResolver = uriResolver;
   }
+
   /**
-   * <p>An object that can be called by the xsl processor
-   * to turn a URI used in document(), xsl:import, or xsl:include into a Source object.
+   * <p>An object that can be called by the xsl processor to turn a URI used in
+   * document(), xsl:import, or xsl:include into a Source object.
+   * 
    * @return uriResolver the uriResolver currently configured
    */
   public URIResolver getUriResolver() {

Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.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/DispatcherTransformer.java?rev=703160&r1=703159&r2=703160&view=diff
==============================================================================
--- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
(original)
+++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
Thu Oct  9 06:09:21 2008
@@ -59,22 +59,19 @@
 /**
  * A cocoon transformer wrapper class for the dispatcher.
  * 
- * The actual work will be done in the core code of the 
- * dispatcher which is based on StAX and AXIOM.
+ * The actual work will be done in the core code of the dispatcher which is
+ * based on StAX and AXIOM.
  * 
- * <li>In this transformer we doing principal configuration 
- *  to adopt the dispatcher to the cocoon environment 
- *  ({@link #configure(Configuration)} and 
- *  ({@link #setup(SourceResolver, Map, String, Parameters)}
- * <li>We reusing cocoon caching mechanism ({@link #getKey()}
- *  and {@link #getValidity()} to cache the dispatcher.  
- * <li>We record the SAX events ({@link #startDocument()} 
- *  to later {@link #endDocument()} passing them as  
- *  Stream to the Structurer implementation we
- *  have chosen. 
+ * <li>In this transformer we doing principal configuration to adopt the
+ * dispatcher to the cocoon environment ({@link #configure(Configuration)} and (
+ * {@link #setup(SourceResolver, Map, String, Parameters)} <li>We reusing cocoon
+ * caching mechanism ({@link #getKey()} and {@link #getValidity()} to cache the
+ * dispatcher. <li>We record the SAX events ({@link #startDocument()} to later
+ * {@link #endDocument()} passing them as Stream to the Structurer
+ * implementation we have chosen.
  * 
  * @version 1.0
- *
+ * 
  */
 public class DispatcherTransformer extends AbstractSAXTransformer implements
     Disposable, CacheableProcessingComponent, URIResolver {
@@ -85,7 +82,7 @@
    * Used to identify the structure to process
    */
   private String requestedFormat;
-  
+
   /**
    * The requested id.
    * <p>
@@ -101,13 +98,13 @@
   private SourceValidity validity;
 
   private String validityChecking;
-  
+
   /**
    * Resolver which will be used for uri resolving
    */
 
   private org.apache.excalibur.source.SourceResolver m_resolver;
-  
+
   /**
    * The caption for the cache parameter
    */
@@ -132,25 +129,25 @@
    * The caption for the condition that caching is turned on
    */
   public static final String CACHING_ON = "on";
-  
+
   /**
    * Logger
    */
   private Logger log;
-  
+
   /**
-   * Main configuration bean of the dispatcher.<p>
-   * This config will control things like 
-   * <li>contract prefixes/suffixes
-   * <li>resolver to use
+   * Main configuration bean of the dispatcher.
+   * <p>
+   * This config will control things like <li>contract prefixes/suffixes <li>
+   * resolver to use
    */
   private DispatcherBean config;
 
   /**
-   * The level of xpath support we need.<p>
-   * If you choose enhanced you can inject/create node
-   * with enhanced xpath expression like e.g. 
-   * /root/child[id='test']
+   * The level of xpath support we need.
+   * <p>
+   * If you choose enhanced you can inject/create node with enhanced xpath
+   * expression like e.g. /root/child[id='test']
    * <p>
    * Supported values are: basic | enhanced
    */
@@ -162,8 +159,8 @@
   private String contractUriPrefix;
 
   /**
-   * The parameter caption use to pass the requestId from the
-   * sitemap to the contract
+   * The parameter caption use to pass the requestId from the sitemap to the
+   * contract
    */
   public static final String DISPATCHER_REQUEST_ATTRIBUTE = "request";
 
@@ -171,7 +168,7 @@
    * The caption of the key for the default variables
    */
   private static final String DEFAULT_VARIABLES = "defaultVariables";
-  
+
   /*
    * @see
    * org.apache.cocoon.transformation.AbstractSAXTransformer#configure(org.apache
@@ -179,17 +176,17 @@
    */
   public void configure(Configuration configuration)
       throws ConfigurationException {
-    // creating a new config and store the general not request specific parameters here
+    // creating a new config and store the general not request specific
+    // parameters here
     config = new DispatcherBean();
     boolean allowXml = configuration.getChild("allowXml").getValueAsBoolean(
         false);
     config.setAllowXmlProperties(allowXml);
-    contractUriPrefix = configuration.getChild("contractUriPrefix")
-        .getValue("cocoon://resolve.contract.");
+    contractUriPrefix = configuration.getChild("contractUriPrefix").getValue(
+        "cocoon://resolve.contract.");
     config.setContractUriSufix("");
     xpathSupport = configuration.getChild("xpathSupport").getValue("basic");
-    boolean shrink = configuration.getChild("shrink").getValueAsBoolean(
-        true);
+    boolean shrink = configuration.getChild("shrink").getValueAsBoolean(true);
     config.setShrink(shrink);
     config.setUriResolver(this);
   }
@@ -236,7 +233,7 @@
   }
 
   public void startDocument() throws SAXException {
-    // just start the recording 
+    // just start the recording
     startSerializedXMLRecording(null);
   }
 
@@ -249,38 +246,38 @@
       throw new SAXException(e);
     }
     /*
-     * We need to change now the contract uri prefixes
-     * since in cocoon we need to add the current 
-     * format.
+     * We need to change now the contract uri prefixes since in cocoon we need
+     * to add the current format.
      */
-    String loacalPrefix =contractUriPrefix+requestedFormat+".";
+    String loacalPrefix = contractUriPrefix + requestedFormat + ".";
     config.setContractUriPrefix(loacalPrefix);
     // start structurer routine
     Structurer structurer = null;
     // need to get the properties for this uri
-    HashMap<String,Object> map = new HashMap<String, Object>();
+    HashMap<String, Object> map = new HashMap<String, Object>();
     String propertyURI = "cocoon://" + requestId + ".props";
     try {
       Source propsSource = m_resolver.resolveURI(propertyURI);
-      if(propsSource!=null){
-        InputStream stream = new BufferedInputStream(propsSource.getInputStream());
-      if (config.isAllowXmlProperties()){
-     // get the bytes from the stream
-        byte [] properties = IOUtils.getStreamAsByteArray(stream);
-        map.put(DEFAULT_VARIABLES, properties);
-      }else{
-        XMLProperties.parseProperties(stream, map);
-      }
-      release(propsSource);
+      if (propsSource != null) {
+        InputStream stream = new BufferedInputStream(propsSource
+            .getInputStream());
+        if (config.isAllowXmlProperties()) {
+          // get the bytes from the stream
+          byte[] properties = IOUtils.getStreamAsByteArray(stream);
+          map.put(DEFAULT_VARIABLES, properties);
+        } else {
+          XMLProperties.parseProperties(stream, map);
+        }
+        release(propsSource);
       }
     } catch (Exception e) {
       throw new SAXException(e);
     }
     // which implementation do we want
     if (xpathSupport.equals("enhanced")) {
-      structurer = new XMLStructurerAxiom(config,map);
+      structurer = new XMLStructurerAxiom(config, map);
     } else {
-      structurer = new XMLStructurer(config,map);
+      structurer = new XMLStructurer(config, map);
     }
     SAXParser parser = null;
     try {
@@ -289,7 +286,7 @@
           new ByteArrayInputStream(document.getBytes())), requestedFormat);
       // requesting a parser
       parser = (SAXParser) manager.lookup(SAXParser.ROLE);
-   // adding the result to the consumer
+      // adding the result to the consumer
       parser.parse(new InputSource(result), super.xmlConsumer);
     } catch (DispatcherException e) {
       throw new SAXException(e);
@@ -319,17 +316,17 @@
    *         is currently not cacheable.
    */
   public SourceValidity getValidity() {
- // You can either request URL?dispatcher.caching=off
+    // You can either request URL?dispatcher.caching=off
     // or add this property to forrest.properties.xml
     // to force a SourceValidity.INVALID
     if (null != validityFile && !(validityChecking.equals(CACHING_OFF))) {
-    Source resolveSource=null;
+      Source resolveSource = null;
       try {
-        resolveSource= m_resolver.resolveURI(validityFile);
+        resolveSource = m_resolver.resolveURI(validityFile);
         this.validity = resolveSource.getValidity();
       } catch (Exception e) {
         getLogger().error(e.getMessage());
-      }finally{
+      } finally {
         release(resolveSource);
       }
     } else
@@ -374,87 +371,87 @@
     super.recycle();
 
   }
-  
-//From URIResolver, copied from TraxProcessor
+
+  // From URIResolver, copied from TraxProcessor
   public javax.xml.transform.Source resolve(String href, String base)
-  throws TransformerException {
-if (getLogger().isDebugEnabled()) {
-  getLogger().debug(
-      "resolve(href = " + href + ", base = " + base + "); resolver = "
-          + m_resolver);
-}
+      throws TransformerException {
+    if (getLogger().isDebugEnabled()) {
+      getLogger().debug(
+          "resolve(href = " + href + ", base = " + base + "); resolver = "
+              + m_resolver);
+    }
 
-Source xslSource = null;
-try {
-  if (base == null || href.indexOf(":") > 1) {
-    // Null base - href must be an absolute URL
-    xslSource = m_resolver.resolveURI(href);
-  } else if (href.length() == 0) {
-    // Empty href resolves to base
-    xslSource = m_resolver.resolveURI(base);
-  } else {
-    // is the base a file or a real m_url
-    if (!base.startsWith("file:")) {
-      int lastPathElementPos = base.lastIndexOf('/');
-      if (lastPathElementPos == -1) {
-        // this should never occur as the base should
-        // always be protocol:/....
-        return null; // we can't resolve this
+    Source xslSource = null;
+    try {
+      if (base == null || href.indexOf(":") > 1) {
+        // Null base - href must be an absolute URL
+        xslSource = m_resolver.resolveURI(href);
+      } else if (href.length() == 0) {
+        // Empty href resolves to base
+        xslSource = m_resolver.resolveURI(base);
       } else {
-        xslSource = m_resolver.resolveURI(base.substring(0,
-            lastPathElementPos)
-            + "/" + href);
+        // is the base a file or a real m_url
+        if (!base.startsWith("file:")) {
+          int lastPathElementPos = base.lastIndexOf('/');
+          if (lastPathElementPos == -1) {
+            // this should never occur as the base should
+            // always be protocol:/....
+            return null; // we can't resolve this
+          } else {
+            xslSource = m_resolver.resolveURI(base.substring(0,
+                lastPathElementPos)
+                + "/" + href);
+          }
+        } else {
+          File parent = new File(base.substring(5));
+          File parent2 = new File(parent.getParentFile(), href);
+          xslSource = m_resolver.resolveURI(parent2.toURL().toExternalForm());
+        }
       }
-    } else {
-      File parent = new File(base.substring(5));
-      File parent2 = new File(parent.getParentFile(), href);
-      xslSource = m_resolver.resolveURI(parent2.toURL().toExternalForm());
+
+      InputSource is = getInputSource(xslSource);
+
+      if (getLogger().isDebugEnabled()) {
+        getLogger().debug(
+            "xslSource = " + xslSource + ", system id = " + xslSource.getURI());
+      }
+
+      return new StreamSource(is.getByteStream(), is.getSystemId());
+    } catch (SourceException e) {
+      if (getLogger().isDebugEnabled()) {
+        getLogger().debug(
+            "Failed to resolve " + href + "(base = " + base + "), return null",
+            e);
+      }
+
+      // CZ: To obtain the same behaviour as when the resource is
+      // transformed by the XSLT Transformer we should return null here.
+      return null;
+    } catch (java.net.MalformedURLException mue) {
+      getLogger().debug(
+          "Failed to resolve " + href + "(base = " + base + "), return null",
+          mue);
+
+      return null;
+    } catch (IOException ioe) {
+      if (getLogger().isDebugEnabled()) {
+        getLogger().debug(
+            "Failed to resolve " + href + "(base = " + base + "), return null",
+            ioe);
+      }
+
+      return null;
+    } finally {
+      release(xslSource);
     }
   }
 
-  InputSource is = getInputSource(xslSource);
-
-  if (getLogger().isDebugEnabled()) {
-    getLogger().debug(
-        "xslSource = " + xslSource + ", system id = " + xslSource.getURI());
-  }
-
-  return new StreamSource(is.getByteStream(), is.getSystemId());
-} catch (SourceException e) {
-  if (getLogger().isDebugEnabled()) {
-    getLogger().debug(
-        "Failed to resolve " + href + "(base = " + base + "), return null",
-        e);
-  }
-
-  // CZ: To obtain the same behaviour as when the resource is
-  // transformed by the XSLT Transformer we should return null here.
-  return null;
-} catch (java.net.MalformedURLException mue) {
-  getLogger().debug(
-      "Failed to resolve " + href + "(base = " + base + "), return null",
-      mue);
-
-  return null;
-} catch (IOException ioe) {
-  if (getLogger().isDebugEnabled()) {
-    getLogger().debug(
-        "Failed to resolve " + href + "(base = " + base + "), return null",
-        ioe);
-  }
-
-  return null;
-} finally {
-    release(xslSource);
-}
-}
   /**
-   * Return a new <code>InputSource</code> object that uses the
-   * <code>InputStream</code> and the system ID of the <code>Source</code>
-   * object.
+   * Return a new <code>InputSource</code> object that uses the <code>
+   * InputStream</code> and the system ID of the <code>Source</code> object.
    * 
    * @throws IOException
-   *               if I/O error occured.
+   *           if I/O error occured.
    */
   private static InputSource getInputSource(final Source source)
       throws IOException, SourceException {



Mime
View raw message