You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ad...@apache.org on 2003/02/20 08:32:56 UTC

cvs commit: jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/webdav WebDavFileSystem.java

adammurdoch    2003/02/19 23:32:56

  Modified:    vfs/src/java/org/apache/commons/vfs/provider/webdav
                        WebDavFileSystem.java
  Log:
  Lazy creation of the HttpClient.
  
  Revision  Changes    Path
  1.3       +23 -20    jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/webdav/WebDavFileSystem.java
  
  Index: WebDavFileSystem.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/webdav/WebDavFileSystem.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebDavFileSystem.java	15 Feb 2003 02:35:35 -0000	1.2
  +++ WebDavFileSystem.java	20 Feb 2003 07:32:55 -0000	1.3
  @@ -78,27 +78,11 @@
       extends AbstractFileSystem
       implements FileSystem
   {
  -    private final HttpClient client;
  +    private HttpClient client;
   
  -    public WebDavFileSystem( final GenericFileName rootName ) throws FileSystemException
  +    public WebDavFileSystem( final GenericFileName rootName )
       {
           super( rootName, null );
  -
  -        // Create an Http client
  -        try
  -        {
  -            final HttpURL url = new HttpURL( rootName.getUserName(),
  -                                             rootName.getPassword(),
  -                                             rootName.getHostName(),
  -                                             rootName.getPort(),
  -                                             "/" );
  -            final WebdavResource resource = new WebdavResource( url, WebdavResource.NOACTION, 1 );
  -            client = resource.retrieveSessionInstance();
  -        }
  -        catch ( final IOException e )
  -        {
  -            throw new FileSystemException( "vfs.provider.webdav/create-client.error", rootName, e );
  -        }
       }
   
       /**
  @@ -118,8 +102,27 @@
       /**
        * Returns the client for this file system.
        */
  -    protected HttpClient getClient()
  +    protected HttpClient getClient() throws FileSystemException
       {
  +        if ( client == null )
  +        {
  +            // Create an Http client
  +            try
  +            {
  +                final GenericFileName rootName = (GenericFileName)getRootName();
  +                final HttpURL url = new HttpURL( rootName.getUserName(),
  +                                                 rootName.getPassword(),
  +                                                 rootName.getHostName(),
  +                                                 rootName.getPort(),
  +                                                 "/" );
  +                final WebdavResource resource = new WebdavResource( url, WebdavResource.NOACTION, 1 );
  +                client = resource.retrieveSessionInstance();
  +            }
  +            catch ( final IOException e )
  +            {
  +                throw new FileSystemException( "vfs.provider.webdav/create-client.error", getRootName(), e );
  +            }
  +        }
           return client;
       }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org