cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject svn commit: r550140 - in /cocoon/branches/BRANCH_2_1_X: src/blocks/qdox/java/org/apache/cocoon/components/source/impl/QDoxSource.java src/java/org/apache/cocoon/components/source/impl/XModuleSource.java status.xml
Date Sat, 23 Jun 2007 23:57:37 GMT
Author: joerg
Date: Sat Jun 23 16:57:36 2007
New Revision: 550140

URL: http://svn.apache.org/viewvc?view=rev&rev=550140
Log:
COCOON-2077: Fixed getInputStream() in XModuleSource and QDoxSource: Set up XMLSerializer
in a component way, i.e. retrieve it from ServiceManager.

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/qdox/java/org/apache/cocoon/components/source/impl/QDoxSource.java
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/XModuleSource.java
    cocoon/branches/BRANCH_2_1_X/status.xml

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/qdox/java/org/apache/cocoon/components/source/impl/QDoxSource.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/blocks/qdox/java/org/apache/cocoon/components/source/impl/QDoxSource.java?view=diff&rev=550140&r1=550139&r2=550140
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/qdox/java/org/apache/cocoon/components/source/impl/QDoxSource.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/qdox/java/org/apache/cocoon/components/source/impl/QDoxSource.java
Sat Jun 23 16:57:36 2007
@@ -42,7 +42,8 @@
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.cocoon.serialization.XMLSerializer;
+import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.serialization.Serializer;
 import org.apache.cocoon.xml.XMLUtils;
 
 import org.apache.commons.lang.StringUtils;
@@ -134,6 +135,9 @@
      */
     protected RE reLink;
 
+    // TODO: make this actually configurable
+    private String configuredSerializerName;
+
     /**
      * Contains a regular expression to match the <code>{</code><code>@link
&hellip;}</code> occurrances.
      *
@@ -346,20 +350,32 @@
      * @see org.apache.excalibur.source.Source#getInputStream()
      */
     public InputStream getInputStream() throws IOException, SourceException {
-        if (logger.isDebugEnabled()) {
-            logger.debug("Getting InputStream for class " + javadocClass.getFullyQualifiedName());
+        if (this.logger.isDebugEnabled()) {
+            this.logger.debug("Getting InputStream for class " + this.javadocClass.getFullyQualifiedName());
         }
-        XMLSerializer serializer = new XMLSerializer();
+
+        // Serialize the SAX events to the XMLSerializer
         ByteArrayInputStream inputStream = null;
 
+        ServiceSelector selector = null;
+        Serializer serializer = null;
         try {
+            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 se) {
-            logger.error("SAX exception!", se);
-            throw new SourceException("Serializing SAX to a ByteArray failed!", se);
+        } 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;
     }
@@ -764,7 +780,7 @@
      */
     private void outputComment(ContentHandler handler, String comment) throws SAXException
{
         if (comment != null && comment.length() > 0) {
-                saxStartElement(handler, COMMENT_ELEMENT);
+            saxStartElement(handler, COMMENT_ELEMENT);
             while (reLink.match(comment)) {
                 String ref = null;
                 String display = null;

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/XModuleSource.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/XModuleSource.java?view=diff&rev=550140&r1=550139&r2=550140
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/XModuleSource.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/source/impl/XModuleSource.java
Sat Jun 23 16:57:36 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;
@@ -70,7 +70,6 @@
  *
  * @author <a href="mailto:danielf@nada.kth.se">Daniel Fagerstom</a>
  */
-
 public class XModuleSource
     extends AbstractSource
     implements ModifiableSource, XMLizable, DOMBuilder.Listener {
@@ -82,6 +81,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.
@@ -180,27 +181,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;
     }
 
@@ -370,8 +378,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;
@@ -392,8 +402,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 );
+            }
         }
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/status.xml
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/status.xml?view=diff&rev=550140&r1=550139&r2=550140
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/status.xml (original)
+++ cocoon/branches/BRANCH_2_1_X/status.xml Sat Jun 23 16:57:36 2007
@@ -182,6 +182,10 @@
 
   <changes>
   <release version="2.1.11" date="TBD">
+    <action dev="JH" type="fix" fixes-bug="COCOON-2077" due-to="Ellis Pritchard">
+      Core, QDox: Fixed getInputStream() in XModuleSource and QDoxSource:
+      Set up XMLSerializer in a component way, i.e. retrieve it from ServiceManager.
+    </action>
     <action dev="GK" type="update" fixes-bug="COCOON-2073" due-to="Alexander Klimetschek"
due-to-email="alexander.klimetschek@mindquarry.com">
       Dojo toolkit upgraded to 0.4.3 version. It contains fix for security bug. See http://dojotoolkit.org/releaseNotes/0.4.3.
     </action>
@@ -196,7 +200,7 @@
       Core: Update log4j to 1.2.14, commons-io to 1.3.1, commons-lang to 2.3 and jakarta-regexp
to 1.5.
     </action>
     <action dev="AG" type="fix" fixes-bug="COCOON-2023" due-to="Larry Ruiz" due-to-email="lruiz@agssa.net">
-      CForms: MultivalueEditorWihtSuggestion doesn't add values to the listbox on Internet
Explorer.
+      CForms: MultivalueEditorWithSuggestion doesn't add values to the listbox on Internet
Explorer.
     </action>
     <action dev="VG" type="fix">
       CForms: Submit widget now inherits validate attribute value from the



Mime
View raw message