Author: cziegeler
Date: Mon May 2 07:21:28 2005
New Revision: 165639
URL: http://svn.apache.org/viewcvs?rev=165639&view=rev
Log:
Add missing ThreadSafe
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java
URL:
http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java?rev=165639&r1=165638&r2=165639&view=diff
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java
Mon May 2 07:21:28 2005
@@ -31,6 +31,7 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.Processor;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.internal.EnvironmentHelper;
@@ -50,7 +51,7 @@
*/
public class CocoonSourceResolver
extends AbstractLogEnabled
-implements SourceResolver, Contextualizable, Serviceable, Disposable {
+implements SourceResolver, Contextualizable, Serviceable, Disposable,
ThreadSafe {
/** A (optional) custom source resolver */
protected org.apache.excalibur.source.SourceResolver customResolver;
@@ -104,78 +105,77 @@
}
if ( this.customResolver != null ) {
return this.customResolver.resolveURI(location, baseURI,
parameters);
- } else {
- if( this.getLogger().isDebugEnabled() ) {
- this.getLogger().debug( "Resolving '" + location + "' with
base '" + baseURI + "' in context '" + this.baseURL + "'" );
- }
- if( location == null ) {
- throw new MalformedURLException( "Invalid System ID" );
- }
- if( null != baseURI &&
org.apache.excalibur.source.SourceUtil.indexOfSchemeColon(baseURI) == -1 ) {
- throw new MalformedURLException( "BaseURI is not valid, it
must contain a protocol: " + baseURI );
- }
+ }
+ if( this.getLogger().isDebugEnabled() ) {
+ this.getLogger().debug( "Resolving '" + location + "' with base '"
+ baseURI + "' in context '" + this.baseURL + "'" );
+ }
+ if( location == null ) {
+ throw new MalformedURLException( "Invalid System ID" );
+ }
+ if( null != baseURI &&
org.apache.excalibur.source.SourceUtil.indexOfSchemeColon(baseURI) == -1 ) {
+ throw new MalformedURLException( "BaseURI is not valid, it must
contain a protocol: " + baseURI );
+ }
- if( baseURI == null ) {
- baseURI = this.baseURL.toExternalForm();
- }
+ if( baseURI == null ) {
+ baseURI = this.baseURL.toExternalForm();
+ }
- String systemID = location;
- // special handling for windows file paths
- if( location.length() > 1 && location.charAt( 1 ) == ':' ) {
- systemID = "file:/" + location;
- } else if( location.length() > 2 && location.charAt(0) == '/' &&
location.charAt(2) == ':' ) {
- systemID = "file:" + location;
- }
+ String systemID = location;
+ // special handling for windows file paths
+ if( location.length() > 1 && location.charAt( 1 ) == ':' ) {
+ systemID = "file:/" + location;
+ } else if( location.length() > 2 && location.charAt(0) == '/' &&
location.charAt(2) == ':' ) {
+ systemID = "file:" + location;
+ }
- // determine protocol (scheme): first try to get the one of the
systemID, if that fails, take the one of the baseURI
- String protocol;
- int protocolPos =
org.apache.excalibur.source.SourceUtil.indexOfSchemeColon(systemID);
+ // determine protocol (scheme): first try to get the one of the
systemID, if that fails, take the one of the baseURI
+ String protocol;
+ int protocolPos =
org.apache.excalibur.source.SourceUtil.indexOfSchemeColon(systemID);
+ if( protocolPos != -1 ) {
+ protocol = systemID.substring( 0, protocolPos );
+ } else {
+ protocolPos =
org.apache.excalibur.source.SourceUtil.indexOfSchemeColon(baseURI);
if( protocolPos != -1 ) {
- protocol = systemID.substring( 0, protocolPos );
+ protocol = baseURI.substring( 0, protocolPos );
} else {
- protocolPos =
org.apache.excalibur.source.SourceUtil.indexOfSchemeColon(baseURI);
- if( protocolPos != -1 ) {
- protocol = baseURI.substring( 0, protocolPos );
- } else {
- protocol = "*";
- }
+ protocol = "*";
}
+ }
- final ServiceManager m = this.getServiceManager();
+ final ServiceManager m = this.getServiceManager();
+
+ Source source = null;
+ // search for a SourceFactory implementing the protocol
+ SourceFactory factory = null;
+ try {
+ factory = this.getSourceFactory( m, protocol );
+ systemID = this.absolutize( factory, baseURI, systemID );
+ if( getLogger().isDebugEnabled() ) {
+ getLogger().debug( "Resolved to systemID : " + systemID );
+ }
+ source = factory.getSource( systemID, parameters );
+ } catch( final ServiceException ce ) {
+ // no selector available, use fallback
+ } finally {
+ m.release( factory );
+ }
- Source source = null;
- // search for a SourceFactory implementing the protocol
- SourceFactory factory = null;
+ if( null == source ) {
try {
- factory = this.getSourceFactory( m, protocol );
+ factory = this.getSourceFactory( m, "*");
systemID = this.absolutize( factory, baseURI, systemID );
if( getLogger().isDebugEnabled() ) {
getLogger().debug( "Resolved to systemID : " + systemID );
}
source = factory.getSource( systemID, parameters );
- } catch( final ServiceException ce ) {
- // no selector available, use fallback
+ } catch (ServiceException se ) {
+ throw new SourceException( "Unable to select source factory
for " + systemID, se );
} finally {
- m.release( factory );
+ m.release(factory);
}
-
- if( null == source ) {
- try {
- factory = this.getSourceFactory( m, "*");
- systemID = this.absolutize( factory, baseURI, systemID );
- if( getLogger().isDebugEnabled() ) {
- getLogger().debug( "Resolved to systemID : " +
systemID );
- }
- source = factory.getSource( systemID, parameters );
- } catch (ServiceException se ) {
- throw new SourceException( "Unable to select source
factory for " + systemID, se );
- } finally {
- m.release(factory);
- }
- }
-
- return source;
}
+
+ return source;
}
/**