avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl ResourceSourceFactory.java SourceResolverImpl.java URLSource.java
Date Wed, 24 Apr 2002 12:35:38 GMT
cziegeler    02/04/24 05:35:37

  Modified:    monitor/src/java/org/apache/avalon/excalibur/monitor
                        SourceResource.java
               sourceresolve/src/java/org/apache/excalibur/source
                        Source.java SourceFactory.java SourceResolver.java
               sourceresolve/src/java/org/apache/excalibur/source/impl
                        ResourceSourceFactory.java SourceResolverImpl.java
                        URLSource.java
  Added:       sourceresolve/src/java/org/apache/excalibur/source
                        SourceException.java
  Log:
  Adding SourceException instead of ComponentException
  
  Revision  Changes    Path
  1.3       +17 -10    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SourceResource.java	21 Apr 2002 21:47:49 -0000	1.2
  +++ SourceResource.java	24 Apr 2002 12:35:37 -0000	1.3
  @@ -14,14 +14,15 @@
   import java.io.Reader;
   import java.io.Writer;
   import org.apache.excalibur.source.Source;
  +import org.apache.excalibur.source.SourceException;
   import org.apache.excalibur.source.SourceValidity;
   
   /**
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version $Id: SourceResource.java,v 1.2 2002/04/21 21:47:49 donaldp Exp $
  + * @version $Id: SourceResource.java,v 1.3 2002/04/24 12:35:37 cziegeler Exp $
    */
  -public final class SourceResource 
  +public final class SourceResource
       extends StreamResource
   {
       /** The wrapped source object */
  @@ -70,17 +71,23 @@
       /**
        * Sets the resource value with an OutputStream
        */
  -    public InputStream getResourceAsStream() 
  -	throws IOException
  +    public InputStream getResourceAsStream()
  +    throws IOException
       {
  -        return m_source.getInputStream();
  +        try {
  +            return m_source.getInputStream();
  +        }
  +        catch (SourceException se)
  +        {
  +            throw new IOException("SourceException: " + se.getMessage());
  +        }
       }
   
       /**
        * Sets the resource value with a Writer
        */
       public Reader getResourceAsReader()
  -	throws IOException
  +    throws IOException
       {
           return new InputStreamReader( getResourceAsStream() );
       }
  @@ -88,8 +95,8 @@
       /**
        * Sets the resource value with an OutputStream
        */
  -    public OutputStream setResourceAsStream() 
  -	throws IOException
  +    public OutputStream setResourceAsStream()
  +    throws IOException
       {
           throw new IOException( "setResourceAsStream() not supported for URLResource" );
       }
  @@ -97,8 +104,8 @@
       /**
        * Sets the resource value with a Writer
        */
  -    public Writer setResourceAsWriter() 
  -	throws IOException
  +    public Writer setResourceAsWriter()
  +    throws IOException
       {
           throw new IOException( "setResourceAsWriter() not supported for URLResource" );
       }
  
  
  
  1.3       +2 -2      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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Source.java	22 Apr 2002 09:13:55 -0000	1.2
  +++ Source.java	24 Apr 2002 12:35:37 -0000	1.3
  @@ -50,7 +50,7 @@
    * validity object must be the same until discardValidity is called!
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2002/04/22 09:13:55 $
  + * @version CVS $Revision: 1.3 $ $Date: 2002/04/24 12:35:37 $
    */
   public interface Source {
   
  @@ -61,7 +61,7 @@
        * from two different invocations.
        */
       InputStream getInputStream()
  -        throws IOException;
  +        throws IOException, SourceException;
   
       /**
        * Return the unique identifer for this source
  
  
  
  1.2       +3 -3      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceFactory.java	19 Apr 2002 09:05:37 -0000	1.1
  +++ SourceFactory.java	24 Apr 2002 12:35:37 -0000	1.2
  @@ -14,10 +14,10 @@
   
   /**
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version $Id: SourceFactory.java,v 1.1 2002/04/19 09:05:37 cziegeler Exp $
  + * @version $Id: SourceFactory.java,v 1.2 2002/04/24 12:35:37 cziegeler Exp $
    */
   public interface SourceFactory
  -    extends Component
  +   extends Component
   {
   
       String ROLE = SourceFactory.class.getName();
  @@ -27,6 +27,6 @@
        * @param parameters This is optional.
        */
       Source getSource( String location, Map parameters )
  -        throws MalformedURLException, IOException;
  +        throws MalformedURLException, IOException, SourceException;
   
   }
  
  
  
  1.2       +4 -5      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SourceResolver.java	19 Apr 2002 09:05:37 -0000	1.1
  +++ SourceResolver.java	24 Apr 2002 12:35:37 -0000	1.2
  @@ -11,7 +11,6 @@
   import java.net.MalformedURLException;
   import java.util.Map;
   import org.apache.avalon.framework.component.Component;
  -import org.apache.avalon.framework.component.ComponentException;
   
   /**
    * Base interface for resolving a source by system identifiers.
  @@ -30,11 +29,11 @@
    * like Composable, Initializable, Disposable etc.
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/04/19 09:05:37 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/04/24 12:35:37 $
    */
   
   public interface SourceResolver
  -    extends Component
  +   extends Component
   {
       String ROLE = SourceResolver.class.getName();
   
  @@ -43,7 +42,7 @@
        * This is a shortcut for <code>resolve(location, null, null)</code>
        */
       Source resolveURI( String location )
  -        throws MalformedURLException, IOException, ComponentException;
  +        throws MalformedURLException, IOException, SourceException;
   
       /**
        * Get a <code>Source</code> object.
  @@ -59,7 +58,7 @@
       Source resolveURI( String location,
                          String base,
                          Map parameters )
  -        throws MalformedURLException, IOException, ComponentException;
  +        throws MalformedURLException, IOException, SourceException;
   
       /**
        * Releases a resolved resource
  
  
  
  1.1                  jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/SourceException.java
  
  Index: SourceException.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE.txt file.
   */
  
  package org.apache.excalibur.source;
  
  import java.io.PrintStream;
  import java.io.PrintWriter;
  import org.apache.avalon.framework.CascadingException;
  
  /**
   * This Exception is thrown every time there is a problem in processing
   * the source.
   *
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Revision: 1.1 $ $Date: 2002/04/24 12:35:37 $
   */
  public class SourceException
      extends CascadingException {
  
      /**
       * Construct a new <code>SourceException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public SourceException( final String message )
      {
          super( 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
       */
      public SourceException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  
      public String toString() {
          StringBuffer s = new StringBuffer();
          s.append(super.toString());
          if(getCause()!=null) {
              s.append(": ");
              s.append(getCause().toString());
          }
          return s.toString();
      }
  
      public void printStackTrace() {
          super.printStackTrace();
          if(getCause()!=null)
              getCause().printStackTrace();
      }
  
      public void printStackTrace( PrintStream s ) {
          super.printStackTrace(s);
          if(getCause()!=null)
              getCause().printStackTrace(s);
      }
  
      public void printStackTrace( PrintWriter s ) {
          super.printStackTrace(s);
          if(getCause()!=null)
              getCause().printStackTrace(s);
      }
  }
  
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/ResourceSourceFactory.java
  
  Index: ResourceSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/sourceresolve/src/java/org/apache/excalibur/source/impl/ResourceSourceFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceSourceFactory.java	19 Apr 2002 09:05:37 -0000	1.1
  +++ ResourceSourceFactory.java	24 Apr 2002 12:35:37 -0000	1.2
  @@ -17,7 +17,7 @@
   /**
    * A factory for the Resource protocol
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version $Id: ResourceSourceFactory.java,v 1.1 2002/04/19 09:05:37 cziegeler Exp $
  + * @version $Id: ResourceSourceFactory.java,v 1.2 2002/04/24 12:35:37 cziegeler Exp $
    */
   public class ResourceSourceFactory
       extends AbstractLogEnabled
  @@ -29,7 +29,7 @@
        * @param parameters This is optional.
        */
       public Source getSource( String location, Map parameters )
  -        throws MalformedURLException, IOException
  +        throws MalformedURLException, IOException, SourceException
       {
           if( this.getLogger().isDebugEnabled() )
           {
  
  
  
  1.3       +23 -12    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SourceResolverImpl.java	24 Apr 2002 08:25:42 -0000	1.2
  +++ SourceResolverImpl.java	24 Apr 2002 12:35:37 -0000	1.3
  @@ -51,7 +51,7 @@
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version $Id: SourceResolverImpl.java,v 1.2 2002/04/24 08:25:42 cziegeler Exp $
  + * @version $Id: SourceResolverImpl.java,v 1.3 2002/04/24 12:35:37 cziegeler Exp $
    */
   public class SourceResolverImpl
       extends AbstractLogEnabled
  @@ -167,7 +167,7 @@
        * Get a <code>Source</code> object.
        */
       public Source resolveURI( String location )
  -        throws MalformedURLException, IOException, ComponentException
  +        throws MalformedURLException, IOException, SourceException
       {
           return this.resolveURI( location, null, null );
       }
  @@ -178,7 +178,7 @@
       public Source resolveURI( String location,
                                 String baseURI,
                                 Map parameters )
  -        throws MalformedURLException, IOException, ComponentException
  +        throws MalformedURLException, IOException, SourceException
       {
           if( this.getLogger().isDebugEnabled() )
           {
  @@ -265,6 +265,10 @@
                       factory = (SourceFactory)m_factorySelector.select( protocol );
                       source = factory.getSource( systemID, parameters );
                   }
  +                catch (ComponentException ce)
  +                {
  +                    throw new SourceException("ComponentException.", ce);
  +                }
                   finally
                   {
                       m_factorySelector.release( factory );
  @@ -294,7 +298,7 @@
                   }
                   catch (Exception ie)
                   {
  -                    throw new ComponentException("Unable to create new instance of " +
  +                    throw new SourceException("Unable to create new instance of " +
                                                    this.m_urlSourceClass, ie);
                   }
               }
  @@ -314,7 +318,7 @@
                   }
                   catch (Exception ie)
                   {
  -                    throw new ComponentException("Unable to create new instance of " +
  +                    throw new SourceException("Unable to create new instance of " +
                                                    this.m_urlSourceClass, ie);
                   }
               }
  @@ -323,21 +327,28 @@
           {
               ( (LogEnabled)source ).enableLogging( getLogger() );
           }
  -        try
  +        if( source instanceof Contextualizable )
           {
  -            if( source instanceof Contextualizable )
  +            try
               {
                   ( (Contextualizable)source ).contextualize( m_context );
               }
  -        }
  -        catch( ContextException ce )
  -        {
  -            throw new ComponentException( "ContextException occured during source resolving.",
ce );
  +            catch( ContextException ce )
  +            {
  +                throw new SourceException( "ContextException occured during source resolving.",
ce );
  +            }
           }
   
           if( source instanceof Composable )
           {
  -            ( (Composable)source ).compose( m_manager );
  +            try
  +            {
  +                ( (Composable)source ).compose( m_manager );
  +            }
  +            catch( ComponentException ce )
  +            {
  +                throw new SourceException( "ComponentException occured during source resolving.",
ce );
  +            }
           }
           return source;
       }
  
  
  
  1.6       +2 -19     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- URLSource.java	24 Apr 2002 08:25:42 -0000	1.5
  +++ URLSource.java	24 Apr 2002 12:35:37 -0000	1.6
  @@ -24,7 +24,7 @@
    * Description of a source which is described by an URL.
    *
    * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
  - * @version CVS $Revision: 1.5 $ $Date: 2002/04/24 08:25:42 $
  + * @version CVS $Revision: 1.6 $ $Date: 2002/04/24 12:35:37 $
    */
   
   public class URLSource
  @@ -180,23 +180,6 @@
       }
   
       /**
  -     *  Get the corresponding Resource object for monitoring.
  -    public Resource getResource()
  -        throws Exception
  -    {
  -        this.getInfos();
  -        if( this.isFile == true )
  -        {
  -            return new FileResource( this.systemId.substring( FILE.length() ) );
  -        }
  -        else
  -        {
  -            return new SourceResource( this );
  -        }
  -    }
  -     */
  -
  -    /**
        * Return an <code>InputStream</code> object to read from the source.
        *
        * @throws ResourceNotFoundException if file not found or
  @@ -204,7 +187,7 @@
        * @throws IOException if I/O error occured.
        */
       public InputStream getInputStream()
  -        throws IOException
  +        throws IOException, SourceException
       {
           this.getInfos();
           InputStream input = null;
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message