cziegeler 2003/01/28 22:56:02 Modified: sourceresolve/src/java/org/apache/excalibur/source SourceException.java SourceValidity.java TraversableSource.java Source.java SourceResolver.java SourceFactory.java ModifiableSource.java SourceUtil.java SourceParameters.java xmlutil/src/java/org/apache/excalibur/xml/xslt XSLTProcessorImpl.java sourceresolve/src/java/org/apache/excalibur/source/impl ResourceSource.java AbstractSource.java SourceResolverImpl.java URLSource.java store/src/java/org/apache/excalibur/store/impl AbstractJispFilesystemStore.java StoreJanitorImpl.java monitor/src/java/org/apache/avalon/excalibur/monitor SourceResource.java Added: sourceresolve/src/java/org/apache/excalibur/source ModifiableTraversableSource.java Log: Applying patch #16500 by Sylvain Wallez ([EMAIL PROTECTED]) Revision Changes Path 1.7 +28 -9 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceException.java Index: SourceException.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceException.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SourceException.java 9 Jan 2003 08:33:34 -0000 1.6 +++ SourceException.java 29 Jan 2003 06:56:01 -0000 1.7 @@ -54,36 +54,55 @@ */ package org.apache.excalibur.source; -import org.apache.avalon.framework.CascadingException; +import java.io.IOException; + +import org.apache.avalon.framework.CascadingThrowable; /** * This Exception is thrown every time there is a problem in processing - * the source. + * a source. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @version CVS $Revision$ $Date$ */ public class SourceException - extends CascadingException + extends IOException implements CascadingThrowable { /** + * The Throwable that caused this exception to be thrown. + */ + private final Throwable m_throwable; + + /** * Construct a new <code>SourceException</code> instance. * - * @param message The detail message for this exception. + * @param message the detail message for this exception. */ public SourceException( final String message ) { - super( message, null ); + this( message, null ); } /** * Construct a new <code>SourceException</code> instance. * - * @param message The detail message for this exception. - * @param throwable the root cause of the exception + * @param message the detail message for this exception. + * @param throwable the root cause of the exception. */ public SourceException( final String message, final Throwable throwable ) { - super( message, throwable ); + super( message ); + m_throwable = throwable; + } + + /** + * Retrieve the cause of the exception. + * + * @return the cause. + */ + public final Throwable getCause() + { + return m_throwable; } } 1.7 +31 -20 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceValidity.java Index: SourceValidity.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceValidity.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SourceValidity.java 13 Jan 2003 13:14:12 -0000 1.6 +++ SourceValidity.java 29 Jan 2003 06:56:01 -0000 1.7 @@ -57,17 +57,22 @@ import java.io.Serializable; /** - * A Validity object contains all information to check if a Source object is - * still valid. - * There are two possibilities: The validity object has all information - * to check by itself how long it is valid (e.g. given an expires date). - * The other possibility needs another (newer) validity object to compare - * against (e.g. to test a last modification date). - * To avoid testing, what the actual implementation of the validity - * object supports, the invocation order is to first call {@link #isValid()} and only if - * this results in <code>0</code>, then to call {@link #isValid}. - * But remember to call the second isValid(SourceValidity) when <code>0</code> - * is returned by the first invocation! + * A <code>SourceValidity</code> object contains all information to check if a Source + * object is still valid. + * <p> + * There are two possibilities: + * <ul> + * <li>The validity object has all information to check by itself if it is valid + * (e.g. given an expires date).</li> + * <li>The validity object possibility needs another (newer) validity object to compare + * against (e.g. to test a last modification date).</li> + * </ul> + * To avoid testing what the actual implementation of the validity object supports, + * the invocation order is to first call {@link #isValid()} and only if this result + * is <code>0</code> (i.e. "don't know"), then to call {@link #isValid(SourceValidity)}. + * <p> + * Remember to call {@link #isValid(SourceValidity)} when {@link #isValid()} returned + * <code>0</code> ! * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Revision$ $Date$ @@ -75,19 +80,25 @@ public interface SourceValidity extends Serializable { + final int VALID = +1; + final int INVALID = -1; + final int UNKNWON = 0; + /** - * Check if the component is still valid. - * If <code>0</code> is returned the isValid(SourceValidity) must be - * called afterwards! - * If -1 is returned, the component is not valid anymore and if +1 - * is returnd, the component is valid. + * Check if the component is still valid. The possible results are : + * <ul> + * <li><code>-1</code>: invalid. The component isn't valid anymore.</li> + * <li><code>0</code>: don't know. This validity should be checked against a new + * validity object using {@link #isValid(SourceValidity)}.</li> + * <li><code>1</code>: valid. The component is still valid.</li> + * </ul> */ int isValid(); /** - * Check if the component is still valid. - * This is only true, if the incoming Validity is of the same - * type and has the "same" values. + * Check if the component is still valid. This is only true if the incoming Validity + * is of the same type and has the "same" values. + * <p> * The invocation order is that the isValid * method of the old Validity object is called with the new one as a * parameter. 1.3 +51 -11 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/TraversableSource.java Index: TraversableSource.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/TraversableSource.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- TraversableSource.java 9 Jan 2003 08:33:34 -0000 1.2 +++ TraversableSource.java 29 Jan 2003 06:56:01 -0000 1.3 @@ -54,7 +54,6 @@ */ package org.apache.excalibur.source; -import org.apache.excalibur.source.Source; import java.util.Collection; @@ -63,26 +62,67 @@ * a parent, like a file system. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @version CVS $Revision$ $Date$ */ public interface TraversableSource extends Source { /** - * Does this source point to a directory? + * Does this source point to a directory (i.e. it possibly has children) ? + * + * @return true if the source is a directory. */ - boolean hasChildren(); + boolean isDirectory(); /** - * Return the URIs of the children - * The returned URIs are relative to the URI of the parent - * (this object) + * Get the absolute URIs of the children of this source. + * + * @return a possibly-empty collection if this source is a directory, + * <code>null</code> otherwise + * @throws SourceException if some problem occurs. */ - Collection getChildrenLocations() throws SourceException; + Collection getChildrenURIs() throws SourceException; /** - * Return the complete URI of the parent source. - * The method should return null if the source hasn't a parent. + * Get the children of this source as {@link Source} objects. + * <p> + * <em>Note:</em> only those sources actually fetched from the + * collection need to be released using the {@link SourceResolver}. + * + * @return a possibly-empty collection if this source is a directory, + * <code>null</code> otherwise + * @throws SourceException if some problem occurs. */ - String getParentLocation() throws SourceException; + Collection getChildrenSources() throws SourceException; + + /** + * Get the children of this source as relative names. + * @return a possibly-empty collection if this source is a directory, + * <code>null</code> otherwise + * @throws SourceException if some problem occurs. + */ + Collection getChildrenNames() throws SourceException; + + /** + * Return the name of this source relative to its parent. + * @throws SourceException if some problem occurs. + */ + String getName() throws SourceException; + + /** + * Return the absolute URI of the parent source. + * + * @return the parent URI, or <code>null</code> if this source has no parent. + * @throws SourceException if some problem occurs. + */ + String getParentURI() throws SourceException; + + /** + * Get the parent of this source as a {@link Source} object. + * + * @return the parent source, or <code>null</code> if this source has no parent. + * @throws SourceException if some problem occurs. + */ + Source getParentSource() throws SourceException; } 1.14 +64 -57 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/Source.java Index: Source.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/Source.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- Source.java 9 Jan 2003 08:45:51 -0000 1.13 +++ Source.java 29 Jan 2003 06:56:01 -0000 1.14 @@ -56,24 +56,22 @@ import java.io.IOException; import java.io.InputStream; -import java.util.Iterator; /** - * Description of a source. This interface provides a simple interface - * for accessing a source of data. - * + * This interface provides a simple interface for accessing a source of data. + * <p> * When the <code>Source</code> object is no longer needed - * it must be released using the resolver. This is very similar like - * looking up components from a <code>ComponentLocator</code>. + * it must be released using the {@link SourceResolver}. This is very similar to + * looking up components from a <code>ServiceSelector</code>. * In fact a source object can implement most lifecycle interfaces * like Composable, Initializable, Disposable etc. - * - * Thee data content can be constant or change over time. - * Using the getInputStream() method you get always the upto-date content. - * When you're done with using the source object, you have to release it. + * <p> + * The data content can be constant or change over time. + * Using the {@link #getInputStream()} method you get always the up-to-date content. + * <p> * If you want to track changes of the source object, this interface * offers you some support for it by providing a SourceValidity object. - * + * <p> * How does the caching work? * The first time you get a Source object, you simply ask * it for it's content via getInputStream() and then get the validity @@ -84,96 +82,105 @@ * The next time, the caching algorithm wants to check if the cached * content is still valid. It has a validity object already to check * against. - * + * <p> * If it is still the same Source than the first time, you - * have to call discardValidity() in order to discard the stored validity + * have to call refresh() in order to discard the stored validity * in the Source object. If it is a new Source object, - * calling discardValidity() should do no harm. - * After that an upto-date validity object can retrieved by calling + * calling refresh() should do no harm. + * After that an up-to-date validity object can retrieved by calling * getValidity(). This can be used to test if the content is still valid * as discribed in the source validity documentation. * If the content is still valid, the cache knows what to do, if not, * the new content can be get using getInputStream(). * So either after a call to getValidity() or the getInputStream the - * validity object must be the same until discardValidity is called! + * validity object must be the same until refresh is called! * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @version CVS $Revision$ $Date$ */ public interface Source { /** - * Return an <code>InputStream</code> object to read from the source. + * Does this source exist ? + * + * @return true if the source exists + */ + public boolean exists(); + + /** + * Return an <code>InputStream</code> to read from the source. * This is the data at the point of invocation of this method, * so if this is Modifiable, you might get different content * from two different invocations. + * + * @return the <code>InputStream</code> to read data from (never <code>null</code>). + * @throws IOException if some I/O problem occurs. + * @throws SourceNotFoundException if the source doesn't exist. */ InputStream getInputStream() - throws IOException, SourceException; + throws IOException, SourceNotFoundException; /** - * Return the unique identifier for this source + * Get the absolute URI for this source. + * + * @return the source URI. */ - String getSystemId(); + String getURI(); /** - * Return the protocol identifier. + * Return the URI scheme identifier, i.e. the part preceding the fist ':' in the URI + * (see <a href="http://www.ietf.org/rfc/rfc2396.txt">RFC 2396</a>). + * <p> + * This scheme can be used to get the {@link SourceFactory} responsible for this object. + * + * @return the URI scheme. */ - String getProtocol(); + String getScheme(); /** - * 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. + * Get the Validity object. This can either wrap the last modification date or + * some expiry information or anything else describing this object's validity. + * <p> + * If it is currently not possible to calculate such an information, + * <code>null</code> is returned. + * + * @return the validity, or <code>null</code>. */ SourceValidity getValidity(); /** - * Refresh the content of this object after the underlying data - * content has changed. + * Refresh the content of this object after the underlying data content has changed. + * <p> + * Some implementations may cache some values to speedup sucessive calls. Refreshing + * ensures you get the latest information. */ - void discardValidity(); + void refresh(); /** - * The mime-type of the content described by this object. + * Get 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>. + * + * @return the source's mime-type or <code>null</code>. */ String getMimeType(); /** - * Return the content length of the content or -1 if the length is - * unknown + * Get the content length of this source's content or -1 if the length is + * unknown. + * + * @return the source's content length or -1. */ long getContentLength(); /** - * Get the last modification date. - * @return The last modification in milliseconds since January 1, 1970 GMT - * or 0 if it is unknown + * Get the last modification date of this source. The date is + * measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), + * and is <code>0</code> if it's unknown. + * + * @return the last modification date or <code>0</code>. */ long getLastModified(); - - /** - * 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. - */ - String getParameter( String name ); - - /** - * 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. - */ - long getParameterAsLong( String name ); - - /** - * Get parameter names - * Using this it is possible to get custom information provided by the - * source implementation, like an expires date, HTTP headers etc. - */ - Iterator getParameterNames(); } 1.7 +14 -7 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceResolver.java Index: SourceResolver.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceResolver.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- SourceResolver.java 15 Dec 2002 11:56:48 -0000 1.6 +++ SourceResolver.java 29 Jan 2003 06:56:01 -0000 1.7 @@ -88,10 +88,13 @@ /** * Get a <code>Source</code> object. * This is a shortcut for <code>resolve(location, null, null)</code> - * @throws SourceNotFoundException if the source cannot be found + * + * @return the resolved source object. + * @throws MalformetURLException if <code>location</code> is malformed. + * @throws IOException if the source couldn't be created for some other reason. */ Source resolveURI( String location ) - throws MalformedURLException, IOException, SourceException; + throws MalformedURLException, IOException; /** * Get a <code>Source</code> object. @@ -102,16 +105,20 @@ * @param base - a base URI for resolving relative locations. This * is optional and can be <code>null</code>. * @param parameters - Additional parameters for the URI. The parameters - * are specific to the used protocol. - * @throws SourceNotFoundException if the source cannot be found + * are specific to the used scheme. + * @return the resolved source object. + * @throws MalformetURLException if <code>location</code> is malformed. + * @throws IOException if the source couldn't be created for some other reason. */ Source resolveURI( String location, String base, Map parameters ) - throws MalformedURLException, IOException, SourceException; + throws MalformedURLException, IOException; /** - * Releases a resolved resource + * Releases a resolved resource. + * + * @param source the source to release. */ void release( Source source ); } 1.6 +18 -9 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceFactory.java Index: SourceFactory.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- SourceFactory.java 15 Dec 2002 11:56:48 -0000 1.5 +++ SourceFactory.java 29 Jan 2003 06:56:01 -0000 1.6 @@ -62,12 +62,12 @@ /** * A source factory creates new source objects. - * + * <p> * Source factories are used to extend the source resolving mechanism - * with a new protocol. A new source factory is added in order to + * with new URI schemes. A new source factory is added in order to * handle a specific prototol. The {@link SourceResolver} delegates - * the handling of a URI containing this new protocol to the factory - * and the factory can created a coresponding {@link Source} object. + * the handling of a URI containing this new scheme to the factory, + * and the factory can create a corresponding {@link Source} object. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version $Id$ @@ -82,16 +82,25 @@ * The factory creates a new {@link Source} object that can be used * by the application. However, when this source object is not needed * anymore it has to be released again using the {@link #release(Source)} - * method. + * method. This is achieved by using {@link SourceResolver#release(Source)} which + * finds the appropriate <code>SourceFactory</code>. * - * @param location The URI to resolve - this URI includes the protocol. - * @param parameters This is optional. + * @param location The URI to resolve - this URI includes the scheme. + * @param parameters additionnal named parameters (optionnal and can be <code>null</code>) + * that drive the creation of the <code>Source</code> object. Each implementation + * must specify what parameters it accepts. + * @return the created source object. + * @throws MalformedURLException if the location is malformed. + * @throws IOException if the source couldn't be created for some other reason. */ + //FIXME : can we really have an IOException here ? Source getSource( String location, Map parameters ) - throws MalformedURLException, IOException, SourceException; + throws MalformedURLException, IOException; /** * Release a {@link Source} object. + * + * @param source the source to release. */ void release( Source source ); } 1.4 +12 -4 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/ModifiableSource.java Index: ModifiableSource.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/ModifiableSource.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ModifiableSource.java 9 Jan 2003 08:56:10 -0000 1.3 +++ ModifiableSource.java 29 Jan 2003 06:56:01 -0000 1.4 @@ -54,14 +54,22 @@ */ package org.apache.excalibur.source; +import java.io.IOException; import java.io.OutputStream; /** - * Description of a modifiable source. This interface provides a - * simple interface for manipulation data. - * for accessing a source of data. + * A {@link Source} that can be written to. + * <p> + * As far a possible, implementations should provide a kind of transaction or + * buffering of data written to the source. This is especially important in + * stream-based systems such as Cocoon where an error that occurs during the + * processing should lead to cancelling data written to the source. + * <p> + * This is the role of the {@link #canCancel(OutputStream)} and + * {@link #cancel(OutputStream)} methods. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @version CVS $Revision$ $Date$ */ public interface ModifiableSource @@ -70,7 +78,7 @@ /** * Return an {@link OutputStream} to write to. */ - OutputStream getOutputStream(); + OutputStream getOutputStream() throws IOException; /** * Delete the source 1.4 +2 -2 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceUtil.java Index: SourceUtil.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceUtil.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- SourceUtil.java 15 Dec 2002 11:56:48 -0000 1.3 +++ SourceUtil.java 29 Jan 2003 06:56:01 -0000 1.4 @@ -317,7 +317,7 @@ */ public static File getFile( Source source ) { - final String systemId = source.getSystemId(); + final String systemId = source.getURI(); if( systemId.startsWith( "file:" ) ) { return new File( systemId.substring( 5 ) ); 1.5 +8 -2 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceParameters.java Index: SourceParameters.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceParameters.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SourceParameters.java 15 Dec 2002 11:56:48 -0000 1.4 +++ SourceParameters.java 29 Jan 2003 06:56:01 -0000 1.5 @@ -68,7 +68,13 @@ /** * This class holds parameters for a <code>Source</code> object. * It differs from the usual Parameters object because it can hold - * more than one value for a parameter. + * more than one value for a parameter, as is the case for HTTP + * request parameters. + * <p> + * Only particular kinds of <code>Source</code> implementations, such as + * {@link org.apache.excalibur.source.impl.URLSource} support this kind of + * parameters, passed as an entry in the <code>parameters</code> argument of + * {@link SourceResolver#resolveURI(String, String, Map)}. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version $Id$ 1.1 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/ModifiableTraversableSource.java Index: ModifiableTraversableSource.java =================================================================== /* ==================================================================== * The Apache Software License, Version 1.1 * * Copyright (c) 2002 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, 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 "Jakarta", "Avalon", 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 (INCLUDING, 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. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package org.apache.excalibur.source; /** * A modifiable traversable source. This adds to {@link ModifiableSource} the * ability to create a directory. * * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @version CVS $Revision: 1.1 $ $Date: 2003/01/29 06:56:01 $ */ public interface ModifiableTraversableSource extends ModifiableSource, TraversableSource { /** * If it doesn't already exist, create the directory corresponding to this source * (equivalent to <code>File.mkdirs()</code>) * <p> * If the source already exists, this method does nothing if it's already * a directory, and fails otherwise. */ public void makeDirectory() throws SourceException; } 1.24 +7 -7 jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/xslt/XSLTProcessorImpl.java Index: XSLTProcessorImpl.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/xmlutil/src/java/org/apache/excalibur/xml/xslt/XSLTProcessorImpl.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- XSLTProcessorImpl.java 22 Jan 2003 02:18:17 -0000 1.23 +++ XSLTProcessorImpl.java 29 Jan 2003 06:56:01 -0000 1.24 @@ -189,7 +189,7 @@ { try { - final String id = stylesheet.getSystemId(); + final String id = stylesheet.getURI(); TransformerHandlerAndValidity handlerAndValidity = getTemplates( stylesheet, id ); if( null == handlerAndValidity ) { @@ -238,7 +238,7 @@ { throw new XSLTProcessorException( "Unable to create templates for stylesheet: " - + stylesheet.getSystemId() ); + + stylesheet.getURI() ); } putTemplates( template, stylesheet, id ); @@ -311,7 +311,7 @@ { final InputStream inputStream = source.getInputStream(); final String mimeType = source.getMimeType(); - final String systemId = source.getSystemId(); + final String systemId = source.getURI(); m_xmlizer.toSAX( inputStream, mimeType, systemId, handler ); } } @@ -624,7 +624,7 @@ if( getLogger().isDebugEnabled() ) { - getLogger().debug( "xslSource = " + xslSource + ", system id = " + xslSource.getSystemId() ); + getLogger().debug( "xslSource = " + xslSource + ", system id = " + xslSource.getURI() ); } // Populate included validities @@ -634,7 +634,7 @@ SourceValidity included = xslSource.getValidity(); if( included != null ) { - includes.add( new Object[]{xslSource.getSystemId(), xslSource.getValidity()} ); + includes.add( new Object[]{xslSource.getURI(), xslSource.getValidity()} ); } else { @@ -694,7 +694,7 @@ throws IOException, SourceException { final InputSource newObject = new InputSource( source.getInputStream() ); - newObject.setSystemId( source.getSystemId() ); + newObject.setSystemId( source.getURI() ); return newObject; } } 1.8 +20 -12 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/ResourceSource.java Index: ResourceSource.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/ResourceSource.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- ResourceSource.java 27 Jan 2003 10:38:44 -0000 1.7 +++ ResourceSource.java 29 Jan 2003 06:56:01 -0000 1.8 @@ -83,7 +83,12 @@ this.systemId = systemId; final int pos = systemId.indexOf( "://" ); m_location = systemId.substring( pos + 3 ); - this.protocol = systemId.substring(0, pos); + this.scheme = systemId.substring(0, pos); + } + + public boolean exists() + { + return getClassLoader().getResource( m_location ) != null; } /** @@ -92,27 +97,30 @@ public InputStream getInputStream() throws IOException, SourceException { - ClassLoader loader = Thread.currentThread().getContextClassLoader(); - if( loader == null ) - { - loader = getClass().getClassLoader(); - } - InputStream in = loader.getResourceAsStream( m_location ); + InputStream in = getClassLoader().getResourceAsStream( m_location ); if ( in == null ) throw new SourceNotFoundException( "Source '"+m_location+"' was not found" ); return in; } /** - * 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. + * Returns {@link NOPValidity#SHARED_INSTANCE} since a resource doesn't change. + * */ public SourceValidity getValidity() { // we are always valid return NOPValidity.SHARED_INSTANCE; + } + + private ClassLoader getClassLoader() { + ClassLoader loader = Thread.currentThread().getContextClassLoader(); + if( loader == null ) + { + loader = getClass().getClassLoader(); + } + + return loader; } } 1.9 +6 -60 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/AbstractSource.java Index: AbstractSource.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/AbstractSource.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- AbstractSource.java 8 Jan 2003 21:33:51 -0000 1.8 +++ AbstractSource.java 29 Jan 2003 06:56:01 -0000 1.9 @@ -56,9 +56,6 @@ import java.io.IOException; import java.io.InputStream; -import java.util.Collections; -import java.util.Collection; -import java.util.Iterator; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; @@ -79,7 +76,7 @@ protected long contentLength; protected String systemId; - protected String protocol; + protected String scheme; /** * Get the last modification date and content length of the source. @@ -117,7 +114,7 @@ /** * Return the unique identifer for this source */ - public String getSystemId() + public String getURI() { return this.systemId; } @@ -125,9 +122,9 @@ /** * Return the protocol identifier. */ - public String getProtocol() + public String getScheme() { - return this.protocol; + return this.scheme; } /** @@ -145,7 +142,7 @@ * Refresh this object and update the last modified date * and content length. */ - public void discardValidity() + public void refresh() { this.gotInfos = false; } @@ -178,56 +175,5 @@ { checkInfos(); return this.lastModificationDate; - } - - /** - * 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( final String name ) - { - checkInfos(); - 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( final String name ) - { - checkInfos(); - 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() - { - checkInfos(); - return Collections.EMPTY_LIST.iterator(); - } - - /** - * Does this source point to a directory? - */ - public boolean isDirectory() - { - return false; - } - - /** - * Return the URIs of the children - * The returned URIs are relative to the URI of the parent - * (this object) - */ - public Collection getChildrenLocations() - { - return Collections.EMPTY_LIST; } } 1.23 +9 -8 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/SourceResolverImpl.java Index: SourceResolverImpl.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/SourceResolverImpl.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- SourceResolverImpl.java 17 Jan 2003 14:26:21 -0000 1.22 +++ SourceResolverImpl.java 29 Jan 2003 06:56:01 -0000 1.23 @@ -61,6 +61,8 @@ import java.util.Map; import org.apache.avalon.framework.activity.Disposable; +import org.apache.avalon.framework.component.ComponentException; +import org.apache.avalon.framework.component.ComponentSelector; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.context.ContextException; import org.apache.avalon.framework.context.Contextualizable; @@ -70,7 +72,6 @@ import org.apache.avalon.framework.parameters.Parameters; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; -import org.apache.avalon.framework.service.ServiceSelector; import org.apache.avalon.framework.service.Serviceable; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.excalibur.source.Source; @@ -114,7 +115,7 @@ protected ServiceManager m_manager; /** The special Source factories */ - protected ServiceSelector m_factorySelector; + protected ComponentSelector m_factorySelector; /** The context */ protected Context m_context; @@ -180,7 +181,7 @@ throws ServiceException { m_manager = manager; - m_factorySelector = (ServiceSelector)m_manager.lookup( SourceFactory.ROLE + "Selector" ); + m_factorySelector = (ComponentSelector)m_manager.lookup( SourceFactory.ROLE + "Selector" ); } public void dispose() @@ -314,7 +315,7 @@ factory = (SourceFactory)m_factorySelector.select( protocol ); source = factory.getSource( systemID, parameters ); } - catch( final ServiceException ce ) + catch( final ComponentException ce ) { // no selector available, use fallback //throw new SourceException( "Unable to select source factory for protocol " + protocol, ce ); @@ -384,14 +385,14 @@ if( source == null ) return; // search for a SourceFactory implementing the protocol - final String protocol = source.getProtocol(); + final String scheme = source.getScheme(); SourceFactory factory = null; try { - factory = (SourceFactory)m_factorySelector.select( protocol ); + factory = (SourceFactory)m_factorySelector.select( scheme ); factory.release( source ); } - catch( ServiceException ce ) + catch( ComponentException ce ) { //no factory available, so use fallback //throw new CascadingRuntimeException( "Unable to select source factory for protocol " + protocol, ce ); 1.18 +21 -4 jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java Index: URLSource.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- URLSource.java 8 Jan 2003 21:33:50 -0000 1.17 +++ URLSource.java 29 Jan 2003 06:56:01 -0000 1.18 @@ -111,6 +111,9 @@ /** Is this a post? */ protected boolean isPost = false; + + /** Does this source exist ? */ + protected boolean exists = false; /** the prev returned SourceValidity */ @@ -135,7 +138,7 @@ { this.systemId = url.toExternalForm(); int pos = systemId.indexOf(':'); - this.protocol = systemId.substring(0, pos); + this.scheme = systemId.substring(0, pos); if (systemId.startsWith( FILE )) { this.file = new File( this.systemId.substring( FILE.length() ) ); @@ -192,10 +195,14 @@ */ protected void getInfos() { + // exists will be set below depending on the url type + this.exists = false; + if( null != this.file ) { this.lastModificationDate = this.file.lastModified(); this.contentLength = this.file.length(); + this.exists = this.file.exists(); } else { @@ -214,6 +221,7 @@ } this.lastModificationDate = this.connection.getLastModified(); this.contentLength = this.connection.getContentLength(); + this.exists = true; } catch( IOException ignore ) { @@ -229,6 +237,15 @@ } /** + * Does this source exist ? + */ + public boolean exists() + { + this.checkInfos(); + return this.exists; + } + + /** * Return an <code>InputStream</code> object to read from the source. * * @throws SourceException if file not found or @@ -393,11 +410,11 @@ * Refresh this object and update the last modified date * and content length. */ - public void discardValidity() + public void refresh() { // reset connection this.connection = null; - super.discardValidity(); + super.refresh(); } /** 1.2 +1 -2 jakarta-avalon-excalibur/store/src/java/org/apache/excalibur/store/impl/AbstractJispFilesystemStore.java Index: AbstractJispFilesystemStore.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/store/src/java/org/apache/excalibur/store/impl/AbstractJispFilesystemStore.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AbstractJispFilesystemStore.java 12 Oct 2002 10:36:55 -0000 1.1 +++ AbstractJispFilesystemStore.java 29 Jan 2003 06:56:01 -0000 1.2 @@ -22,7 +22,6 @@ import java.io.IOException; import java.io.Serializable; import java.util.Enumeration; -import java.util.Vector; /** * This store is based on the Jisp library 1.2 +2 -2 jakarta-avalon-excalibur/store/src/java/org/apache/excalibur/store/impl/StoreJanitorImpl.java Index: StoreJanitorImpl.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/store/src/java/org/apache/excalibur/store/impl/StoreJanitorImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- StoreJanitorImpl.java 2 May 2002 08:55:39 -0000 1.1 +++ StoreJanitorImpl.java 29 Jan 2003 06:56:02 -0000 1.2 @@ -138,7 +138,7 @@ } } try { - Thread.currentThread().sleep(this.cleanupthreadinterval * 1000); + Thread.sleep(this.cleanupthreadinterval * 1000); } catch (InterruptedException ignore) {} } } 1.10 +4 -4 jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/SourceResource.java Index: SourceResource.java =================================================================== RCS file: /home/cvs/jakarta-avalon-excalibur/monitor/src/java/org/apache/avalon/excalibur/monitor/SourceResource.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- SourceResource.java 14 Jan 2003 07:45:10 -0000 1.9 +++ SourceResource.java 29 Jan 2003 06:56:02 -0000 1.10 @@ -36,7 +36,7 @@ public SourceResource( final Source source ) throws Exception { - super( source.getSystemId() ); + super( source.getURI() ); m_source = source; setPreviousModified( System.currentTimeMillis() ); @@ -58,7 +58,7 @@ boolean isValid = false; SourceValidity newVal = null; if ( valid == 0 ) { - m_source.discardValidity(); + m_source.refresh(); newVal = m_source.getValidity(); if( newVal != null) { @@ -72,7 +72,7 @@ return getPreviousModified(); } else { if ( null == newVal ) { - m_source.discardValidity(); + m_source.refresh(); m_validity = m_source.getValidity(); } return System.currentTimeMillis();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]