Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 20360 invoked from network); 2 May 2005 14:21:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 May 2005 14:21:31 -0000 Received: (qmail 69944 invoked by uid 500); 2 May 2005 14:22:56 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 69809 invoked by uid 500); 2 May 2005 14:22:55 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: List-Post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 69790 invoked by uid 99); 2 May 2005 14:22:55 -0000 X-ASF-Spam-Status: No, hits=0.2 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 02 May 2005 07:22:55 -0700 Received: (qmail 20291 invoked by uid 65534); 2 May 2005 14:21:28 -0000 Message-ID: <20050502142128.20290.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: svn commit: r165639 - /cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceResolver.java Date: Mon, 02 May 2005 14:21:28 -0000 To: cvs@cocoon.apache.org From: cziegeler@apache.org X-Mailer: svnmailer-1.0.0-dev X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: cziegeler Date: Mon May 2 07:21:28 2005 New Revision: 165639 URL: http://svn.apache.org/viewcvs?rev=3D165639&view=3Drev Log: Add missing ThreadSafe Modified: cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceR= esolver.java Modified: cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonS= ourceResolver.java URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/= components/source/CocoonSourceResolver.java?rev=3D165639&r1=3D165638&r2=3D1= 65639&view=3Ddiff =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D --- cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceR= esolver.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/components/source/CocoonSourceR= esolver.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=20 extends AbstractLogEnabled -implements SourceResolver, Contextualizable, Serviceable, Disposable { +implements SourceResolver, Contextualizable, Serviceable, Disposable, Thre= adSafe { =20 /** A (optional) custom source resolver */ protected org.apache.excalibur.source.SourceResolver customResolver; @@ -104,78 +105,77 @@ } if ( this.customResolver !=3D null ) { return this.customResolver.resolveURI(location, baseURI, param= eters); - } else { - if( this.getLogger().isDebugEnabled() ) { - this.getLogger().debug( "Resolving '" + location + "' with= base '" + baseURI + "' in context '" + this.baseURL + "'" ); - } - if( location =3D=3D null ) { - throw new MalformedURLException( "Invalid System ID" ); - } - if( null !=3D baseURI && org.apache.excalibur.source.SourceUti= l=2EindexOfSchemeColon(baseURI) =3D=3D -1 ) { - throw new MalformedURLException( "BaseURI is not valid, it= must contain a protocol: " + baseURI ); - } + } + if( this.getLogger().isDebugEnabled() ) { + this.getLogger().debug( "Resolving '" + location + "' with bas= e '" + baseURI + "' in context '" + this.baseURL + "'" ); + } + if( location =3D=3D null ) { + throw new MalformedURLException( "Invalid System ID" ); + } + if( null !=3D baseURI && org.apache.excalibur.source.SourceUtil.in= dexOfSchemeColon(baseURI) =3D=3D -1 ) { + throw new MalformedURLException( "BaseURI is not valid, it mus= t contain a protocol: " + baseURI ); + } =20 - if( baseURI =3D=3D null ) { - baseURI =3D this.baseURL.toExternalForm(); - } + if( baseURI =3D=3D null ) { + baseURI =3D this.baseURL.toExternalForm(); + } =20 - String systemID =3D location; - // special handling for windows file paths - if( location.length() > 1 && location.charAt( 1 ) =3D=3D ':' )= { - systemID =3D "file:/" + location; - } else if( location.length() > 2 && location.charAt(0) =3D=3D = '/' && location.charAt(2) =3D=3D ':' ) { - systemID =3D "file:" + location; - } + String systemID =3D location; + // special handling for windows file paths + if( location.length() > 1 && location.charAt( 1 ) =3D=3D ':' ) { + systemID =3D "file:/" + location; + } else if( location.length() > 2 && location.charAt(0) =3D=3D '/' = && location.charAt(2) =3D=3D ':' ) { + systemID =3D "file:" + location; + } =20 - // determine protocol (scheme): first try to get the one of th= e systemID, if that fails, take the one of the baseURI - String protocol; - int protocolPos =3D org.apache.excalibur.source.SourceUtil.ind= exOfSchemeColon(systemID); + // determine protocol (scheme): first try to get the one of the sy= stemID, if that fails, take the one of the baseURI + String protocol; + int protocolPos =3D org.apache.excalibur.source.SourceUtil.indexOf= SchemeColon(systemID); + if( protocolPos !=3D -1 ) { + protocol =3D systemID.substring( 0, protocolPos ); + } else { + protocolPos =3D org.apache.excalibur.source.SourceUtil.indexOf= SchemeColon(baseURI); if( protocolPos !=3D -1 ) { - protocol =3D systemID.substring( 0, protocolPos ); + protocol =3D baseURI.substring( 0, protocolPos ); } else { - protocolPos =3D org.apache.excalibur.source.SourceUtil.ind= exOfSchemeColon(baseURI); - if( protocolPos !=3D -1 ) { - protocol =3D baseURI.substring( 0, protocolPos ); - } else { - protocol =3D "*"; - } + protocol =3D "*"; } + } =20 - final ServiceManager m =3D this.getServiceManager(); + final ServiceManager m =3D this.getServiceManager(); + + Source source =3D null; + // search for a SourceFactory implementing the protocol + SourceFactory factory =3D null; + try { + factory =3D this.getSourceFactory( m, protocol ); + systemID =3D this.absolutize( factory, baseURI, systemID ); + if( getLogger().isDebugEnabled() ) { + getLogger().debug( "Resolved to systemID : " + systemID ); + } + source =3D factory.getSource( systemID, parameters ); + } catch( final ServiceException ce ) { + // no selector available, use fallback + } finally { + m.release( factory ); + } =20 - Source source =3D null; - // search for a SourceFactory implementing the protocol - SourceFactory factory =3D null; + if( null =3D=3D source ) { try { - factory =3D this.getSourceFactory( m, protocol ); + factory =3D this.getSourceFactory( m, "*"); systemID =3D this.absolutize( factory, baseURI, systemID ); if( getLogger().isDebugEnabled() ) { getLogger().debug( "Resolved to systemID : " + systemI= D ); } source =3D factory.getSource( systemID, parameters ); - } catch( final ServiceException ce ) { - // no selector available, use fallback + } catch (ServiceException se ) { + throw new SourceException( "Unable to select source factor= y for " + systemID, se ); } finally { - m.release( factory ); + m.release(factory); } - - if( null =3D=3D source ) { - try { - factory =3D this.getSourceFactory( m, "*"); - systemID =3D this.absolutize( factory, baseURI, system= ID ); - if( getLogger().isDebugEnabled() ) { - getLogger().debug( "Resolved to systemID : " + sys= temID ); - } - source =3D factory.getSource( systemID, parameters ); - } catch (ServiceException se ) { - throw new SourceException( "Unable to select source fa= ctory for " + systemID, se ); - } finally { - m.release(factory); - } - } - - return source; } + + return source; } =20 /**