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/src/java/org/apache/cocoon/components/language/markup/sitemap SitemapMarkupLanguage.java
Date Mon, 29 Apr 2002 12:53:17 GMT
cziegeler    02/04/29 05:53:17

  Modified:    src/java/org/apache/cocoon/components/language/markup
                        AbstractMarkupLanguage.java
                        CocoonMarkupLanguage.java Logicsheet.java
                        MarkupLanguage.java NamedLogicsheet.java
               src/java/org/apache/cocoon/components/language/markup/sitemap
                        SitemapMarkupLanguage.java
  Log:
  Some upgrades to the new source resolving
  
  Revision  Changes    Path
  1.16      +34 -34    xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/AbstractMarkupLanguage.java
  
  Index: AbstractMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/AbstractMarkupLanguage.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- AbstractMarkupLanguage.java	22 Feb 2002 07:00:07 -0000	1.15
  +++ AbstractMarkupLanguage.java	29 Apr 2002 12:53:16 -0000	1.16
  @@ -63,14 +63,13 @@
   import org.apache.avalon.framework.parameters.Parameters;
   
   import org.apache.avalon.excalibur.pool.Recyclable;
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceResolver;
   
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
   import org.apache.cocoon.components.store.Store;
  -import org.apache.cocoon.components.url.URLFactory;
  -import org.apache.cocoon.environment.Source;
  -import org.apache.cocoon.environment.SourceResolver;
  -import org.apache.cocoon.environment.URLFactorySourceResolver;
   import org.apache.cocoon.util.HashMap;
   
   import org.xml.sax.Attributes;
  @@ -97,7 +96,7 @@
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
  - * @version CVS $Id: AbstractMarkupLanguage.java,v 1.15 2002/02/22 07:00:07 cziegeler Exp
$
  + * @version CVS $Id: AbstractMarkupLanguage.java,v 1.16 2002/04/29 12:53:16 cziegeler Exp
