org.apache.excalibur.source.impl
Class URLSourceFactory

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.excalibur.source.impl.URLSourceFactory
All Implemented Interfaces:
org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.parameters.Parameterizable, org.apache.avalon.framework.thread.ThreadSafe, SourceFactory
Direct Known Subclasses:
FTPSourceFactory

public class URLSourceFactory
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.avalon.framework.parameters.Parameterizable, SourceFactory, org.apache.avalon.framework.thread.ThreadSafe

A factory for a URL wrapper

Version:
$Id: URLSourceFactory.java 564 2006-03-25 08:33:32Z jbq $
Author:
Avalon Development Team

Field Summary
(package private)  org.apache.avalon.framework.parameters.Parameters parameters
           
 
Fields inherited from interface org.apache.excalibur.source.SourceFactory
ROLE
 
Constructor Summary
URLSourceFactory()
           
 
Method Summary
protected  Source createFileSource(java.lang.String uri)
          Create an file-based source.
protected  Source createURLSource(java.net.URL url, java.util.Map parameters)
          Create an URL-based source.
 Source getSource(java.lang.String uri, java.util.Map parameters)
          Get a Source object.
 void parameterize(org.apache.avalon.framework.parameters.Parameters par)
          Starting with JDK 1.5, accepts configuration parameters: connect-timeout used to set URLConnection.setConnectTimeout() read-timeout used to set URLConnection.setReadTimeout()
 void release(Source source)
          Release a Source object.
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parameters

org.apache.avalon.framework.parameters.Parameters parameters
Constructor Detail

URLSourceFactory

public URLSourceFactory()
Method Detail

parameterize

public void parameterize(org.apache.avalon.framework.parameters.Parameters par)
                  throws org.apache.avalon.framework.parameters.ParameterException
Starting with JDK 1.5, accepts configuration parameters:

Specified by:
parameterize in interface org.apache.avalon.framework.parameters.Parameterizable
Throws:
org.apache.avalon.framework.parameters.ParameterException

createURLSource

protected Source createURLSource(java.net.URL url,
                                 java.util.Map parameters)
                          throws java.net.MalformedURLException,
                                 java.io.IOException
Create an URL-based source. This class actually creates an URLSource, but if another implementation is needed, subclasses can override this method.

Throws:
java.net.MalformedURLException
java.io.IOException

createFileSource

protected Source createFileSource(java.lang.String uri)
                           throws java.net.MalformedURLException,
                                  java.io.IOException
Create an file-based source. This class actually creates an FileSource, but if another implementation is needed, subclasses can override this method.

Throws:
java.net.MalformedURLException
java.io.IOException

getSource

public Source getSource(java.lang.String uri,
                        java.util.Map parameters)
                 throws java.net.MalformedURLException,
                        java.io.IOException
Description copied from interface: SourceFactory
Get a Source object. The factory creates a new 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 SourceFactory.release(Source) method. This is achieved by using SourceResolver.release(Source) which finds the appropriate SourceFactory.

Specified by:
getSource in interface SourceFactory
Parameters:
uri - The URI to resolve - this URI includes the scheme.
parameters - additionnal named parameters (optionnal and can be null) that drive the creation of the Source object. Each implementation must specify what parameters it accepts.
Returns:
the created source object.
Throws:
java.io.IOException - if the source couldn't be created for some reason.
java.net.MalformedURLException
See Also:
SourceFactory.getSource(java.lang.String, java.util.Map)

release

public void release(Source source)
Description copied from interface: SourceFactory
Release a Source object.

Specified by:
release in interface SourceFactory
Parameters:
source - the source to release.
See Also:
SourceFactory.release(org.apache.excalibur.source.Source)