forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r708186 - /forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java
Date Mon, 27 Oct 2008 14:05:18 GMT
Author: thorsten
Date: Mon Oct 27 07:05:17 2008
New Revision: 708186

URL: http://svn.apache.org/viewvc?rev=708186&view=rev
Log:
restructuring transformer to better reuse it spring driven context

Modified:
    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/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=708186&r1=708185&r2=708186&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
Mon Oct 27 07:05:17 2008
@@ -27,6 +27,7 @@
 
 import javax.xml.transform.TransformerException;
 import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
 import javax.xml.transform.URIResolver;
 import javax.xml.transform.stream.StreamSource;
 
@@ -143,15 +144,6 @@
 
   /**
    * 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;
-  }
-  
-  /**
-   * Cocoon 2.2 compatible method.
    * Allow that the ServiceManager is be set via e.g. spring
    * @param manager manger to use in the context
    */
@@ -170,6 +162,13 @@
   private String xpathSupport;
 
   /**
+   * @param xpathSupport the xpathSupport to set
+   */
+  public synchronized void setXpathSupport(String xpathSupport) {
+    this.xpathSupport = xpathSupport;
+  }
+
+  /**
    * The prefix that we need to use to resolve a concrete contract.
    */
   private String contractUriPrefix;
@@ -201,10 +200,27 @@
     config.setAllowXmlProperties(allowXml);
     contractUriPrefix = configuration.getChild("contractUriPrefix").getValue(
         "cocoon://resolve.contract.");
-    config.setContractUriSufix("");
+    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.
+   */
+  public void setConfig(WritableDispatcherBean config) {
+    this.config = config;
+    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?
     TransformerFactory tfactory = TransformerFactory.newInstance();
     tfactory.setURIResolver(this);
@@ -234,6 +250,12 @@
       throw new ProcessingException(error);
     }
     this.requestedFormat = parameters.getParameter(Captions.TYPE_ATT, null);
+    /*
+     * We need to change now the contract uri prefixes since in cocoon we need
+     * to add the current format.
+     */
+    String loacalPrefix = contractUriPrefix + requestedFormat + ".";
+    config.setContractUriPrefix(loacalPrefix);
     if (requestedFormat == null) {
       String error = "dispatcherError:\n"
           + "You have to set the \"type\" parameter in the sitemap!";
@@ -283,12 +305,6 @@
     } catch (ProcessingException e) {
       throw new SAXException(e);
     }
-    /*
-     * We need to change now the contract uri prefixes since in cocoon we need
-     * to add the current format.
-     */
-    String loacalPrefix = contractUriPrefix + requestedFormat + ".";
-    config.setContractUriPrefix(loacalPrefix);
     // start structurer routine
     Structurer structurer = null;
     // need to get the properties for this uri



Mime
View raw message