org.apache.webdav.lib
Class WebdavSession

java.lang.Object
  |
  +--org.apache.webdav.lib.WebdavSession
All Implemented Interfaces:
org.apache.commons.httpclient.ConnectionInterceptor
Direct Known Subclasses:
WebdavResource

public abstract class WebdavSession
extends java.lang.Object
implements org.apache.commons.httpclient.ConnectionInterceptor

This WebdavSession class is for the session management of WebDAV clients. This class saves and restores the requested client. Although this class is thread safe, it should only be accessed by one concurrent thread, since the underlying protocol, HTTP, is not multiplexed. If simultaneous operations are needed, it is recommended to create additional threads, each having its own associated WebDAV client. Clients that use persistent connections SHOULD limit the number of simultaneous connections that they maintain to a given server. A single-user client SHOULD NOT maintain more than 2 connections with any server or proxy. A proxy SHOULD use up to 2*N connections to another server or proxy, where N is the number of simultaneously active users. These guidelines are intended to improve HTTP response times and avoid congestion.

Author:
Park, Sung-Gu

Field Summary
protected  org.apache.commons.httpclient.HttpClient client
          The Http client instance.
protected  int debug
          Debug level.
 
Constructor Summary
WebdavSession()
          Default constructor.
 
Method Summary
 void authenticate()
          Authenticate.
 void closeSession()
          Close an session and delete the connection information.
 void closeSession(org.apache.commons.httpclient.HttpClient client)
          Deprecated. Replaced by closeSession()
 void connect()
          Connect.
 void disconnect()
          Disconnect.
 boolean error(int status, java.lang.Exception e)
          Unexpected error.
 org.apache.commons.httpclient.HttpClient getSessionInstance(org.apache.util.HttpURL httpURL)
          Get a HttpClient instance.
 org.apache.commons.httpclient.HttpClient getSessionInstance(org.apache.util.HttpURL httpURL, boolean reset)
          Get a HttpClient instance.
 boolean info(int status, java.util.Hashtable headers)
          Recieved an informational status code.
 void receivedExpectation()
          Received expectation.
 void receivedResponse()
          Received response.
 void requiredAuthentication()
          Authenticate.
 boolean retry(int status)
          Retry.
 void sentRequest()
          Sent request.
 void setDebug(int debug)
          Set debug level.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

client

protected org.apache.commons.httpclient.HttpClient client
The Http client instance.

debug

protected int debug
Debug level.
Constructor Detail

WebdavSession

public WebdavSession()
Default constructor.
Method Detail

setDebug

public void setDebug(int debug)
Set debug level.

getSessionInstance

public org.apache.commons.httpclient.HttpClient getSessionInstance(org.apache.util.HttpURL httpURL)
                                                            throws java.io.IOException
Get a HttpClient instance. This method returns a new client instance for the first time. And it is saved util it's closed or reset.
Parameters:
httpURL - The http URL to connect. only used the authority part.
Returns:
An instance of HttpClient.
Throws:
java.io.IOException -  

getSessionInstance

public org.apache.commons.httpclient.HttpClient getSessionInstance(org.apache.util.HttpURL httpURL,
                                                                   boolean reset)
                                                            throws java.io.IOException
Get a HttpClient instance. This method returns a new client instance, when reset is true.
Parameters:
httpURL - The http URL to connect. only used the authority part.
reset - The reset flag to represent whether the saved information is used or not.
Returns:
An instance of HttpClient.
Throws:
java.io.IOException -  

closeSession

public void closeSession()
                  throws java.io.IOException
Close an session and delete the connection information.
Parameters:
client - The HttpClient instance.
Throws:
java.io.IOException - Error in closing socket.

closeSession

public void closeSession(org.apache.commons.httpclient.HttpClient client)
                  throws java.io.IOException
Deprecated. Replaced by closeSession()

Close an session and delete the connection information.
Parameters:
client - The HttpClient instance.
Throws:
java.io.IOException - Error in closing socket.

connect

public void connect()
Connect.
Specified by:
connect in interface org.apache.commons.httpclient.ConnectionInterceptor

disconnect

public void disconnect()
Disconnect.
Specified by:
disconnect in interface org.apache.commons.httpclient.ConnectionInterceptor

retry

public boolean retry(int status)
Retry.
Specified by:
retry in interface org.apache.commons.httpclient.ConnectionInterceptor
Returns:
boolean true if a retry should be attempted

info

public boolean info(int status,
                    java.util.Hashtable headers)
Recieved an informational status code.
Specified by:
info in interface org.apache.commons.httpclient.ConnectionInterceptor
Returns:
boolean true if a retry should be attempted

error

public boolean error(int status,
                     java.lang.Exception e)
Unexpected error.
Specified by:
error in interface org.apache.commons.httpclient.ConnectionInterceptor
Parameters:
status - Status code; can be equal to -1 if status code is not known
e - Underlying exception; can be null
Returns:
boolean true if processing of the request should be stopped

sentRequest

public void sentRequest()
Sent request.
Specified by:
sentRequest in interface org.apache.commons.httpclient.ConnectionInterceptor
Following copied from interface: org.apache.commons.httpclient.ConnectionInterceptor
Parameters:
requestLine - Request line sent
headers - Headers sent

receivedResponse

public void receivedResponse()
Received response.
Specified by:
receivedResponse in interface org.apache.commons.httpclient.ConnectionInterceptor
Following copied from interface: org.apache.commons.httpclient.ConnectionInterceptor
Parameters:
responseLine - Response line recieved
headers - Headers recieved

receivedExpectation

public void receivedExpectation()
Received expectation.
Specified by:
receivedExpectation in interface org.apache.commons.httpclient.ConnectionInterceptor

requiredAuthentication

public void requiredAuthentication()
Authenticate.
Specified by:
requiredAuthentication in interface org.apache.commons.httpclient.ConnectionInterceptor

authenticate

public void authenticate()
Authenticate.
Specified by:
authenticate in interface org.apache.commons.httpclient.ConnectionInterceptor