cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/source CopletSource.java
Date Mon, 02 Feb 2004 08:39:09 GMT
cziegeler    2004/02/02 00:39:09

  Modified:    src/blocks/portal/java/org/apache/cocoon/portal/source
                        CopletSource.java
  Log:
  Implement streaming of coplets
  
  Revision  Changes    Path
  1.5       +29 -2     cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/source/CopletSource.java
  
  Index: CopletSource.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/source/CopletSource.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- CopletSource.java	20 Oct 2003 13:37:10 -0000	1.4
  +++ CopletSource.java	2 Feb 2004 08:39:09 -0000	1.5
  @@ -50,15 +50,23 @@
   */
   package org.apache.cocoon.portal.source;
   
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
   
  +import org.apache.avalon.framework.component.ComponentException;
  +import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.component.ComponentSelector;
   import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.ServiceSelector;
   import org.apache.avalon.framework.service.Serviceable;
  +import org.apache.cocoon.CascadingIOException;
  +import org.apache.cocoon.components.CocoonComponentManager;
   import org.apache.cocoon.portal.coplet.CopletInstanceData;
   import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
  +import org.apache.cocoon.serialization.Serializer;
   import org.apache.excalibur.source.Source;
   import org.apache.excalibur.source.SourceNotFoundException;
   import org.apache.excalibur.source.SourceValidity;
  @@ -105,7 +113,26 @@
   	 * @see org.apache.excalibur.source.Source#getInputStream()
   	 */
   	public InputStream getInputStream() throws IOException, SourceNotFoundException {
  -		return null;
  +        ComponentManager sitemapManager = CocoonComponentManager.getSitemapComponentManager();
  +        ComponentSelector serializerSelector = null;
  +        Serializer serializer = null;
  +        try {
  +            serializerSelector = (ComponentSelector) sitemapManager.lookup(Serializer.ROLE+"Selector");
  +            serializer = (Serializer) serializerSelector.select("html");
  +            ByteArrayOutputStream os = new ByteArrayOutputStream();
  +            serializer.setOutputStream(os);
  +            this.toSAX(serializer);
  +            return new ByteArrayInputStream(os.toByteArray());
  +        } catch (SAXException se) {
  +            throw new CascadingIOException("Unable to stream content.", se);
  +        } catch (ComponentException ce) {
  +            throw new CascadingIOException("Unable to get components for serializing.",
ce);
  +        } finally {
  +            if ( serializer != null ) {
  +                serializerSelector.release(serializer);
  +            }
  +            sitemapManager.release(serializerSelector);
  +        }
   	}
   
   	/**
  
  
  

Mime
View raw message