$
    */
   public abstract class AbstractMarkupLanguage
           extends AbstractLoggable
  @@ -128,11 +127,8 @@
       /** The component manager */
       protected ComponentManager manager;
   
  -    /** The URL factory to create source resolver */
  -    private URLFactory urlFactory;
  -
       /** The URL factory source resolver used to resolve URIs */
  -    private URLFactorySourceResolver urlResolver;
  +    private SourceResolver resolver;
   
   
       /**
  @@ -206,14 +202,14 @@
               String prefix = params.getParameter("prefix", null);
   
               NamedLogicsheet namedLogicsheet =
  -                new NamedLogicsheet(location, manager, urlResolver);
  +                new NamedLogicsheet(location, manager, resolver);
               namedLogicsheet.setLogger(getLogger());
               namedLogicsheet.setURI(uri);
               namedLogicsheet.setPrefix(prefix);
               logicsheet = namedLogicsheet;
           } else {
               String location = params.getParameter("core-logicsheet", null);
  -            logicsheet = new Logicsheet(location, manager, urlResolver);
  +            logicsheet = new Logicsheet(location, manager, resolver);
               logicsheet.setLogger(getLogger());
           }
   
  @@ -233,16 +229,14 @@
           // Initialize logicsheet cache
           this.logicsheetCache = (Store) manager.lookup(Store.TRANSIENT_CACHE);
   
  -        // Initialize the URL factory source resolver
  -        this.urlFactory = (URLFactory)this.manager.lookup(URLFactory.ROLE);
  -        this.urlResolver = new URLFactorySourceResolver(this.urlFactory, manager);
  +        // Initialize the source resolver
  +        this.resolver = (SourceResolver)this.manager.lookup(SourceResolver.ROLE);
       }
   
       /**
        * Recycle this component: clear logic sheet list and dependencies.
        */
  -    public void recycle()
  -    {
  +    public void recycle() {
           this.logicSheetList.clear();
       }
   
  @@ -250,14 +244,11 @@
        * Release all resources.
        */
       public void dispose() {
  -        if (this.logicsheetCache != null)
  -            this.manager.release(this.logicsheetCache);
  +        this.manager.release(this.logicsheetCache);
           this.logicsheetCache = null;
   
  -        if (this.urlFactory != null)
  -            this.manager.release(this.urlFactory);
  -        this.urlFactory = null;
  -        this.urlResolver = null;
  +        this.manager.release(this.resolver);
  +        this.resolver = null;
           this.manager = null;
           this.languages.clear();
       }
  @@ -364,7 +355,9 @@
        * @return The generated source code
        * @exception Exception If an error occurs during code generation
        */
  -    public String generateCode(InputSource input, String filename, ProgrammingLanguage
programmingLanguage,
  +    public String generateCode(InputSource input,
  +                               String filename,
  +                               ProgrammingLanguage programmingLanguage,
                                  SourceResolver resolver) throws Exception {
   
           String languageName = programmingLanguage.getLanguageName();
  @@ -433,17 +426,24 @@
       {
           Logicsheet logicsheet = (Logicsheet)logicsheetCache.get(CACHE_PREFIX + logicsheetLocation);
           if (logicsheet == null) {
  -            // Logicsheet is reusable (across multiple XSPs) object,
  -            // and it is resolved via urlResolver, and not via per-request
  -            // temporary resolver.
  -            Source inputSource = this.urlResolver.resolve(logicsheetLocation);
  -
  -            // Resolver (local) could not be used as it is temporary
  -            // (per-request) object, yet Logicsheet is being cached and reused
  -            // across multiple requests. "Global" url-factory-based resolver
  -            // passed to the Logicsheet.
  -            logicsheet = new Logicsheet(inputSource, manager, this.urlResolver);
  -            logicsheetCache.store(CACHE_PREFIX + logicsheet.getSystemId(), logicsheet);
  +            Source inputSource = null;
  +            try {
  +                // Logicsheet is reusable (across multiple XSPs) object,
  +                // and it is resolved via urlResolver, and not via per-request
  +                // temporary resolver.
  +                inputSource = this.resolver.resolveURI(logicsheetLocation);
  +
  +                // Resolver (local) could not be used as it is temporary
  +                // (per-request) object, yet Logicsheet is being cached and reused
  +                // across multiple requests. "Global" url-factory-based resolver
  +                // passed to the Logicsheet.
  +                logicsheet = new Logicsheet(inputSource, manager, this.resolver);
  +                logicsheetCache.store(CACHE_PREFIX + logicsheet.getSystemId(), logicsheet);
  +            } catch (SourceException se) {
  +                throw new ProcessingException(se);
  +            } finally {
  +                this.resolver.release( inputSource );
  +            }
           }
           String logicsheetName = logicsheet.getSystemId();
   
  
  
  
  1.6       +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/CocoonMarkupLanguage.java
  
  Index: CocoonMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/CocoonMarkupLanguage.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CocoonMarkupLanguage.java	20 Apr 2002 03:38:34 -0000	1.5
  +++ CocoonMarkupLanguage.java	29 Apr 2002 12:53:16 -0000	1.6
  @@ -54,7 +54,7 @@
   
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.SourceResolver;
   
   import org.apache.log.Logger;
   import org.xml.sax.Attributes;
  @@ -81,7 +81,7 @@
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
    * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
  - * @version CVS $Id: CocoonMarkupLanguage.java,v 1.5 2002/04/20 03:38:34 vgritsenko Exp
$
  + * @version CVS $Id: CocoonMarkupLanguage.java,v 1.6 2002/04/29 12:53:16 cziegeler Exp
$
    */
   public abstract class CocoonMarkupLanguage extends AbstractMarkupLanguage
   {
  
  
  
  1.11      +47 -22    xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/Logicsheet.java
  
  Index: Logicsheet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/Logicsheet.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Logicsheet.java	29 Apr 2002 10:52:52 -0000	1.10
  +++ Logicsheet.java	29 Apr 2002 12:53:17 -0000	1.11
  @@ -55,8 +55,9 @@
   import org.apache.avalon.framework.logger.AbstractLoggable;
   
   import org.apache.cocoon.components.xslt.XSLTProcessor;
  -import org.apache.cocoon.environment.Source;
  -import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
  +import org.apache.excalibur.source.SourceResolver;
   import org.apache.cocoon.ProcessingException;
   
   import org.xml.sax.Attributes;
  @@ -83,52 +84,55 @@
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
  - * @version CVS $Id: Logicsheet.java,v 1.10 2002/04/29 10:52:52 cziegeler Exp $
  + * @version CVS $Id: Logicsheet.java,v 1.11 2002/04/29 12:53:17 cziegeler Exp $
    */
   public class Logicsheet extends AbstractLoggable
   {
       /**
  -     * The Source object for this logicsheet.
  +     * The Source Resolver object for this logicsheet.
        */
  -    private Source source;
  +    private SourceResolver resolver;
   
       /**
  -     * the template namespace's list
  +     * The system id to resolve
        */
  -    protected Map namespaceURIs = new HashMap();
  +    private String systemId;
   
       /**
  -     * The {@link org.apache.cocoon.components.xslt.XSLTProcessor} component.
  +     * the template namespace's list
        */
  -    private XSLTProcessor xsltProcessor;
  +    protected Map namespaceURIs = new HashMap();
   
       /**
        * The ComponentManager of this instance.
        */
       private ComponentManager manager;
   
  -
       public Logicsheet(Source source, ComponentManager manager, SourceResolver resolver)
  -        throws ProcessingException
  +        throws SAXException, IOException, ProcessingException
       {
  -        this.source = source;
  +        this.resolver = resolver;
  +        this.systemId = source.getSystemId();
           this.manager = manager;
  -        try {
  -            this.xsltProcessor = (XSLTProcessor)this.manager.lookup(XSLTProcessor.ROLE);
  -        } catch (ComponentException e) {
  -            throw new ProcessingException("Could not obtain XSLT processor", e);
  -        }
       }
   
       public Logicsheet(String systemId, ComponentManager manager, SourceResolver resolver)
  -        throws SAXException, IOException, ProcessingException
  +        throws SAXException, IOException, SourceException, ProcessingException
       {
  -        this(resolver.resolve(systemId), manager, resolver);
  +        this.resolver = resolver;
  +        this.manager = manager;
  +        Source source = null;
  +        try {
  +            source = this.resolver.resolveURI( systemId );
  +            this.systemId = source.getSystemId();
  +        } finally {
  +            this.resolver.release( source );
  +        }
       }
   
       public String getSystemId()
       {
  -        return source.getSystemId();
  +        return this.systemId;
       }
   
       /**
  @@ -150,16 +154,37 @@
        */
       public TransformerHandler getTransformerHandler() throws ProcessingException
       {
  +        XSLTProcessor xsltProcessor = null;
  +        Source source = null;
           try {
  +            xsltProcessor = (XSLTProcessor)this.manager.lookup(XSLTProcessor.ROLE);
  +            source = this.resolver.resolveURI( this.systemId );
  +
               // If the Source object is not changed, the
               // getTransformerHandler() of XSLTProcessor will simply return
               // the old template object. If the Source is unchanged, the
               // namespaces are not modified either.
               XMLFilter saveNSFilter = new SaveNamespaceFilter(namespaceURIs);
  -            return xsltProcessor.getTransformerHandler(source, saveNSFilter);
  +            // FIXME: The wrapping will disappear as soon as we use excaliburs xslt processor
  +            Object[] env = org.apache.cocoon.components.CocoonComponentManager.getCurrentEnvironment();
  +            return xsltProcessor.getTransformerHandler(
  +               new org.apache.cocoon.components.source.impl.AvalonToCocoonSource(source,
  +                                                                                 this.resolver,
  +                                                                                 (org.apache.cocoon.environment.Environment)env[0]),
  +               saveNSFilter);
  +
  +        } catch (ComponentException e) {
  +            throw new ProcessingException("Could not obtain XSLT processor", e);
  +        } catch (MalformedURLException e) {
  +            throw new ProcessingException("Could not resolve " + this.systemId, e);
  +        } catch (IOException e) {
  +            throw new ProcessingException("Could not resolve " + this.systemId, e);
  +        } catch (SourceException e) {
  +            throw new ProcessingException("Could not resolve " + this.systemId, e);
           } finally {
  +            this.manager.release(xsltProcessor);
               // Release used resources
  -            source.recycle();
  +            this.resolver.release( source );
           }
       }
   
  
  
  
  1.6       +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/MarkupLanguage.java
  
  Index: MarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/MarkupLanguage.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- MarkupLanguage.java	22 Feb 2002 07:00:08 -0000	1.5
  +++ MarkupLanguage.java	29 Apr 2002 12:53:17 -0000	1.6
  @@ -52,7 +52,7 @@
   
   import org.apache.avalon.framework.component.Component;
   import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.SourceResolver;
   import org.xml.sax.InputSource;
   
   /**
  @@ -61,7 +61,7 @@
    * document augmenting it with dynamic content
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
  - * @version CVS $Id: MarkupLanguage.java,v 1.5 2002/02/22 07:00:08 cziegeler Exp $
  + * @version CVS $Id: MarkupLanguage.java,v 1.6 2002/04/29 12:53:17 cziegeler Exp $
    */
   public interface MarkupLanguage extends Component {
   
  
  
  
  1.10      +4 -3      xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/NamedLogicsheet.java
  
  Index: NamedLogicsheet.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/NamedLogicsheet.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NamedLogicsheet.java	26 Apr 2002 10:42:16 -0000	1.9
  +++ NamedLogicsheet.java	29 Apr 2002 12:53:17 -0000	1.10
  @@ -52,7 +52,8 @@
   
   import org.apache.avalon.framework.component.ComponentManager;
   import org.apache.cocoon.ProcessingException;
  -import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.SourceResolver;
  +import org.apache.excalibur.source.SourceException;
   
   import org.xml.sax.SAXException;
   
  @@ -67,7 +68,7 @@
    *
    * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
    * @author <a href="mailto:ovidiu@cup.hp.com">Ovidiu Predescu</a>
  - * @version CVS $Id: NamedLogicsheet.java,v 1.9 2002/04/26 10:42:16 cziegeler Exp $
  + * @version CVS $Id: NamedLogicsheet.java,v 1.10 2002/04/29 12:53:17 cziegeler Exp $
    */
   public class NamedLogicsheet extends Logicsheet {
       /**
  @@ -81,7 +82,7 @@
       private String prefix;
   
       public NamedLogicsheet(String systemId, ComponentManager manager, SourceResolver resolver)
  -        throws IOException, ProcessingException, SAXException
  +        throws IOException, ProcessingException, SourceException, SAXException
       {
           super(systemId, manager, resolver);
       }
  
  
  
  1.10      +2 -2      xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/sitemap/SitemapMarkupLanguage.java
  
  Index: SitemapMarkupLanguage.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/sitemap/SitemapMarkupLanguage.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- SitemapMarkupLanguage.java	22 Feb 2002 07:00:08 -0000	1.9
  +++ SitemapMarkupLanguage.java	29 Apr 2002 12:53:17 -0000	1.10
  @@ -57,7 +57,7 @@
   import org.apache.cocoon.components.language.markup.LogicsheetCodeGenerator;
   import org.apache.cocoon.components.language.markup.CocoonMarkupLanguage;
   import org.apache.cocoon.components.language.programming.ProgrammingLanguage;
  -import org.apache.cocoon.environment.SourceResolver;
  +import org.apache.excalibur.source.SourceResolver;
   import org.apache.log.Logger;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -75,7 +75,7 @@
    * <a href="http://xml.apache.org/cocoon2/userdocs/concepts/sitemap.html">Sitemap</a>.
    *
    * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
  - * @version CVS $Id: SitemapMarkupLanguage.java,v 1.9 2002/02/22 07:00:08 cziegeler Exp
$
  + * @version CVS $Id: SitemapMarkupLanguage.java,v 1.10 2002/04/29 12:53:17 cziegeler Exp
$
    */
   public class SitemapMarkupLanguage extends CocoonMarkupLanguage {
   
  
  
  

----------------------------------------------------------------------
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