cziegeler 2002/06/13 02:28:16 Modified: lib/core avalon-excalibur-20020612.jar src/java/org/apache/cocoon Cocoon.java src/java/org/apache/cocoon/acting AbstractComplementaryConfigurableAction.java AbstractXMLFormAction.java src/java/org/apache/cocoon/caching IncludeCacheValidity.java src/java/org/apache/cocoon/components/flow AbstractInterpreter.java Interpreter.java ScriptSource.java src/java/org/apache/cocoon/components/flow/javascript JavaScriptInterpreter.java src/java/org/apache/cocoon/components/language/generator ProgramGeneratorImpl.java src/java/org/apache/cocoon/components/language/markup/xsp XSPFormValidatorHelper.java XSPUtil.java src/java/org/apache/cocoon/components/search SimpleLuceneXMLIndexerImpl.java src/java/org/apache/cocoon/components/source SitemapSource.java SourceUtil.java src/java/org/apache/cocoon/components/source/impl AvalonToCocoonSource.java src/java/org/apache/cocoon/components/treeprocessor DefaultTreeBuilder.java TreeBuilder.java TreeProcessor.java src/java/org/apache/cocoon/components/treeprocessor/sitemap MountNode.java src/java/org/apache/cocoon/environment AbstractEnvironment.java src/java/org/apache/cocoon/environment/commandline AbstractCommandLineEnvironment.java src/java/org/apache/cocoon/generation DirectoryGenerator.java JspGenerator.java VelocityGenerator.java src/java/org/apache/cocoon/transformation CachingCIncludeTransformer.java XIncludeTransformer.java src/java/org/apache/cocoon/webapps/portal/components CopletThread.java src/java/org/apache/cocoon/webapps/session/components SessionManager.java Added: src/java/org/apache/cocoon/components/source/impl DelayedRefreshSourceWrapper.java Log: Changed all calls from resolve() to the new resolveURI() Revision Changes Path 1.3 +94 -96 xml-cocoon2/lib/core/avalon-excalibur-20020612.jar <<Binary file>> 1.30 +11 -12 xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java Index: Cocoon.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/Cocoon.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- Cocoon.java 29 May 2002 12:50:20 -0000 1.29 +++ Cocoon.java 13 Jun 2002 09:28:14 -0000 1.30 @@ -72,14 +72,15 @@ import org.apache.cocoon.components.language.generator.CompiledComponent; import org.apache.cocoon.components.language.generator.ProgramGenerator; import org.apache.cocoon.components.pipeline.ProcessingPipeline; -import org.apache.cocoon.components.source.DelayedRefreshSourceWrapper; -import org.apache.cocoon.components.source.URLSource; +import org.apache.cocoon.components.source.SourceUtil; +import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper; import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.environment.ModifiableSource; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.Session; import org.apache.cocoon.util.ClassUtils; +import org.apache.excalibur.source.Source; +import org.apache.excalibur.source.impl.URLSource; import org.xml.sax.InputSource; import java.io.BufferedInputStream; @@ -114,7 +115,7 @@ private Context context; /** The configuration file */ - private ModifiableSource configurationFile; + private Source configurationFile; /** The configuration tree */ private Configuration configuration; @@ -183,8 +184,9 @@ try { // FIXME : add a configuration option for the refresh delay. // for now, hard-coded to 1 second. - this.configurationFile = new DelayedRefreshSourceWrapper( - new URLSource((URL)context.get(Constants.CONTEXT_CONFIG_URL), this.componentManager), + URLSource urlSource = new URLSource(); + urlSource.init((URL)context.get(Constants.CONTEXT_CONFIG_URL), null); + this.configurationFile = new DelayedRefreshSourceWrapper(urlSource, 1000L ); @@ -325,7 +327,7 @@ Configuration roleConfig = null; try { - this.configurationFile.refresh(); + this.configurationFile.discardValidity(); p = (Parser)startupManager.lookup(Parser.ROLE); SAXConfigurationHandler b = new SAXConfigurationHandler(); InputStream inputStream = ClassUtils.getResource("org/apache/cocoon/cocoon.roles").openStream(); @@ -348,7 +350,7 @@ try { p = (Parser)startupManager.lookup(Parser.ROLE); SAXConfigurationHandler b = new SAXConfigurationHandler(); - InputSource is = this.configurationFile.getInputSource(); + InputSource is = SourceUtil.getInputSource(this.configurationFile); p.parse(is, b); this.configuration = b.getConfiguration(); } catch (Exception e) { @@ -458,9 +460,6 @@ this.sourceResolver = null; this.xmlizer = null; this.componentManager.dispose(); - if (this.configurationFile != null) { - this.configurationFile.recycle(); - } this.disposed = true; } 1.8 +5 -5 xml-cocoon2/src/java/org/apache/cocoon/acting/AbstractComplementaryConfigurableAction.java Index: AbstractComplementaryConfigurableAction.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/AbstractComplementaryConfigurableAction.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AbstractComplementaryConfigurableAction.java 6 Apr 2002 06:26:10 -0000 1.7 +++ AbstractComplementaryConfigurableAction.java 13 Jun 2002 09:28:14 -0000 1.8 @@ -54,8 +54,8 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.SAXConfigurationHandler; import org.apache.cocoon.Constants; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; +import org.apache.excalibur.source.Source; import java.util.HashMap; import java.util.Map; @@ -112,7 +112,7 @@ synchronized (AbstractComplementaryConfigurableAction.configurations) { Source resource = null; try { - resource = resolver.resolve(descriptor); + resource = resolver.resolveURI(descriptor); conf = (ConfigurationHelper) AbstractComplementaryConfigurableAction.configurations.get(resource.getSystemId()); if (conf == null || (reloadable && conf.lastModified != resource.getLastModified())) { getLogger().debug("(Re)Loading " + descriptor); @@ -122,7 +122,7 @@ } SAXConfigurationHandler builder = new SAXConfigurationHandler(); - resource.toSAX(builder); + resolver.toSAX(resource, builder); conf.lastModified = resource.getLastModified(); conf.configuration = builder.getConfiguration(); @@ -136,7 +136,7 @@ throw new ConfigurationException("Error trying to load configurations for resource: " + (resource == null ? "null" : resource.getSystemId())); } finally { - if (resource != null) resource.recycle(); + resolver.release(resource); } } 1.2 +68 -65 xml-cocoon2/src/java/org/apache/cocoon/acting/AbstractXMLFormAction.java Index: AbstractXMLFormAction.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/acting/AbstractXMLFormAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractXMLFormAction.java 20 May 2002 06:53:14 -0000 1.1 +++ AbstractXMLFormAction.java 13 Jun 2002 09:28:14 -0000 1.2 @@ -6,7 +6,7 @@ * ==================================================================== * The Apache Software License, Version 1.1 * - * + * * * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. @@ -85,18 +85,17 @@ import org.apache.avalon.framework.CascadingRuntimeException; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.excalibur.pool.Poolable; +import org.apache.excalibur.source.Source; // Cocoon classes import org.apache.cocoon.Constants; import org.apache.cocoon.environment.Redirector; import org.apache.cocoon.environment.SourceResolver; -import org.apache.cocoon.environment.Source; -import org.apache.cocoon.acting.*; import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Session; import org.apache.cocoon.environment.Context; - +import org.apache.cocoon.components.source.SourceUtil; // Schematron classes import org.apache.cocoon.components.validation.SchemaFactory; import org.apache.cocoon.components.validation.Schema; @@ -110,10 +109,10 @@ /** * - * This is the base action class for + * This is the base action class for * xmlform handling * - * This action is Poolable which means that + * This action is Poolable which means that * subclasses of this class should not be * concerned about thread safety. * The framework ensures that only one thread @@ -121,19 +120,19 @@ * * However once an action is complete, the instance * will be recycled and reused for another request. - * + * * * Several ideas are borrowed from the original work of * Torsten Curdt. * * @author Ivelin Ivanov <[EMAIL PROTECTED]> */ -public abstract class AbstractXMLFormAction - extends ConfigurableComposerAction +public abstract class AbstractXMLFormAction + extends ConfigurableComposerAction implements Poolable { - public static final String OBJECT_MAP_NEXT_PAGE = "page"; + public static final String OBJECT_MAP_NEXT_PAGE = "page"; /** @@ -147,20 +146,20 @@ * an objectModel map which will be immediately returned by the action. * * This method is a good place to handle buttons with Cancel - * kind of semantics. For example + * kind of semantics. For example * <pre>return page("input")</pre> * */ protected abstract Map prepare(); - - + + /** - * Invoked during the form population process + * Invoked during the form population process * - * Provides default implementation, which + * Provides default implementation, which * can be extended or replaced by subclasses * - * Implementations of this method are responsible + * Implementations of this method are responsible * for creating and * returning the Form object which the action * is working on. @@ -171,7 +170,7 @@ protected Form getForm () { Form form = Form.lookup( getObjectModel(), getFormId() ); - + if (form != null) return form; else // create new form { @@ -183,9 +182,9 @@ } } - - public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters params) - throws java.lang.Exception + + public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters params) + throws java.lang.Exception { // populate action state objects redirector_ = redirector; @@ -193,7 +192,7 @@ objectModel_ = objectModel; src_ = src; params_ = params; - + // find and save the action command findCommand(); @@ -211,10 +210,10 @@ // If this is not the desired behaviour, the Form class can be subclassed form.populate( objectModel ); - + return perform(); } - + /** * Get the command which was submitted with the form. @@ -225,7 +224,7 @@ { return command_; } - + protected void findCommand() { @@ -235,15 +234,15 @@ { String paramName = (String) enum.nextElement (); // search for the command - if ( paramName.startsWith ( Constants.ACTION_PARAM_PREFIX ) ) + if ( paramName.startsWith ( Constants.ACTION_PARAM_PREFIX ) ) { - command_ = + command_ = paramName.substring ( Constants.ACTION_PARAM_PREFIX.length(), paramName.length() ); } } } - - + + /** * @return the @view attribute of the xmlform form tag. * This attribute is used to identify the part(or view) @@ -253,11 +252,11 @@ */ public String getFormView() { - return getForm().getFormView( getObjectModel() ); + return getForm().getFormView( getObjectModel() ); } - - + + /** * Called to determine the exit point of an action. * The pageName is made available in the objectMap, @@ -269,13 +268,13 @@ protected Map page( String pageName ) { Map objectModel = new HashMap(); - objectModel.put( OBJECT_MAP_NEXT_PAGE, pageName ); + objectModel.put( OBJECT_MAP_NEXT_PAGE, pageName ); return objectModel; } - + /** * Invoked after form population - * unless a Cancel button was pressed, + * unless a Cancel button was pressed, * in which case population is skipped and this method * is invoked immediately * @@ -302,35 +301,35 @@ return objectModel_; } - + protected Parameters getParameters() { return params_; } - + protected String getSrc() { return src_; } - + protected Request getRequest() { return (Request) ( getObjectModel().get(ObjectModelHelper.REQUEST_OBJECT) ); } - + protected Session getSession( boolean shouldCreateNew ) { return getRequest().getSession( shouldCreateNew ); } - + protected Session getSession() { return getSession( true ); } - + /** - * Extract action parameters and + * Extract action parameters and * instantiate a new validator based on them. * * xmlform-validator-schema-ns @@ -347,29 +346,33 @@ // initialize the Validor with a schema file String schNS = getParameters().getParameter("xmlform-validator-schema-ns", null); String schDoc = getParameters().getParameter("xmlform-validator-schema", null); - + // if validator params are not specified, then // there is no validation by default if (schNS == null || schDoc == null ) return null; - Source schemaSrc = getSourceResolver().resolve( schDoc ); - InputSource is = schemaSrc.getInputSource (); - SchemaFactory schf = SchemaFactory.lookup ( schNS ); - Schema sch = schf.compileSchema ( is ); - - return sch.newValidator(); - } + Source schemaSrc = getSourceResolver().resolveURI( schDoc ); + try { + InputSource is = SourceUtil.getInputSource(schemaSrc); + SchemaFactory schf = SchemaFactory.lookup ( schNS ); + Schema sch = schf.compileSchema ( is ); + + return sch.newValidator(); + } finally { + getSourceResolver().release(schemaSrc); + } + } catch ( Exception e) { // couldn't load the validator throw new CascadingRuntimeException( " Failed loading validating schema ", e ); } } - - + + /** - * Extract xmlform-model - * action parameter and + * Extract xmlform-model + * action parameter and * instantiate a new form model it. * * @@ -385,24 +388,24 @@ Class modelClass = Class.forName ( modelClassName ); Object o = modelClass.newInstance (); return o; - } + } catch ( Exception e) { throw new CascadingRuntimeException( " Failed instantiating form model ", e ); } } - + protected String getFormId() { String formId = getParameters().getParameter("xmlform-id", null); if ( formId == null ) throw new RuntimeException( " xmlform-id not specified " ); - else + else return formId; } - - + + protected String getFormScope() { String formScope = getParameters().getParameter("xmlform-scope", null); @@ -413,17 +416,17 @@ } return formScope; } - - + + // action state objects private Redirector redirector_; private SourceResolver resolver_; private Map objectModel_; private Parameters params_; - private String src_; + private String src_; private Request request_; private Session session_; private String command_; - + } 1.9 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/caching/IncludeCacheValidity.java Index: IncludeCacheValidity.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/caching/IncludeCacheValidity.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- IncludeCacheValidity.java 28 May 2002 07:11:43 -0000 1.8 +++ IncludeCacheValidity.java 13 Jun 2002 09:28:14 -0000 1.9 @@ -50,7 +50,7 @@ */ package org.apache.cocoon.caching; -import org.apache.cocoon.environment.Source; +import org.apache.excalibur.source.Source; import org.apache.cocoon.environment.SourceResolver; import java.util.ArrayList; @@ -104,14 +104,14 @@ long timeStamp = ((Long)j.next()).longValue(); Source otherSource = null; try { - otherSource = otherResolver.resolve(src); + otherSource = otherResolver.resolveURI(src); if(otherSource.getLastModified() != timeStamp || timeStamp == 0) return false; } catch (Exception e) { return false; } finally { - if (otherSource != null) otherSource.recycle(); + otherResolver.release(otherSource); } } return true; 1.3 +1 -1 xml-cocoon2/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java Index: AbstractInterpreter.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/AbstractInterpreter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AbstractInterpreter.java 21 May 2002 12:24:57 -0000 1.2 +++ AbstractInterpreter.java 13 Jun 2002 09:28:14 -0000 1.3 @@ -117,7 +117,7 @@ * * @see org.apache.cocoon.components.source.SourceFactory * @see org.apache.cocoon.environment.Environment - * @see org.apache.cocoon.components.source.DelayedRefreshSourceWrapper + * @see org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper */ public void register(String source) { 1.2 +1 -1 xml-cocoon2/src/java/org/apache/cocoon/components/flow/Interpreter.java Index: Interpreter.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/Interpreter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Interpreter.java 19 May 2002 19:19:38 -0000 1.1 +++ Interpreter.java 13 Jun 2002 09:28:14 -0000 1.2 @@ -4,7 +4,7 @@ import java.util.Map; import org.apache.cocoon.components.treeprocessor.CategoryNode; import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.environment.Source; +import org.apache.excalibur.source.Source; /** * The interface to the flow scripting languages. This interface is 1.2 +1 -1 xml-cocoon2/src/java/org/apache/cocoon/components/flow/ScriptSource.java Index: ScriptSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/ScriptSource.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ScriptSource.java 19 May 2002 19:19:38 -0000 1.1 +++ ScriptSource.java 13 Jun 2002 09:28:14 -0000 1.2 @@ -2,7 +2,7 @@ import org.apache.cocoon.environment.Environment; import org.apache.cocoon.environment.ModifiableSource; -import org.apache.cocoon.environment.Source; +import org.apache.excalibur.source.Source; /** * Representation of a source in a scripting language. Loosely modeled 1.2 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java Index: JavaScriptInterpreter.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/flow/javascript/JavaScriptInterpreter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- JavaScriptInterpreter.java 19 May 2002 19:19:39 -0000 1.1 +++ JavaScriptInterpreter.java 13 Jun 2002 09:28:14 -0000 1.2 @@ -13,7 +13,7 @@ import org.apache.cocoon.components.flow.AbstractInterpreter; import org.apache.cocoon.components.flow.WebContinuation; import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.environment.Source; +import org.apache.excalibur.source.Source; import org.mozilla.javascript.Context; import org.mozilla.javascript.Function; import org.mozilla.javascript.NativeArray; @@ -141,7 +141,7 @@ try { thrScope = enterContext(environment); - source = environment.resolve(sourceName); + source = environment.resolveURI(sourceName); InputStream inputStream = source.getInputStream(); Reader reader = new BufferedReader(new InputStreamReader(inputStream)); Context ctx = Context.getCurrentContext(); 1.18 +6 -5 xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java Index: ProgramGeneratorImpl.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/generator/ProgramGeneratorImpl.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- ProgramGeneratorImpl.java 14 May 2002 12:50:05 -0000 1.17 +++ ProgramGeneratorImpl.java 13 Jun 2002 09:28:15 -0000 1.18 @@ -64,6 +64,7 @@ import org.apache.avalon.framework.parameters.Parameterizable; import org.apache.avalon.framework.parameters.ParameterException; import org.apache.avalon.framework.thread.ThreadSafe; +import org.apache.excalibur.source.Source; import org.apache.cocoon.Constants; import org.apache.cocoon.ProcessingException; @@ -73,7 +74,7 @@ import org.apache.cocoon.components.language.programming.CodeFormatter; import org.apache.cocoon.components.language.programming.ProgrammingLanguage; import org.apache.cocoon.components.language.programming.Program; -import org.apache.cocoon.environment.Source; +import org.apache.cocoon.components.source.SourceUtil; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.util.IOUtils; import org.xml.sax.InputSource; @@ -223,7 +224,7 @@ SourceResolver resolver) throws Exception { - final Source source = resolver.resolve(fileName); + final Source source = resolver.resolveURI(fileName); final String id = source.getSystemId(); ProgrammingLanguage programmingLanguage = null; @@ -366,7 +367,7 @@ return (programInstance); } finally { - source.recycle(); + resolver.release(source); this.markupSelector.release(markupLanguage); this.languageSelector.release(programmingLanguage); } @@ -434,7 +435,7 @@ } // Input Source // FIXME(VG): Use Source.toSAX() - InputSource is = source.getInputSource(); + InputSource is = SourceUtil.getInputSource(source); // Generate code String code = markupLanguage.generateCode(is, normalizedName, programmingLanguage, resolver); 1.10 +5 -5 xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPFormValidatorHelper.java Index: XSPFormValidatorHelper.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPFormValidatorHelper.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- XSPFormValidatorHelper.java 28 Apr 2002 19:09:20 -0000 1.9 +++ XSPFormValidatorHelper.java 13 Jun 2002 09:28:15 -0000 1.10 @@ -53,13 +53,13 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.configuration.SAXConfigurationHandler; +import org.apache.excalibur.source.Source; import org.apache.cocoon.Constants; import org.apache.cocoon.acting.ConfigurationHelper; import org.apache.cocoon.acting.ValidatorActionResult; import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Request; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; import org.apache.log.Logger; @@ -398,7 +398,7 @@ synchronized (XSPFormValidatorHelper.configurations) { Source source = null; try { - source = resolver.resolve(descriptor); + source = resolver.resolveURI(descriptor); conf = (ConfigurationHelper) XSPFormValidatorHelper.configurations.get(source.getSystemId()); if (conf == null || (reloadable && conf.lastModified != source.getLastModified())) { logger.debug("(Re)Loading " + descriptor); @@ -408,7 +408,7 @@ } SAXConfigurationHandler builder = new SAXConfigurationHandler(); - source.toSAX(builder); + resolver.toSAX(source, builder); conf.lastModified = source.getLastModified(); conf.configuration = builder.getConfiguration(); @@ -421,7 +421,7 @@ logger.error("Could not configure Database mapping environment", e); throw new ConfigurationException("Error trying to load configurations for resource: " + source.getSystemId()); } finally { - if (source != null) source.recycle(); + resolver.release(source); } } 1.9 +3 -3 xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java Index: XSPUtil.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/XSPUtil.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- XSPUtil.java 4 Jun 2002 09:27:20 -0000 1.8 +++ XSPUtil.java 13 Jun 2002 09:28:15 -0000 1.9 @@ -64,7 +64,7 @@ import org.xml.sax.SAXException; import org.apache.cocoon.environment.SourceResolver; -import org.apache.cocoon.environment.Source; +import org.apache.excalibur.source.Source; import java.lang.Long; import java.io.*; @@ -280,7 +280,7 @@ StringBuffer result = new StringBuffer(); InputStream stream = null; try { - Source resource = resolver.resolve(uri); + Source resource = resolver.resolveURI(uri); long length = resource.getContentLength(); stream = new BufferedInputStream(resource.getInputStream()); if (length != -1) { 1.10 +1 -2 xml-cocoon2/src/java/org/apache/cocoon/components/search/SimpleLuceneXMLIndexerImpl.java Index: SimpleLuceneXMLIndexerImpl.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/search/SimpleLuceneXMLIndexerImpl.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- SimpleLuceneXMLIndexerImpl.java 28 Feb 2002 14:11:42 -0000 1.9 +++ SimpleLuceneXMLIndexerImpl.java 13 Jun 2002 09:28:15 -0000 1.10 @@ -78,7 +78,6 @@ import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.ProcessingException; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; import org.apache.lucene.document.DateField; 1.18 +11 -6 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.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- SitemapSource.java 28 May 2002 14:03:18 -0000 1.17 +++ SitemapSource.java 13 Jun 2002 09:28:15 -0000 1.18 @@ -53,6 +53,7 @@ import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.ComponentSelector; +import org.apache.excalibur.source.SourceException; import org.apache.cocoon.Constants; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.Processor; @@ -119,7 +120,7 @@ private ProcessingPipeline processingPipeline; /** The redirect <code>Source</code> */ - private Source redirectSource; + private org.apache.excalibur.source.Source redirectSource; /** The <code>SAXException</code> if unable to get resource */ private ProcessingException exception; @@ -227,7 +228,11 @@ } if (this.redirectSource != null) { - return this.redirectSource.getInputStream(); + try { + return this.redirectSource.getInputStream(); + } catch (SourceException se) { + throw SourceUtil.handle(se); + } } try { @@ -269,7 +274,7 @@ if (redirectURL.indexOf(":") == -1) { redirectURL = "cocoon:/" + redirectURL; } - this.redirectSource = this.environment.resolve(redirectURL); + this.redirectSource = this.environment.resolveURI(redirectURL); this.lastModificationDate = this.redirectSource.getLastModified(); } } catch (ProcessingException e) { @@ -315,7 +320,7 @@ consumer = new ContentHandlerWrapper(contentHandler); } if (this.redirectSource != null) { - this.redirectSource.toSAX(consumer); + this.environment.toSAX(this.redirectSource, consumer); } else { try { CocoonComponentManager.enterEnvironment(this.environment, @@ -341,8 +346,8 @@ if (this.processingPipeline != null) this.processingPipeline.release(); this.processingPipeline = null; this.lastModificationDate = 0; + this.environment.release(this.redirectSource); this.environment.reset(); - if (this.redirectSource != null) this.redirectSource.recycle(); this.redirectSource = null; this.exception = null; this.needsRefresh = true; 1.4 +16 -1 xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceUtil.java Index: SourceUtil.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SourceUtil.java 4 Jun 2002 07:31:52 -0000 1.3 +++ SourceUtil.java 13 Jun 2002 09:28:15 -0000 1.4 @@ -62,6 +62,7 @@ import org.apache.excalibur.source.SourceNotFoundException; import org.apache.excalibur.xmlizer.XMLizer; import org.xml.sax.ContentHandler; +import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.w3c.dom.Document; @@ -143,5 +144,19 @@ if (se instanceof SourceNotFoundException) return new ResourceNotFoundException(message, se); return new ProcessingException(message, se); + } + + /** + * Get an InputSource object + */ + static public InputSource getInputSource(Source source) + throws IOException, ProcessingException { + try { + final InputSource newObject = new InputSource(source.getInputStream()); + newObject.setSystemId(source.getSystemId()); + return newObject; + } catch (SourceException se) { + throw handle(se); + } } } 1.7 +3 -2 xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/AvalonToCocoonSource.java Index: AvalonToCocoonSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/AvalonToCocoonSource.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- AvalonToCocoonSource.java 12 Jun 2002 10:14:53 -0000 1.6 +++ AvalonToCocoonSource.java 13 Jun 2002 09:28:15 -0000 1.7 @@ -67,7 +67,8 @@ /** * This source objects wraps an Avalon Excalibur Source to get * an obsolete Cocoon Source object for the use of the deprecated - * resolve() method of the environment! + * {@link org.apache.cocoon.environment.SourceResolver#resolve(String)} + * method. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Revision$ $Date$ 1.1 xml-cocoon2/src/java/org/apache/cocoon/components/source/impl/DelayedRefreshSourceWrapper.java Index: DelayedRefreshSourceWrapper.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.source.impl; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceValidity; import org.apache.avalon.excalibur.pool.Recyclable; import org.apache.cocoon.ProcessingException; import org.xml.sax.InputSource; import java.io.IOException; import java.io.InputStream; import java.util.Iterator; import org.xml.sax.ContentHandler; import org.xml.sax.SAXException; /** * A wrapper around a <code>Source</code> that reduces the number of calls to * <code>Source.getLastModified()</code> which can be a costly operation. * * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @version $Id: DelayedRefreshSourceWrapper.java,v 1.1 2002/06/13 09:28:15 cziegeler Exp $ */ public final class DelayedRefreshSourceWrapper implements Source { private Source source; private long delay; private long nextCheckTime = 0; private long lastModified = 0; /** * Creates a wrapper for a <code>Source</code> which ensures that * <code>Source.getLastModified()</code> won't be called more than once per * <code>delay</code> milliseconds period. * * @param source the wrapped <code>Source</code> * @param delay the last-modified refresh delay, in milliseconds */ public DelayedRefreshSourceWrapper(Source source, long delay) { this.source = source; this.delay = delay; } public final InputStream getInputStream() throws SourceException, IOException { return this.source.getInputStream(); } public final String getSystemId() { return this.source.getSystemId(); } /** * Get the Validity object. This can either wrap the last modification * date or the expires information or... * If it is currently not possible to calculate such an information * <code>null</code> is returned. */ public SourceValidity getValidity() { return this.source.getValidity(); } /** * Get the last modification time for the wrapped <code>Source</code>. The * age of the returned information is guaranteed to be lower than or equal to * the delay specified in the constructor. * <p> * This method is also thread-safe, even if the underlying Source is not. * * @return the last modification time. */ public final long getLastModified() { // Do we have to refresh the source ? if (System.currentTimeMillis() >= nextCheckTime) { // Yes this.discardValidity(); } return this.lastModified; } /** * Force the refresh of the wrapped <code>Source</code>, even if the refresh period * isn't over, and starts a new period. * <p> * This method is thread-safe, even if the underlying Source is not. */ public synchronized final void discardValidity() { this.nextCheckTime = System.currentTimeMillis() + this.delay; // Refresh modifiable sources this.source.discardValidity(); // Keep the last modified date this.lastModified = source.getLastModified(); } public final long getContentLength() { return this.source.getContentLength(); } /** * The mime-type of the content described by this object. * If the source is not able to determine the mime-type by itself * this can be <code>null</code>. */ public String getMimeType() { return this.source.getMimeType(); } public final void recycle() { if (this.source instanceof Recyclable) { ((Recyclable)this.source).recycle(); } } /** * Get the value of a parameter. * Using this it is possible to get custom information provided by the * source implementation, like an expires date, HTTP headers etc. */ public String getParameter(String name) { return null; } /** * Get the value of a parameter. * Using this it is possible to get custom information provided by the * source implementation, like an expires date, HTTP headers etc. */ public long getParameterAsLong(String name) { return 0; } /** * Get parameter names * Using this it is possible to get custom information provided by the * source implementation, like an expires date, HTTP headers etc. */ public Iterator getParameterNames() { return java.util.Collections.EMPTY_LIST.iterator(); } } 1.8 +25 -5 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java Index: DefaultTreeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/DefaultTreeBuilder.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DefaultTreeBuilder.java 21 May 2002 12:24:57 -0000 1.7 +++ DefaultTreeBuilder.java 13 Jun 2002 09:28:15 -0000 1.8 @@ -78,12 +78,14 @@ import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.logger.AbstractLoggable; - +import org.apache.cocoon.ProcessingException; import org.apache.cocoon.components.ExtendedComponentSelector; import org.apache.cocoon.components.LifecycleHelper; - -import org.apache.cocoon.environment.Source; +import org.apache.cocoon.components.source.SourceUtil; import org.apache.cocoon.environment.SourceResolver; +import org.apache.excalibur.source.Source; +import org.apache.excalibur.source.SourceException; +import org.apache.excalibur.xmlizer.XMLizer; import org.apache.cocoon.sitemap.PatternException; import org.apache.cocoon.util.ClassUtils; @@ -383,7 +385,25 @@ try { // Build a namespace-aware configuration object NamespacedSAXConfigurationHandler handler = new NamespacedSAXConfigurationHandler(); - source.toSAX(handler); + if ( source instanceof org.apache.avalon.excalibur.xml.XMLizable ) { + ((org.apache.avalon.excalibur.xml.XMLizable)source).toSAX( handler ); + } else if ( source instanceof org.apache.cocoon.xml.XMLizable ) { + ((org.apache.cocoon.xml.XMLizable)source).toSAX( handler ); + } else { + XMLizer xmlizer = (XMLizer)this.parentManager.lookup(XMLizer.ROLE); + try { + xmlizer.toSAX( source.getInputStream(), + source.getMimeType(), + source.getSystemId(), + handler ); + } catch (SourceException se) { + throw SourceUtil.handle(se); + } catch (ComponentException ce) { + throw new ProcessingException("Exception during streaming source.", ce); + } finally { + this.parentManager.release(xmlizer); + } + } Configuration treeConfig = handler.getConfiguration(); return build(treeConfig); 1.3 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java Index: TreeBuilder.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/TreeBuilder.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TreeBuilder.java 17 Mar 2002 21:55:22 -0000 1.2 +++ TreeBuilder.java 13 Jun 2002 09:28:15 -0000 1.3 @@ -55,8 +55,8 @@ import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; +import org.apache.excalibur.source.Source; import java.util.*; @@ -105,9 +105,9 @@ * Build a processing tree from a <code>Configuration</code>. */ ProcessingNode build(Configuration tree) throws Exception; - + ProcessingNode build(Source source) throws Exception; - + String getFileName(); /** 1.16 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java Index: TreeProcessor.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/TreeProcessor.java,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- TreeProcessor.java 9 Jun 2002 00:23:26 -0000 1.15 +++ TreeProcessor.java 13 Jun 2002 09:28:15 -0000 1.16 @@ -81,12 +81,12 @@ import org.apache.cocoon.components.ExtendedComponentSelector; import org.apache.cocoon.components.LifecycleHelper; import org.apache.cocoon.components.pipeline.ProcessingPipeline; -import org.apache.cocoon.components.source.DelayedRefreshSourceWrapper; +import org.apache.cocoon.components.source.impl.DelayedRefreshSourceWrapper; import org.apache.cocoon.components.source.SourceUtil; import org.apache.cocoon.components.source.URLSource; import org.apache.cocoon.environment.Environment; -import org.apache.cocoon.environment.Source; +import org.apache.excalibur.source.Source; import java.io.InputStream; import java.util.*; @@ -396,7 +396,7 @@ } if (this.source == null) { - this.source = new DelayedRefreshSourceWrapper(env.resolve(this.fileName), lastModifiedDelay); + this.source = new DelayedRefreshSourceWrapper(env.resolveURI(this.fileName), lastModifiedDelay); } root = builder.build(this.source); 1.6 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java Index: MountNode.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- MountNode.java 27 May 2002 14:31:27 -0000 1.5 +++ MountNode.java 13 Jun 2002 09:28:15 -0000 1.6 @@ -156,7 +156,7 @@ } processor = this.parentProcessor.createChildProcessor( - this.manager, this.language, env.resolve(actualSource)); + this.manager, this.language, env.resolveURI(actualSource)); // Associate to the original source processors.put(source, processor); 1.22 +3 -1 xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java Index: AbstractEnvironment.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/AbstractEnvironment.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- AbstractEnvironment.java 6 Jun 2002 14:43:40 -0000 1.21 +++ AbstractEnvironment.java 13 Jun 2002 09:28:15 -0000 1.22 @@ -452,6 +452,8 @@ throws SAXException, IOException, ProcessingException { if ( source instanceof org.apache.avalon.excalibur.xml.XMLizable ) { ((org.apache.avalon.excalibur.xml.XMLizable)source).toSAX( handler ); + } else if ( source instanceof org.apache.cocoon.xml.XMLizable ) { + ((org.apache.cocoon.xml.XMLizable)source).toSAX( handler ); } else { try { xmlizer.toSAX( source.getInputStream(), 1.8 +13 -12 xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java Index: AbstractCommandLineEnvironment.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/commandline/AbstractCommandLineEnvironment.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- AbstractCommandLineEnvironment.java 27 Mar 2002 15:13:40 -0000 1.7 +++ AbstractCommandLineEnvironment.java 13 Jun 2002 09:28:15 -0000 1.8 @@ -55,7 +55,8 @@ import org.apache.cocoon.environment.AbstractEnvironment; import org.apache.cocoon.environment.Redirector; import org.apache.cocoon.environment.Session; -import org.apache.cocoon.environment.Source; +import org.apache.excalibur.source.Source; +import org.apache.excalibur.source.SourceException; import org.apache.log.Logger; import org.xml.sax.SAXException; @@ -130,19 +131,21 @@ Source redirectSource = null; try { - redirectSource = this.resolve(newURL); - redirectSource.toSAX(ls); + redirectSource = this.resolveURI(newURL); + this.toSAX(redirectSource, ls); + } catch (SourceException se) { + throw new IOException("SourceException: " + se); } catch (SAXException se) { throw new IOException("SAXException: " + se); } catch (ProcessingException pe) { throw new IOException("ProcessingException: " + pe); } finally { - if (redirectSource != null) redirectSource.recycle(); + this.release( redirectSource ); } } else { Source redirectSource = null; try { - redirectSource = this.resolve(newURL); + redirectSource = this.resolveURI(newURL); InputStream is = redirectSource.getInputStream(); byte[] buffer = new byte[8192]; int length = -1; @@ -150,16 +153,14 @@ while ((length = is.read(buffer)) > -1) { this.stream.write(buffer, 0, length); } - } catch (SAXException se) { - throw new IOException("SAXException: " + se); - } catch (ProcessingException pe) { - throw new IOException("ProcessingException: " + pe); + } catch (SourceException se) { + throw new IOException("SourceException: " + se); } finally { - if (redirectSource != null) redirectSource.recycle(); + this.release( redirectSource); } } } - + public boolean hasRedirected() { return this.hasRedirected; } 1.10 +79 -75 xml-cocoon2/src/java/org/apache/cocoon/generation/DirectoryGenerator.java Index: DirectoryGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/DirectoryGenerator.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- DirectoryGenerator.java 19 May 2002 11:42:00 -0000 1.9 +++ DirectoryGenerator.java 13 Jun 2002 09:28:16 -0000 1.10 @@ -53,8 +53,10 @@ import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.ResourceNotFoundException; -import org.apache.cocoon.environment.Source; +import org.apache.cocoon.components.source.SourceUtil; import org.apache.cocoon.environment.SourceResolver; +import org.apache.excalibur.source.Source; +import org.apache.excalibur.source.SourceException; import org.apache.regexp.RE; import org.apache.regexp.RESyntaxException; import org.xml.sax.SAXException; @@ -132,7 +134,7 @@ protected static final String FILENAME_ATTR_NAME = "name"; protected static final String LASTMOD_ATTR_NAME = "lastModified"; protected static final String DATE_ATTR_NAME = "date"; - protected static final String SIZE_ATTR_NAME = "size"; + protected static final String SIZE_ATTR_NAME = "size"; /* * Variables set per-request @@ -142,8 +144,8 @@ protected int depth; protected AttributesImpl attributes = new AttributesImpl(); protected SimpleDateFormat dateFormatter; - protected String sort; - protected boolean reverse; + protected String sort; + protected boolean reverse; protected RE rootRE; protected RE includeRE; @@ -179,11 +181,11 @@ this.depth = par.getParameterAsInteger("depth", 1); getLogger().debug("depth: " + this.depth); - this.sort = par.getParameter("sort", "name"); - getLogger().debug("sort: " + this.sort); + this.sort = par.getParameter("sort", "name"); + getLogger().debug("sort: " + this.sort); - this.reverse = par.getParameterAsBoolean("reverse", false); - getLogger().debug("reverse: " + this.reverse); + this.reverse = par.getParameterAsBoolean("reverse", false); + getLogger().debug("reverse: " + this.reverse); String rePattern = par.getParameter("root", null); try { @@ -224,7 +226,7 @@ String directory = super.source; Source inputSource = null; try { - inputSource = this.resolver.resolve(directory); + inputSource = this.resolver.resolveURI(directory); String systemId = inputSource.getSystemId(); if (!systemId.startsWith(FILE)) { throw new ResourceNotFoundException(systemId + " does not denote a directory"); @@ -243,12 +245,14 @@ this.contentHandler.endPrefixMapping(PREFIX); this.contentHandler.endDocument(); + } catch (SourceException se) { + throw SourceUtil.handle(se); } catch (IOException ioe) { getLogger().warn("Could not read directory " + directory, ioe); throw new ResourceNotFoundException("Could not read directory " + directory, ioe); } finally { - if (inputSource != null) inputSource.recycle(); + this.resolver.release( inputSource ); } } @@ -308,64 +312,64 @@ if (depth>0) { File contents[] = path.listFiles(); - if(sort.equals("name")) { - Arrays.sort(contents, - new Comparator() { - public int compare(Object o1, Object o2) { - if(reverse) { - return ((File) o2).getName() - .compareTo(((File) o1).getName()); - } - return ((File) o1).getName() - .compareTo(((File) o2).getName()); - } - }); - } else if(sort.equals("size")) { - Arrays.sort(contents, - new Comparator() { - public int compare(Object o1, Object o2) { - if(reverse) { - return new Long(((File) o2).length()) - .compareTo(new Long(((File) o1).length())); - } - return new Long(((File) o1).length()) - .compareTo(new Long(((File) o2).length())); - } - }); - } else if(sort.equals("lastmodified")) { - Arrays.sort(contents, - new Comparator() { - public int compare(Object o1, Object o2) { - if(reverse) { - return new Long(((File) o2).lastModified()) - .compareTo(new Long(((File) o1).lastModified())); - } - return new Long(((File) o1).lastModified()) - .compareTo(new Long(((File) o2).lastModified())); - } - }); - } else if(sort.equals("directory")) { - Arrays.sort(contents, - new Comparator() { - public int compare(Object o1, Object o2) { - File f1 = (File) o1; - File f2 = (File) o2; - - if(reverse) { - if(f2.isDirectory() && f1.isFile()) - return -1; - if(f2.isFile() && f1.isDirectory()) - return 1; - return f2.getName().compareTo(f1.getName()); - } - if(f2.isDirectory() && f1.isFile()) - return 1; - if(f2.isFile() && f1.isDirectory()) - return -1; - return f1.getName().compareTo(f2.getName()); - } - }); - } + if(sort.equals("name")) { + Arrays.sort(contents, + new Comparator() { + public int compare(Object o1, Object o2) { + if(reverse) { + return ((File) o2).getName() + .compareTo(((File) o1).getName()); + } + return ((File) o1).getName() + .compareTo(((File) o2).getName()); + } + }); + } else if(sort.equals("size")) { + Arrays.sort(contents, + new Comparator() { + public int compare(Object o1, Object o2) { + if(reverse) { + return new Long(((File) o2).length()) + .compareTo(new Long(((File) o1).length())); + } + return new Long(((File) o1).length()) + .compareTo(new Long(((File) o2).length())); + } + }); + } else if(sort.equals("lastmodified")) { + Arrays.sort(contents, + new Comparator() { + public int compare(Object o1, Object o2) { + if(reverse) { + return new Long(((File) o2).lastModified()) + .compareTo(new Long(((File) o1).lastModified())); + } + return new Long(((File) o1).lastModified()) + .compareTo(new Long(((File) o2).lastModified())); + } + }); + } else if(sort.equals("directory")) { + Arrays.sort(contents, + new Comparator() { + public int compare(Object o1, Object o2) { + File f1 = (File) o1; + File f2 = (File) o2; + + if(reverse) { + if(f2.isDirectory() && f1.isFile()) + return -1; + if(f2.isFile() && f1.isDirectory()) + return 1; + return f2.getName().compareTo(f1.getName()); + } + if(f2.isDirectory() && f1.isFile()) + return 1; + if(f2.isFile() && f1.isDirectory()) + return -1; + return f1.getName().compareTo(f2.getName()); + } + }); + } for (int i=0; i<contents.length; i++) { if (isIncluded(contents[i]) && !isExcluded(contents[i])) { @@ -425,14 +429,14 @@ attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME, "CDATA", dateFormatter.format(new Date(lastModified))); - attributes.addAttribute("", SIZE_ATTR_NAME, - SIZE_ATTR_NAME, "CDATA", - Long.toString(path.length())); + attributes.addAttribute("", SIZE_ATTR_NAME, + SIZE_ATTR_NAME, "CDATA", + Long.toString(path.length())); if (this.isRequestedDirectory) { - attributes.addAttribute("", "sort", "sort", "CDATA", this.sort); - attributes.addAttribute("", "reverse", "reverse", "CDATA", - String.valueOf(this.reverse)); + attributes.addAttribute("", "sort", "sort", "CDATA", this.sort); + attributes.addAttribute("", "reverse", "reverse", "CDATA", + String.valueOf(this.reverse)); attributes.addAttribute("", "requested", "requested", "CDATA", "true"); this.isRequestedDirectory = false; 1.8 +1 -2 xml-cocoon2/src/java/org/apache/cocoon/generation/JspGenerator.java Index: JspGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/JspGenerator.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- JspGenerator.java 22 Apr 2002 09:47:51 -0000 1.7 +++ JspGenerator.java 13 Jun 2002 09:28:16 -0000 1.8 @@ -56,7 +56,6 @@ import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.components.jsp.JSPEngine; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.http.HttpEnvironment; import org.xml.sax.InputSource; import org.xml.sax.SAXException; 1.9 +4 -4 xml-cocoon2/src/java/org/apache/cocoon/generation/VelocityGenerator.java Index: VelocityGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/VelocityGenerator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- VelocityGenerator.java 22 Feb 2002 07:03:51 -0000 1.8 +++ VelocityGenerator.java 13 Jun 2002 09:28:16 -0000 1.9 @@ -61,11 +61,11 @@ import org.apache.avalon.framework.context.DefaultContext; import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.parameters.ParameterException; +import org.apache.excalibur.source.Source; import org.apache.log.Logger; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.ResourceNotFoundException; import org.apache.cocoon.environment.ObjectModelHelper; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; import org.apache.commons.collections.ExtendedProperties; import org.apache.velocity.VelocityContext; @@ -282,7 +282,7 @@ if (source == null) { try { SourceResolver resolver = (SourceResolver)this.resolverContext.get(CONTEXT_RESOLVER_KEY); - source = resolver.resolve(systemId); + source = resolver.resolveURI(systemId); } catch (ContextException ex) { throw new org.apache.velocity.exception.ResourceNotFoundException("No Cocoon source resolver associated with current request."); } catch (Exception ex) { @@ -490,7 +490,7 @@ try { Map sourceCache = (Map)this.resolverContext.get(CONTEXT_SOURCE_CACHE_KEY); for (Iterator it = sourceCache.values().iterator(); it.hasNext();) { - ((Source)it.next()).recycle(); + this.resolver.release((Source)it.next()); } } catch (ContextException ignore) { } 1.8 +7 -7 xml-cocoon2/src/java/org/apache/cocoon/transformation/CachingCIncludeTransformer.java Index: CachingCIncludeTransformer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/CachingCIncludeTransformer.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- CachingCIncludeTransformer.java 22 Feb 2002 07:03:56 -0000 1.7 +++ CachingCIncludeTransformer.java 13 Jun 2002 09:28:16 -0000 1.8 @@ -54,12 +54,12 @@ import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; import org.apache.avalon.framework.parameters.Parameters; +import org.apache.excalibur.source.Source; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.CacheValidity; import org.apache.cocoon.caching.Cacheable; import org.apache.cocoon.caching.IncludeCacheValidity; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.xml.IncludeXMLConsumer; @@ -188,14 +188,14 @@ if(currentCacheValidity != null ) { Source temp = null; try { - temp = sourceResolver.resolve(src); + temp = sourceResolver.resolveURI(src); currentCacheValidity.add(src, temp.getLastModified()); getLogger().debug("currentCacheValidity: " + currentCacheValidity); } catch (Exception e) { getLogger().error("CachingCIncludeTransformer could not resolve resource:" + src, e); throw new SAXException("CachingCIncludeTransformer could not resolve resource", e); } finally { - if (temp != null) temp.recycle(); + sourceResolver.release(temp); } } @@ -212,13 +212,13 @@ Source source = null; try { - source = this.sourceResolver.resolve(src); - source.toSAX(getConsumer()); + source = this.sourceResolver.resolveURI(src); + this.sourceResolver.toSAX(source, getConsumer()); } catch (Exception e) { getLogger().error("CachingCIncludeTransformer", e); throw new SAXException("CachingCIncludeTransformer could not read resource", e); } finally { - if (source != null) source.recycle(); + sourceResolver.release(source); } if (!"".equals(element)) { 1.12 +23 -18 xml-cocoon2/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java Index: XIncludeTransformer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/transformation/XIncludeTransformer.java,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- XIncludeTransformer.java 13 Mar 2002 16:28:02 -0000 1.11 +++ XIncludeTransformer.java 13 Jun 2002 09:28:16 -0000 1.12 @@ -59,10 +59,12 @@ import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; import org.apache.avalon.excalibur.xml.xpath.XPathProcessor; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; +import org.apache.cocoon.components.source.SourceUtil; import org.apache.cocoon.xml.IncludeXMLConsumer; import org.apache.cocoon.xml.dom.DOMStreamer; +import org.apache.excalibur.source.Source; +import org.apache.excalibur.source.SourceException; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.Attributes; @@ -181,14 +183,14 @@ getLogger().debug("setDocumentLocator called " + locator.getSystemId()); } - base_xmlbase_uri = this.resolver.resolve(locator.getSystemId()); + base_xmlbase_uri = this.resolver.resolveURI(locator.getSystemId()); // If url ends with .xxx then truncate to dir if (base_xmlbase_uri.getSystemId().lastIndexOf('.') > base_xmlbase_uri.getSystemId().lastIndexOf('/')) { String uri = base_xmlbase_uri.getSystemId().substring(0,base_xmlbase_uri.getSystemId().lastIndexOf('/')+1); - base_xmlbase_uri.recycle(); + this.resolver.release(base_xmlbase_uri); base_xmlbase_uri = null; - base_xmlbase_uri = this.resolver.resolve(uri); + base_xmlbase_uri = this.resolver.resolveURI(uri); } if (current_xmlbase_uri == null) { @@ -217,15 +219,15 @@ } try { - current_xmlbase_uri = this.resolver.resolve(urlLoc); + current_xmlbase_uri = this.resolver.resolveURI(urlLoc); xmlbase_element_uri_stack.push(last_xmlbase_element_uri); last_xmlbase_element_uri = uri; xmlbase_element_name_stack.push(last_xmlbase_element_name); last_xmlbase_element_name = name; - } catch (ProcessingException e) { - throw e; + } catch (SourceException e) { + throw SourceUtil.handle(e); } catch (Exception e) { throw new ProcessingException("Could not resolve '" + urlLoc + "'", e); } @@ -245,7 +247,8 @@ last_xmlbase_element_name = (String)xmlbase_element_name_stack.pop(); } - protected void processXIncludeElement(String href, String parse) throws SAXException,ProcessingException,IOException { + protected void processXIncludeElement(String href, String parse) + throws SAXException,ProcessingException,IOException { if (getLogger().isDebugEnabled()) { getLogger().debug("Processing XInclude element: href="+href+", parse="+parse); if(current_xmlbase_uri == null) @@ -260,15 +263,15 @@ int index = href.indexOf('#'); if (index < 0) { if(current_xmlbase_uri == null) - url = this.resolver.resolve(href); + url = this.resolver.resolveURI(href); else - url = this.resolver.resolve(current_xmlbase_uri.getSystemId() + href); + url = this.resolver.resolveURI(current_xmlbase_uri.getSystemId() + href); suffix = ""; } else { if(current_xmlbase_uri == null) - url = this.resolver.resolve(href.substring(0,index)); + url = this.resolver.resolveURI(href.substring(0,index)); else - url = this.resolver.resolve(current_xmlbase_uri.getSystemId() + href.substring(0,index)); + url = this.resolver.resolveURI(current_xmlbase_uri.getSystemId() + href.substring(0,index)); suffix = href.substring(index+1); } if (getLogger().isDebugEnabled()) { @@ -293,7 +296,7 @@ try { parser = (Parser)manager.lookup(Parser.ROLE); - InputSource input = url.getInputSource(); + InputSource input = SourceUtil.getInputSource(url); if (suffix.startsWith("xpointer(") && suffix.endsWith(")")) { String xpath = suffix.substring(9,suffix.length()-1); @@ -328,19 +331,21 @@ this.manager.release(parser); } } + } catch (SourceException se) { + throw SourceUtil.handle(se); } finally { - if (url != null) url.recycle(); + this.resolver.release(url); } } public void recycle() { // Reset all variables to initial state. - this.resolver = null; - if (base_xmlbase_uri != null) base_xmlbase_uri.recycle(); + if (base_xmlbase_uri != null) this.resolver.release(base_xmlbase_uri); base_xmlbase_uri = null; - if (current_xmlbase_uri != null) current_xmlbase_uri.recycle(); + if (current_xmlbase_uri != null) this.resolver.release(current_xmlbase_uri); current_xmlbase_uri = null; + this.resolver = null; xmlbase_stack = new Stack(); last_xmlbase_element_uri = ""; xmlbase_element_uri_stack = new Stack(); 1.3 +3 -2 xml-cocoon2/src/java/org/apache/cocoon/webapps/portal/components/CopletThread.java Index: CopletThread.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/portal/components/CopletThread.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CopletThread.java 19 Apr 2002 11:02:58 -0000 1.2 +++ CopletThread.java 13 Jun 2002 09:28:16 -0000 1.3 @@ -244,9 +244,10 @@ info.put(PortalConstants.COPLETINFO_PARAMETERS, p); info.put(PortalConstants.COPLETINFO_PORTALURI, request.getRequestURI()); info.put(PortalConstants.COPLETINFO_STATUSPROFILE, loadedCoplet[7]); + XMLConsumer xc = new IncludeXMLConsumer(nextConsumer); this.resourceConnector.streamXML(resource.getResourceType(), null, res, (handlesParameters == true ? p : null), - new IncludeXMLConsumer(nextConsumer), null); + xc , xc); if (this.logger.isDebugEnabled() == true) { this.logger.debug("portal: Loaded coplet " + copletID); } 1.4 +1 -2 xml-cocoon2/src/java/org/apache/cocoon/webapps/session/components/SessionManager.java Index: SessionManager.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/webapps/session/components/SessionManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SessionManager.java 6 Jun 2002 14:28:15 -0000 1.3 +++ SessionManager.java 13 Jun 2002 09:28:16 -0000 1.4 @@ -72,7 +72,6 @@ import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.Response; import org.apache.cocoon.environment.Session; -import org.apache.cocoon.environment.Source; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.webapps.session.SessionConstants; import org.apache.cocoon.webapps.session.context.*;
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]