org.apache.excalibur.source.impl
Class SourceResolverImpl

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.excalibur.source.impl.SourceResolverImpl
All Implemented Interfaces:
org.apache.avalon.framework.component.Component, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, SourceResolver, org.apache.avalon.framework.thread.ThreadSafe

public class SourceResolverImpl
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.avalon.framework.service.Serviceable, org.apache.avalon.framework.context.Contextualizable, org.apache.avalon.framework.activity.Disposable, SourceResolver, org.apache.avalon.framework.thread.ThreadSafe

This is the default implemenation of a SourceResolver. The source resolving is done relative to a base directory/URI (if the given location is relative). This implementation looks for the base URI in the Context object of the "container" for the "context-root" information. This information can either be a File object or a URL object. If the entry does not exist, the system property "user.dir" is used as the base URI instead.

Version:
$Id: SourceResolverImpl.java,v 1.4 2004/02/28 11:47:24 cziegeler Exp $
Author:
Avalon Development Team
See Also:
SourceResolver
Implements service:
type=SourceResolver
Avalon component

Field Summary
protected  URL m_baseURL
          The base URL
protected  org.apache.avalon.framework.service.ServiceSelector m_factorySelector
          The special Source factories
protected  org.apache.avalon.framework.service.ServiceManager m_manager
          The component m_manager
 
Fields inherited from interface org.apache.excalibur.source.SourceResolver
METHOD, ROLE, URI_ENCODING, URI_PARAMETERS
 
Constructor Summary
SourceResolverImpl()
           
 
Method Summary
 void contextualize(org.apache.avalon.framework.context.Context context)
          Get the context
 void dispose()
           
 void release(Source source)
          Releases a resolved resource
 Source resolveURI(String location)
          Get a Source object.
 Source resolveURI(String location, String baseURI, Map parameters)
          Get a Source object.
 void service(org.apache.avalon.framework.service.ServiceManager manager)
          Set the current ComponentLocator instance used by this Composable.
 
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

m_manager

protected org.apache.avalon.framework.service.ServiceManager m_manager
The component m_manager


m_factorySelector

protected org.apache.avalon.framework.service.ServiceSelector m_factorySelector
The special Source factories


m_baseURL

protected URL m_baseURL
The base URL

Constructor Detail

SourceResolverImpl

public SourceResolverImpl()
Method Detail

contextualize

public void contextualize(org.apache.avalon.framework.context.Context context)
                   throws org.apache.avalon.framework.context.ContextException
Get the context

Specified by:
contextualize in interface org.apache.avalon.framework.context.Contextualizable
Throws:
org.apache.avalon.framework.context.ContextException

service

public void service(org.apache.avalon.framework.service.ServiceManager manager)
             throws org.apache.avalon.framework.service.ServiceException
Set the current ComponentLocator instance used by this Composable.

Specified by:
service in interface org.apache.avalon.framework.service.Serviceable
Throws:
org.apache.avalon.framework.service.ServiceException
Requires component:
type="org.apache.excalibur.source.SourceFactory"

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable

resolveURI

public Source resolveURI(String location)
                  throws MalformedURLException,
                         IOException,
                         SourceException
Get a Source object.

Specified by:
resolveURI in interface SourceResolver
Returns:
the resolved source object.
Throws:
SourceNotFoundException - if the source cannot be found
IOException - if the source couldn't be created for some other reason.
MalformedURLException - if location is malformed.
SourceException

resolveURI

public Source resolveURI(String location,
                         String baseURI,
                         Map parameters)
                  throws MalformedURLException,
                         IOException,
                         SourceException
Get a Source object.

Specified by:
resolveURI in interface SourceResolver
Parameters:
location - - the URI to resolve. If this is relative it is either resolved relative to the base parameter (if not null) or relative to a base setting of the source resolver itself.
baseURI - - a base URI for resolving relative locations. This is optional and can be null.
parameters - - Additional parameters for the URI. The parameters are specific to the used scheme.
Returns:
the resolved source object.
Throws:
SourceNotFoundException - if the source cannot be found
IOException - if the source couldn't be created for some other reason.
MalformedURLException - if location is malformed.
SourceException

release

public void release(Source source)
Releases a resolved resource

Specified by:
release in interface SourceResolver
Parameters:
source - the source to release


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.