forrest-svn mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r736993 - /forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XSLContract.java
Date Fri, 23 Jan 2009 10:53:02 GMT
Author: thorsten
Date: Fri Jan 23 02:53:01 2009
New Revision: 736993

URL: http://svn.apache.org/viewvc?rev=736993&view=rev
Log:
Enhancing error reporting by adding the name of the contract that have caused the error. Adopting
the move to SAX for contract processing. Adding more javadoc to better explain the class.

Modified:
    forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XSLContract.java

Modified: forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XSLContract.java
URL: http://svn.apache.org/viewvc/forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XSLContract.java?rev=736993&r1=736992&r2=736993&view=diff
==============================================================================
--- forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XSLContract.java
(original)
+++ forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/impl/XSLContract.java
Fri Jan 23 02:53:01 2009
@@ -33,7 +33,6 @@
 import org.apache.forrest.dispatcher.api.Contract;
 import org.apache.forrest.dispatcher.exception.ContractException;
 import org.apache.forrest.dispatcher.impl.helper.Loggable;
-import org.apache.forrest.dispatcher.impl.helper.StAX;
 import org.apache.forrest.dispatcher.impl.helper.XSLContractHelper;
 
 public class XSLContract extends Loggable implements Contract {
@@ -44,20 +43,38 @@
 
   private boolean allowXmlProperties = false;
 
-  public XSLContract(boolean allowXmlProperties, TransformerFactory transformerFactory,StAX
stax) throws ContractException {
+  /**
+   * This contract implementation is assuming xsl based contracts
+   * and their corresponding descriptors. A contract descriptor is
+   * providing information about name, description, usage and xsl stylesheet.
+   * <p>
+   * 
+   * @param allowXmlProperties are we allowing xml based properties. This are the ones where
you 
+   * have you own set of xml within the <code>&lt;forrest:property></code>
element.
+   * @param transformerFactory the transformer factory that we should use
+   * @throws ContractException
+   */
+  public XSLContract(boolean allowXmlProperties, TransformerFactory transformerFactory) throws
ContractException {
     this.allowXmlProperties = allowXmlProperties;
     /*
      * get a new instance of the corresponding helper class since the helper is
      * doing the actual work
      */
-    helper = new XSLContractHelper(transformerFactory,stax);
+    try {
+      helper = new XSLContractHelper(transformerFactory);
+    } catch (Exception e) {
+      throw new ContractException(e);
+    }
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.forrest.dispatcher.api.Contract#execute(java.io.InputStream, java.util.Map)
+   */
   public BufferedInputStream execute(InputStream dataStream,
       Map<String, Object> properties) throws ContractException {
     if (xslSource == null || helper == null) {
       String message = "The xsl source have not been initialize from stream "
-          + "for the contract.";
+          + "for the contract \""+name+"\".";
       throw new ContractException(message);
     }
     try {
@@ -67,7 +84,7 @@
       helper.prepareTransformation(xslSource, allowXmlProperties, properties);
     } catch (TransformerConfigurationException e) {
       String message =  "Could not setup the transformer for "
-                + "the contract."+"\n"+ e;
+                + "the contract \""+name+"\".\n"+ e;
       throw new ContractException(message );
     } catch (Exception e) {
       throw new ContractException(e);
@@ -81,7 +98,7 @@
         dataStream = helper.createEmptyXml();
       } catch (XMLStreamException e) {
         String message = "Could not create an empty xml document for "
-            + "the contract. " +"\n"+ e;
+            + "the contract \""+name+"\".\n"+ e;
         throw new ContractException(message);
       }
     }
@@ -99,6 +116,9 @@
     return new BufferedInputStream(new ByteArrayInputStream(out.toByteArray()));
   }
 
+  /* (non-Javadoc)
+   * @see org.apache.forrest.dispatcher.api.Contract#initializeFromStream(java.io.InputStream)
+   */
   public void initializeFromStream(InputStream stream)
       throws ContractException {
     // invoke the extraction



Mime
View raw message