cziegeler 02/04/26 01:41:52 Modified: . changes.xml src/java/org/apache/cocoon/components CocoonComponentManager.java src/java/org/apache/cocoon/environment AbstractEnvironment.java SourceResolver.java src/java/org/apache/cocoon/environment/wrapper EnvironmentWrapper.java src/java/org/apache/cocoon/generation FileGenerator.java Added: . WARNING Log: - Activated Avalon source resolving, deactivated Cocoon source resolving - Fixed some minor bugs and tested the new cocoon protocol - The FileGenerator uses directly the new source resolving, all other components still use the deprecated version which creates a wrapper object to maintain compatibility - Added Alpha Warning - Started deprecating code Revision Changes Path 1.148 +6 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.147 retrieving revision 1.148 diff -u -r1.147 -r1.148 --- changes.xml 25 Apr 2002 05:41:12 -0000 1.147 +++ changes.xml 26 Apr 2002 08:41:52 -0000 1.148 @@ -4,7 +4,7 @@ <!-- History of Cocoon changes - $Id: changes.xml,v 1.147 2002/04/25 05:41:12 crossley Exp $ + $Id: changes.xml,v 1.148 2002/04/26 08:41:52 cziegeler Exp $ --> <changes title="History of Changes"> @@ -35,6 +35,11 @@ </devs> <release version="@version@" date="@date@"> + <action dev="CZ" type="add"> + Integrated the new Avalon Excalibur Source Resolving architecture. This deprecates + the now obsolete Cocoon source resolving. Wrapper classes etc. have been provided + for an easy upgrading. In addition the Excalibur XMLizer is added. + </action> <action dev="GF" type="add"> added new Selector component, obtained from [EMAIL PROTECTED] (Maciek Kaminski). </action> 1.3 +6 -4 xml-cocoon2/WARNING 1.18 +2 -2 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.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- CocoonComponentManager.java 24 Apr 2002 14:32:52 -0000 1.17 +++ CocoonComponentManager.java 26 Apr 2002 08:41:52 -0000 1.18 @@ -76,7 +76,7 @@ * and by handling the lookup of the <code>SourceResolver</code> (in development) * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: CocoonComponentManager.java,v 1.17 2002/04/24 14:32:52 cziegeler Exp $ + * @version CVS $Id: CocoonComponentManager.java,v 1.18 2002/04/26 08:41:52 cziegeler Exp $ */ public final class CocoonComponentManager extends ExcaliburComponentManager @@ -160,7 +160,7 @@ public static Object[] getCurrentEnvironment() { final Stack stack = (Stack)environmentStack.get(); if ( null != stack && !stack.empty()) { - return (Object[])stack.pop(); + return (Object[])stack.peek(); } return null; } 1.18 +7 -24 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.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- AbstractEnvironment.java 25 Apr 2002 14:53:15 -0000 1.17 +++ AbstractEnvironment.java 26 Apr 2002 08:41:52 -0000 1.18 @@ -73,7 +73,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: AbstractEnvironment.java,v 1.17 2002/04/25 14:53:15 cziegeler Exp $ + * @version CVS $Id: AbstractEnvironment.java,v 1.18 2002/04/26 08:41:52 cziegeler Exp $ */ public abstract class AbstractEnvironment extends AbstractLoggable implements Environment { @@ -350,6 +350,7 @@ /** * Resolve an entity. + * @deprecated Use the resolveURI methods instead */ public Source resolve(String systemId) throws ProcessingException, SAXException, IOException { @@ -358,30 +359,12 @@ } if (systemId == null) throw new SAXException("Invalid System ID"); - Source source; - if (systemId.length() == 0) { - source = this.sourceHandler.getSource(this, this.context.toExternalForm()); - } else if (systemId.charAt(0) == '/') { - // windows: absolute paths can start with / followed by a drive letter - if (systemId.length() > 2 && systemId.charAt(2) == ':') { - source = this.sourceHandler.getSource(this, "file:" + systemId); - } else { - source = this.sourceHandler.getSource(this, this.context.getProtocol() + - ":" + systemId); - } - } else if (systemId.indexOf(":") > 1) { - source = this.sourceHandler.getSource(this, systemId); - // windows: absolute paths can start with drive letter - } else if (systemId.length() > 1 && systemId.charAt(1) == ':') { - source = this.sourceHandler.getSource(this, "file:/" + systemId); - } else { - source = this.sourceHandler.getSource(this, this.context, systemId); - } - - if (getLogger().isDebugEnabled()) { - this.getLogger().debug("Resolved to '"+source.getSystemId()+"'"); + try { + org.apache.excalibur.source.Source source = this.resolveURI( systemId ); + return new org.apache.cocoon.components.source.impl.AvalonToCocoonSource(source, this.sourceResolver, this); + } catch (SourceException se) { + throw new ProcessingException("Exception during resolving of " + systemId, se); } - return source; } /** 1.8 +2 -1 xml-cocoon2/src/java/org/apache/cocoon/environment/SourceResolver.java Index: SourceResolver.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/SourceResolver.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SourceResolver.java 25 Apr 2002 09:37:01 -0000 1.7 +++ SourceResolver.java 26 Apr 2002 08:41:52 -0000 1.8 @@ -59,7 +59,7 @@ * Base interface for resolving a source by system identifiers. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: SourceResolver.java,v 1.7 2002/04/25 09:37:01 cziegeler Exp $ + * @version CVS $Id: SourceResolver.java,v 1.8 2002/04/26 08:41:52 cziegeler Exp $ */ public interface SourceResolver @@ -69,6 +69,7 @@ * Resolve the source. * @param systemID This is either a system identifier * (<code>java.net.URL</code> or a local file. + * @deprecated Use the resolveURI methods instead */ Source resolve(String systemID) throws ProcessingException, SAXException, IOException; 1.14 +2 -2 xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Index: EnvironmentWrapper.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- EnvironmentWrapper.java 25 Apr 2002 09:30:48 -0000 1.13 +++ EnvironmentWrapper.java 26 Apr 2002 08:41:52 -0000 1.14 @@ -73,7 +73,7 @@ * contains a <code>RequestWrapper</code> object. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version $Id: EnvironmentWrapper.java,v 1.13 2002/04/25 09:30:48 cziegeler Exp $ + * @version $Id: EnvironmentWrapper.java,v 1.14 2002/04/26 08:41:52 cziegeler Exp $ */ public class EnvironmentWrapper extends AbstractEnvironment implements Environment { @@ -111,7 +111,6 @@ Logger logger) throws MalformedURLException { this(env, requestURI, queryString, logger, false); - this.setComponents(env.getSourceResolver(), null); } /** @@ -125,6 +124,7 @@ boolean rawMode) throws MalformedURLException { super(env.getURI(), env.getView(), env.getRootContext(), env.getAction()); + this.setComponents(env.getSourceResolver(), null); this.setLogger(logger); this.environment = env; 1.9 +15 -20 xml-cocoon2/src/java/org/apache/cocoon/generation/FileGenerator.java Index: FileGenerator.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/generation/FileGenerator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- FileGenerator.java 21 Apr 2002 17:34:01 -0000 1.8 +++ FileGenerator.java 26 Apr 2002 08:41:52 -0000 1.9 @@ -54,10 +54,11 @@ import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.CacheValidity; import org.apache.cocoon.caching.Cacheable; -import org.apache.cocoon.caching.TimeStampCacheValidity; -import org.apache.cocoon.environment.Source; +import org.apache.cocoon.caching.SourceCacheValidity; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.util.HashUtil; +import org.apache.excalibur.source.Source; +import org.apache.excalibur.source.SourceException; import org.xml.sax.SAXException; import java.io.IOException; @@ -73,7 +74,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> * (Apache Software Foundation, Exoffice Technologies) * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: FileGenerator.java,v 1.8 2002/04/21 17:34:01 vgritsenko Exp $ + * @version CVS $Id: FileGenerator.java,v 1.9 2002/04/26 08:41:52 cziegeler Exp $ */ public class FileGenerator extends ComposerGenerator implements Cacheable { @@ -86,11 +87,9 @@ * All instance variables are set to <code>null</code>. */ public void recycle() { + super.resolver.release( this.inputSource ); + this.inputSource = null; super.recycle(); - if (this.inputSource != null) { - this.inputSource.recycle(); - this.inputSource = null; - } } /** @@ -100,7 +99,11 @@ public void setup(SourceResolver resolver, Map objectModel, String src, Parameters par) throws ProcessingException, SAXException, IOException { super.setup(resolver, objectModel, src, par); - this.inputSource = resolver.resolve(src); + try { + this.inputSource = resolver.resolveURI(src); + } catch (SourceException se) { + throw new ProcessingException("Error during resolving of '" + src + "'.", se); + } } /** @@ -110,7 +113,7 @@ * @return The generated key hashes the src */ public long generateKey() { - if (this.inputSource.getLastModified() != 0) { + if (this.inputSource.getValidity() != null) { return HashUtil.hash(this.inputSource.getSystemId()); } return 0; @@ -123,9 +126,8 @@ * component is currently not cacheable. */ public CacheValidity generateValidity() { - long modified = this.inputSource.getLastModified(); - if (modified != 0) { - return new TimeStampCacheValidity(modified); + if (this.inputSource.getValidity() != null) { + return new SourceCacheValidity(this.inputSource.getValidity()); } return null; } @@ -140,9 +142,7 @@ this.getLogger().debug("processing file " + super.source); this.getLogger().debug("file resolved to " + this.inputSource.getSystemId()); } - this.inputSource.toSAX(super.xmlConsumer); - } catch (ProcessingException e) { - throw e; + this.resolver.toSAX(this.inputSource, super.xmlConsumer); } catch (SAXException e) { final Exception cause = e.getException(); if( cause != null ) { @@ -157,11 +157,6 @@ + this.inputSource.getSystemId(), cause); } throw e; - } catch (Exception e) { - this.getLogger().error("Could not read resource " - + this.inputSource.getSystemId(), e); - throw new ProcessingException("Could not read resource " - + this.inputSource.getSystemId(), e); } } }
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]