From svn-return-8057-apmail-forrest-svn-archive=forrest.apache.org@forrest.apache.org Thu Oct 02 12:32:07 2008 Return-Path: Delivered-To: apmail-forrest-svn-archive@www.apache.org Received: (qmail 36420 invoked from network); 2 Oct 2008 12:32:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Oct 2008 12:32:07 -0000 Received: (qmail 99253 invoked by uid 500); 2 Oct 2008 12:32:06 -0000 Delivered-To: apmail-forrest-svn-archive@forrest.apache.org Received: (qmail 99209 invoked by uid 500); 2 Oct 2008 12:32:06 -0000 Mailing-List: contact svn-help@forrest.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Forrest Developers List" List-Id: Delivered-To: mailing list svn@forrest.apache.org Received: (qmail 99200 invoked by uid 99); 2 Oct 2008 12:32:06 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Oct 2008 05:32:06 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Oct 2008 12:31:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5E41723889B7; Thu, 2 Oct 2008 05:31:16 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r701105 - /forrest/branches/dispatcher_rewrite/plugins/org.apache.forrest.plugin.internal.dispatcher/src/java/org/apache/forrest/dispatcher/transformation/DispatcherTransformer.java Date: Thu, 02 Oct 2008 12:31:16 -0000 To: svn@forrest.apache.org From: thorsten@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081002123116.5E41723889B7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: thorsten Date: Thu Oct 2 05:31:15 2008 New Revision: 701105 URL: http://svn.apache.org/viewvc?rev=701105&view=rev Log: FOR-1118 Parsing the resulting stream to the xmlconsumer. This way it is present in further processing. 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=701105&r1=701104&r2=701105&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 2 05:31:15 2008 @@ -19,12 +19,14 @@ import java.io.BufferedInputStream; import java.io.ByteArrayInputStream; import java.io.IOException; +import java.io.InputStream; import java.io.Serializable; import java.util.Map; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; @@ -35,14 +37,14 @@ import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceValidity; import org.apache.excalibur.source.impl.validity.AggregatedValidity; -import org.apache.excalibur.xml.sax.XMLizable; +import org.apache.excalibur.xml.sax.SAXParser; import org.apache.forrest.dispatcher.api.Structurer; import org.apache.forrest.dispatcher.config.DispatcherBean; -import org.apache.forrest.dispatcher.exception.DispatcherException; import org.apache.forrest.dispatcher.impl.CocoonResolver; import org.apache.forrest.dispatcher.impl.XMLStructurer; import org.apache.forrest.dispatcher.impl.XMLStructurerAxiom; import org.apache.forrest.dispatcher.impl.helper.Captions; +import org.xml.sax.InputSource; import org.xml.sax.SAXException; public class DispatcherTransformer extends AbstractSAXTransformer implements @@ -71,6 +73,8 @@ */ private String xpathSupport; + private Logger log; + public static final String PATH_PARAMETER = "path"; public static final String DISPATCHER_REQUEST_ATTRIBUTE = "request"; @@ -111,10 +115,10 @@ this.requestId = parameters .getParameter(DISPATCHER_REQUEST_ATTRIBUTE, null); this.cacheKey = parameters.getParameter(CACHE_PARAMETER, null); + log = getLogger(); if (null == this.cacheKey) - getLogger().warn( - "Caching not activated! Declare the CACHE_KEY_PARAMETER=" - + CACHE_PARAMETER + " in your sitemap."); + log.warn("Caching not activated! Declare the CACHE_KEY_PARAMETER=" + + CACHE_PARAMETER + " in your sitemap."); this.validityFile = parameters.getParameter(VALIDITY_PARAMETER, null); this.validityOverride = parameters.getParameter( VALIDITY_OVERRIDE_PARAMETER, ""); @@ -123,14 +127,14 @@ if (requestId == null) { String error = "dispatcherError:\n" + "You have to set the \"request\" parameter in the sitemap!"; - getLogger().error(error); + log.error(error); throw new ProcessingException(error); } this.requestedFormat = parameters.getParameter(Captions.TYPE_ATT, null); if (requestedFormat == null) { String error = "dispatcherError:\n" + "You have to set the \"type\" parameter in the sitemap!"; - getLogger().error(error); + log.error(error); throw new ProcessingException(error); } if (null == m_resolver) @@ -145,12 +149,10 @@ } public void startDocument() throws SAXException { - super.startDocument(); startSerializedXMLRecording(null); } public void endDocument() throws SAXException { - super.endDocument(); String document = null; try { document = super.endSerializedXMLRecording(); @@ -163,11 +165,19 @@ } else { structurer = new XMLStructurer(config); } + SAXParser parser = null; try { - structurer.execute(new BufferedInputStream(new ByteArrayInputStream( - document.getBytes())), requestedFormat); - } catch (DispatcherException e) { + InputStream result = structurer.execute(new BufferedInputStream( + new ByteArrayInputStream(document.getBytes())), requestedFormat); + // adding the result to the consumer + parser = (SAXParser) manager.lookup(SAXParser.ROLE); + parser.parse(new InputSource(result), super.xmlConsumer); + } catch (Exception e) { throw new SAXException(e); + } finally { + if (null != parser) { + manager.release(parser); + } } }