You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by jo...@apache.org on 2007/06/24 01:52:38 UTC
svn commit: r550139 - in
/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components:
src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java
status.xml
Author: joerg
Date: Sat Jun 23 16:52:38 2007
New Revision: 550139
URL: http://svn.apache.org/viewvc?view=rev&rev=550139
Log:
COCOON-2077: Fixed getInputStream() in XModuleSource and QDoxSource: Set up XMLSerializer in a component way, i.e. retrieve it from ServiceManager.
Added:
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/status.xml (with props)
Modified:
cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java
Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java?view=diff&rev=550139&r1=550138&r2=550139
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/source/impl/XModuleSource.java Sat Jun 23 16:52:38 2007
@@ -39,7 +39,7 @@
import org.apache.cocoon.components.modules.input.InputModule;
import org.apache.cocoon.components.modules.output.OutputModule;
-import org.apache.cocoon.serialization.XMLSerializer;
+import org.apache.cocoon.serialization.Serializer;
import org.apache.cocoon.util.jxpath.DOMFactory;
import org.apache.cocoon.xml.dom.DOMBuilder;
import org.apache.cocoon.xml.dom.DOMStreamer;
@@ -80,6 +80,8 @@
protected ServiceManager manager;
private Map objectModel;
private Logger logger;
+ // TODO: make this actually configurable
+ private String configuredSerializerName = "xml";
/**
* Create a xmodule source from a 'xmodule:' uri and a the object model.
@@ -178,27 +180,34 @@
*
* @throws IOException if I/O error occured.
*/
- // Stolen from QDoxSource
public InputStream getInputStream() throws IOException, SourceException {
if ( this.logger.isDebugEnabled() ) {
this.logger.debug( "Getting InputStream for " + getURI() );
}
- // Serialize the SAX events to the XMLSerializer:
-
- XMLSerializer serializer = new XMLSerializer();
+ // Serialize the SAX events to the XMLSerializer
ByteArrayInputStream inputStream = null;
+ ServiceSelector selector = null;
+ Serializer serializer = null;
try {
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream( 2048 );
- serializer.setOutputStream( outputStream );
- toSAX( serializer );
- inputStream = new ByteArrayInputStream( outputStream.toByteArray() );
- } catch ( SAXException se ) {
- logger.error( "SAX exception!", se );
- throw new SourceException( "Serializing SAX to a ByteArray failed!", se );
- }
+ selector = (ServiceSelector)this.manager.lookup(Serializer.ROLE + "Selector");
+ serializer = (Serializer)selector.select(this.configuredSerializerName);
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(2048);
+ serializer.setOutputStream(outputStream);
+ toSAX(serializer);
+ inputStream = new ByteArrayInputStream(outputStream.toByteArray());
+ } catch (SAXException e) {
+ throw new SourceException("Serializing SAX to a ByteArray failed!", e);
+ } catch (ServiceException e) {
+ throw new SourceException("Retrieving serializer failed.", e);
+ } finally {
+ if (selector != null) {
+ selector.release(serializer);
+ this.manager.release(selector);
+ }
+ }
return inputStream;
}
@@ -368,8 +377,10 @@
throw new SAXException( "Could not find an attribute: " + attributeName +
" from the InputModule " + inputModuleName, e );
} finally {
- if ( inputModule != null ) selector.release( inputModule );
- this.manager.release( selector );
+ if ( selector != null ) {
+ selector.release( inputModule );
+ this.manager.release( selector );
+ }
}
return obj;
@@ -390,8 +401,10 @@
throw new SAXException( "Could not find an OutputModule of the type " +
outputModuleName , e );
} finally {
- if ( outputModule != null ) selector.release( outputModule );
- this.manager.release( selector );
+ if ( selector != null ) {
+ selector.release( outputModule );
+ this.manager.release( selector );
+ }
}
}
}
Added: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/status.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/status.xml?view=auto&rev=550139
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/status.xml (added)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/status.xml Sat Jun 23 16:52:38 2007
@@ -0,0 +1,76 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE status [
+<!ELEMENT status (developers?, todo?, changes)>
+<!ELEMENT developers (person+)>
+<!ELEMENT person EMPTY>
+<!ATTLIST person
+ name CDATA #REQUIRED
+ email CDATA #REQUIRED
+ id CDATA #REQUIRED
+>
+<!ELEMENT todo (actions+)>
+<!ELEMENT actions (action+)>
+<!ATTLIST actions
+ priority (high | medium | low) #REQUIRED
+>
+<!ELEMENT changes (release+)>
+<!ELEMENT release (action+)>
+<!ATTLIST release
+ version CDATA #REQUIRED
+ date CDATA #REQUIRED
+>
+<!ELEMENT action (#PCDATA | link | br | code | ul | strong)*>
+<!ATTLIST action
+ context (build | code | docs) #IMPLIED
+ assigned-to CDATA #IMPLIED
+ dev CDATA #IMPLIED
+ type (add | fix | remove | update) #IMPLIED
+ fixes-bug CDATA #IMPLIED
+ due-to CDATA #IMPLIED
+ due-to-email CDATA #IMPLIED
+>
+<!ELEMENT code (#PCDATA)>
+<!ELEMENT br EMPTY>
+<!ELEMENT strong (#PCDATA)>
+<!ELEMENT link (#PCDATA)>
+<!ATTLIST link
+ href CDATA #REQUIRED
+>
+<!ELEMENT ul (li)+>
+<!ELEMENT li (#PCDATA | link | br | code | ul)*>
+<!ENTITY eacute "é">
+<!ENTITY ouml "ö">
+<!ENTITY uuml "ü">
+<!ENTITY ccedil "ç">
+]>
+
+<!-- SVN $Id: status.xml 449177 2006-09-23 06:18:56Z crossley $ -->
+
+<status>
+ <changes>
+ <release version="@version@" date="@date@">
+ <action dev="JH" type="fix" fixes-bug="COCOON-2077" due-to="Ellis Pritchard">
+ Fixed getInputStream() in XModuleSource:
+ Set up XMLSerializer in a component way, i.e. retrieve it from ServiceManager.
+ </action>
+ </release>
+ </changes>
+
+</status>
+
Propchange: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/status.xml
------------------------------------------------------------------------------
svn:eol-style = native