cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/lib jars.xml
Date Wed, 20 Nov 2002 14:53:22 GMT
cziegeler    2002/11/20 06:53:22

  Modified:    src/java/org/apache/cocoon/components Tag:
                        cocoon_2_0_3_branch CocoonComponentManager.java
               src/java/org/apache/cocoon/components/source Tag:
                        cocoon_2_0_3_branch SitemapSource.java
               lib      Tag: cocoon_2_0_3_branch jars.xml
  Added:       src/java/org/apache/cocoon/components Tag:
                        cocoon_2_0_3_branch EnvironmentStack.java
               lib/core Tag: cocoon_2_0_3_branch
                        commons-collections-2.1.jar
  Removed:     lib/core Tag: cocoon_2_0_3_branch
                        commons-collections-1.0.jar
  Log:
  Removing the intermediate buffering for the cocoon protocol
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.13.2.5  +24 -18    xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java
  
  Index: CocoonComponentManager.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/CocoonComponentManager.java,v
  retrieving revision 1.13.2.4
  retrieving revision 1.13.2.5
  diff -u -r1.13.2.4 -r1.13.2.5
  --- CocoonComponentManager.java	20 Nov 2002 11:21:49 -0000	1.13.2.4
  +++ CocoonComponentManager.java	20 Nov 2002 14:53:21 -0000	1.13.2.5
  @@ -56,7 +56,6 @@
   import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
  -import java.util.Stack;
   import org.apache.avalon.excalibur.component.ExcaliburComponentManager;
   import org.apache.avalon.framework.component.Component;
   import org.apache.avalon.framework.component.ComponentException;
  @@ -123,9 +122,9 @@
                                           Map         objectModel,
                                           Processor   processor) {
           if (environmentStack.get() == null) {
  -            environmentStack.set(new Stack());
  +            environmentStack.set(new EnvironmentStack());
           }
  -        final Stack stack = (Stack)environmentStack.get();
  +        final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           stack.push(new Object[] {env, processor});
           
           EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
  @@ -139,7 +138,7 @@
        * This hook must be called by the sitemap each time a sitemap is left
        */
       public static void leaveEnvironment() {
  -        final Stack stack = (Stack)environmentStack.get();
  +        final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           if (null != stack && !stack.empty()) {
               final Object[] objects = (Object[])stack.pop();
               EnvironmentDescription desc = (EnvironmentDescription)((Environment)objects[0]).getObjectModel().get(PROCESS_KEY);
  @@ -178,9 +177,9 @@
        * Return the current environment (for the cocoon: protocol)
        */
       public static Environment getCurrentEnvironment() {
  -        final Stack stack = (Stack)environmentStack.get();
  +        final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           if (null != stack && !stack.empty()) {
  -            return (Environment) ((Object[])stack.peek())[0];
  +            return (Environment) ((Object[])stack.getCurrent())[0];
           }
           return null;
       }
  @@ -189,23 +188,30 @@
        * Return the current processor (for the cocoon: protocol)
        */
       public static Processor getCurrentProcessor() {
  -        final Stack stack = (Stack)environmentStack.get();
  +        final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           if (null != stack && !stack.empty()) {
  -            return (Processor) ((Object[])stack.peek())[1];
  +            return (Processor) ((Object[])stack.getCurrent())[1];
           }
           return null;
       }
   
       /**
  +     * Return the current environment stack (for the cocoon: protocol)
  +     */
  +    public static EnvironmentStack getCurrentEnvironmentStack() {
  +        return (EnvironmentStack)environmentStack.get();
  +    }
  +
  +    /**
        * Return an instance of a component based on a Role.  The Role is usually the Interface's
        * Fully Qualified Name(FQN)--unless there are multiple Components for the same Role.
 In that
        * case, the Role's FQN is appended with "Selector", and we return a ComponentSelector.
        */
       public Component lookup( final String role )
       throws ComponentException {
  -        final Stack stack = (Stack)environmentStack.get();
  +        final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           if ( null != stack && !stack.empty()) {
  -            final Object[] objects = (Object[])stack.peek();
  +            final Object[] objects = (Object[])stack.getCurrent();
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
               EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
  @@ -221,7 +227,7 @@
               if (stack == null || stack.empty()) {
                   throw new ComponentException("ComponentManager has no Environment Stack.");
               }
  -            final Object[] objects = (Object[]) stack.peek();
  +            final Object[] objects = (Object[]) stack.getCurrent();
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
               EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
  @@ -266,9 +272,9 @@
                                                          final Component         component,
                                                          final ComponentManager  manager)
       throws ProcessingException {
  -        final Stack stack = (Stack)environmentStack.get();
  +        final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           if ( null != stack && !stack.empty()) {
  -            final Object[] objects = (Object[])stack.firstElement();
  +            final Object[] objects = (Object[])stack.get(0);
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
               EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
  @@ -285,9 +291,9 @@
       public static void addComponentForAutomaticRelease(final ComponentManager manager,
                                                          final Component        component)
       throws ProcessingException {
  -        final Stack stack = (Stack)environmentStack.get();
  +        final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           if ( null != stack && !stack.empty()) {
  -            final Object[] objects = (Object[])stack.firstElement();
  +            final Object[] objects = (Object[])stack.get(0);
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
               EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
  @@ -303,9 +309,9 @@
        */
       public static void removeFromAutomaticRelease(final Component component)
       throws ProcessingException {
  -        final Stack stack = (Stack)environmentStack.get();
  +        final EnvironmentStack stack = (EnvironmentStack)environmentStack.get();
           if ( null != stack && !stack.empty()) {
  -            final Object[] objects = (Object[])stack.firstElement();
  +            final Object[] objects = (Object[])stack.get(0);
               final Map objectModel = ((Environment)objects[0]).getObjectModel();
               EnvironmentDescription desc = (EnvironmentDescription)objectModel.get(PROCESS_KEY);
               if ( null != desc ) {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +87 -0     xml-cocoon2/src/java/org/apache/cocoon/components/Attic/EnvironmentStack.java
  
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.1   +0 -0      xml-cocoon2/lib/core/commons-collections-2.1.jar
  
  	<<Binary file>>
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.9.2.5   +166 -25   xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java
  
  Index: SitemapSource.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java,v
  retrieving revision 1.9.2.4
  retrieving revision 1.9.2.5
  diff -u -r1.9.2.4 -r1.9.2.5
  --- SitemapSource.java	20 Nov 2002 11:21:49 -0000	1.9.2.4
  +++ SitemapSource.java	20 Nov 2002 14:53:22 -0000	1.9.2.5
  @@ -56,11 +56,10 @@
   import org.apache.cocoon.Processor;
   import org.apache.cocoon.caching.PipelineCacheKey;
   import org.apache.cocoon.components.CocoonComponentManager;
  +import org.apache.cocoon.components.EnvironmentStack;
   import org.apache.cocoon.components.pipeline.CacheableEventPipeline;
   import org.apache.cocoon.components.pipeline.EventPipeline;
   import org.apache.cocoon.components.pipeline.StreamPipeline;
  -import org.apache.cocoon.components.sax.XMLDeserializer;
  -import org.apache.cocoon.components.sax.XMLSerializer;
   import org.apache.cocoon.environment.Environment;
   import org.apache.cocoon.environment.ModifiableSource;
   import org.apache.cocoon.environment.Source;
  @@ -71,8 +70,10 @@
   import org.apache.cocoon.xml.XMLConsumer;
   import org.apache.cocoon.xml.XMLProducer;
   import org.apache.log.Logger;
  +import org.xml.sax.Attributes;
   import org.xml.sax.ContentHandler;
   import org.xml.sax.InputSource;
  +import org.xml.sax.Locator;
   import org.xml.sax.SAXException;
   import org.xml.sax.ext.LexicalHandler;
   
  @@ -357,38 +358,30 @@
               throw this.exception;
           }
           try {
  -            XMLConsumer consumer;
  -            if (contentHandler instanceof XMLConsumer) {
  -                consumer = (XMLConsumer)contentHandler;
  -            } else if (contentHandler instanceof LexicalHandler) {
  -                consumer = new ContentHandlerWrapper(contentHandler, (LexicalHandler)contentHandler);
  -            } else {
  -                consumer = new ContentHandlerWrapper(contentHandler);
  -            }
               if (this.redirectSource != null) {
  -                this.redirectSource.toSAX(consumer);
  +                this.redirectSource.toSAX(contentHandler);
               } else {
  -                // We have to buffer the result in order to get
  +                XMLConsumer consumer;
  +                if (contentHandler instanceof XMLConsumer) {
  +                    consumer = (XMLConsumer)contentHandler;
  +                } else if (contentHandler instanceof LexicalHandler) {
  +                    consumer = new ContentHandlerWrapper(contentHandler, (LexicalHandler)contentHandler);
  +                } else {
  +                    consumer = new ContentHandlerWrapper(contentHandler);
  +                }
  +                // We have to add an environment changer
                   // clean environment stack handling.
  -                XMLSerializer xmls = (XMLSerializer) this.manager.lookup(XMLSerializer.ROLE);
  -                Object fragment;
  +                EnvironmentStack envStack = CocoonComponentManager.getCurrentEnvironmentStack();
  +                int currentOffset = envStack.getOffset();
                   try {
                       CocoonComponentManager.enterEnvironment(this.environment,
                                                               this.environment.getObjectModel(),
                                                               this.pipelineProcessor);
  -                    ((XMLProducer)eventPipeline).setConsumer(xmls);
  +                    ((XMLProducer)eventPipeline).setConsumer(new EnvironmentChanger(consumer,
envStack));
                       eventPipeline.process(this.environment);
  -                    fragment = xmls.getSAXFragment();
                   } finally {
  -                    this.manager.release(xmls);
                       CocoonComponentManager.leaveEnvironment();
  -                }
  -                XMLDeserializer xmld = (XMLDeserializer) this.manager.lookup(XMLDeserializer.ROLE);
  -                try {
  -                    xmld.setConsumer(consumer);
  -                    xmld.deserialize(fragment);
  -                } finally {
  -                    this.manager.release(xmld);
  +                    envStack.resetOffset(currentOffset);
                   }
               }
           } catch (ComponentException cme) {
  @@ -425,3 +418,151 @@
           reset();
       }
   }
  +
  +
  +/**
  + * This class is an {@link XMLConsumer} that changes the current environment.
  + * When a pipeline calls an internal pipeline, two environments are
  + * established: one for the calling pipeline and one for the internal pipeline.
  + * Now, if SAX events are send from the internal pipeline, they are
  + * received by some component of the calling pipeline, so inbetween we
  + * have to change the environment forth and back.
  + */
  +final class EnvironmentChanger
  +implements XMLConsumer {
  +
  +    final XMLConsumer consumer;
  +    final EnvironmentStack stack;
  +    
  +    EnvironmentChanger(XMLConsumer consumer, EnvironmentStack es) {
  +        this.consumer = consumer;
  +        this.stack = es;
  +    }
  +    
  +    public void setDocumentLocator(Locator locator) {
  +        this.stack.incOffset();
  +        this.consumer.setDocumentLocator(locator);
  +        this.stack.decOffset();
  +    }
  +
  +    public void startDocument()
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.startDocument();
  +        this.stack.decOffset();
  +    }
  +
  +    public void endDocument()
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.endDocument();
  +        this.stack.decOffset();
  +    }
  +
  +    public void startPrefixMapping(String prefix, String uri)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.startPrefixMapping(prefix, uri);
  +        this.stack.decOffset();
  +    }
  +
  +    public void endPrefixMapping(String prefix)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.endPrefixMapping(prefix);
  +        this.stack.decOffset();
  +    }
  +
  +    public void startElement(String uri, String loc, String raw, Attributes a)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.startElement(uri, loc, raw, a);
  +        this.stack.decOffset();
  +    }
  +
  +
  +    public void endElement(String uri, String loc, String raw)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.endElement(uri, loc, raw);
  +        this.stack.decOffset();
  +    }
  +    
  +    public void characters(char c[], int start, int len)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.characters(c, start, len);
  +        this.stack.decOffset();
  +    }
  +
  +    public void ignorableWhitespace(char c[], int start, int len)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.ignorableWhitespace(c, start, len);
  +        this.stack.decOffset();
  +    }
  +
  +    public void processingInstruction(String target, String data)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.processingInstruction(target, data);
  +        this.stack.decOffset();
  +    }
  +
  +    public void skippedEntity(String name)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.skippedEntity(name);
  +        this.stack.decOffset();
  +    }
  +
  +    public void startDTD(String name, String publicId, String systemId)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.startDTD(name, publicId, systemId);
  +        this.stack.decOffset();
  +    }
  +
  +    public void endDTD()
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.endDTD();
  +        this.stack.decOffset();
  +    }
  +
  +    public void startEntity(String name)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.startEntity(name);
  +        this.stack.decOffset();
  +    }
  +
  +    public void endEntity(String name)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.endEntity(name);
  +        this.stack.decOffset();
  +    }
  +
  +    public void startCDATA()
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.startCDATA();
  +        this.stack.decOffset();
  +    }
  +
  +    public void endCDATA()
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.endCDATA();
  +        this.stack.decOffset();
  +    }
  +
  +    public void comment(char ch[], int start, int len)
  +    throws SAXException {
  +        this.stack.incOffset();
  +        this.consumer.comment(ch, start, len);
  +        this.stack.decOffset();
  +    }
  +}
  +
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.11.2.15 +1 -1      xml-cocoon2/lib/jars.xml
  
  Index: jars.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/lib/jars.xml,v
  retrieving revision 1.11.2.14
  retrieving revision 1.11.2.15
  diff -u -r1.11.2.14 -r1.11.2.15
  --- jars.xml	20 Nov 2002 12:35:18 -0000	1.11.2.14
  +++ jars.xml	20 Nov 2002 14:53:22 -0000	1.11.2.15
  @@ -36,7 +36,7 @@
   	<title>Jakarta Commons Collections</title>
   	<description>Common implementations of collection classes.</description>
   	<used-by>Cocoon</used-by>
  -	<lib>core/commons-collections-1.0.jar</lib>
  +	<lib>core/commons-collections-2.1.jar</lib>
   	<homepage>http://jakarta.apache.org/commons/collections.html</homepage>
    </file>
    <file>
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message