com.funambol.util
Class ConnectionManager

java.lang.Object
  extended by com.funambol.util.ConnectionManager

public class ConnectionManager
extends java.lang.Object

Controls all of the connections requested by the API implementations. It is strongly recommended to use this class instead of the direct call to the Connector.open(String url) method. This class is based on the singleton pattern: it has private constructor and just one instance to be referenced calling the method ConnectionManager.getInstance() by other classes.


Constructor Summary
protected ConnectionManager()
          Private constructor - Use getInstance() method
 
Method Summary
 ConnectionListener getConnectionListener()
          Accessor method to get the current connection listener
static ConnectionManager getInstance()
          Singleton implementation:
 Connection open(java.lang.String url)
          Open up a connection to the give url
 Connection open(java.lang.String url, int mode, boolean b)
          Open up a connection to the given url with the given access mode and
 HttpConnectionAdapter openHttpConnection(java.lang.String url, java.lang.Object extra)
          Open an http connection to the given URL
 SocketAdapter openSocketConnection(java.lang.String addr, int port, int mode, boolean timeout)
          Open a socket connection to the given URL
 void setConnectionListener(ConnectionListener cl)
          Accessor method to set the connection listener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionManager

protected ConnectionManager()
Private constructor - Use getInstance() method

Method Detail

getInstance

public static ConnectionManager getInstance()
Singleton implementation:

Returns:
the current instance of this class or a new instance if it the current instance is null

open

public Connection open(java.lang.String url)
                throws java.io.IOException
Open up a connection to the give url

Parameters:
url - The URL for the connection
Returns:
the connection url with the given parameters
Throws:
java.io.IOException

open

public Connection open(java.lang.String url,
                       int mode,
                       boolean b)
                throws java.io.IOException
Open up a connection to the given url with the given access mode and

Parameters:
url - The URL for the connection
mode - the access mode that can be READ, WRITE, READ_WRITE
b - A flag to indicate that the called wants timeout exceptions
Returns:
Connection related to the given parameters
Throws:
java.io.IOException

setConnectionListener

public void setConnectionListener(ConnectionListener cl)
Accessor method to set the connection listener

Parameters:
cl - the connection listener to be set

getConnectionListener

public ConnectionListener getConnectionListener()
Accessor method to get the current connection listener

Returns:
ConnectionListener related to this ConnectionManager instance

openHttpConnection

public HttpConnectionAdapter openHttpConnection(java.lang.String url,
                                                java.lang.Object extra)
                                         throws java.io.IOException
Open an http connection to the given URL

Parameters:
url - is the url (in the form of "http://..." or "https://...")
extra - is some extra information that can be specified to specific implementations. In this implementation the supported values are: * "wrapper" which indicates an HttpConnectionAdapterWrapper shall be used
Throws:
java.io.IOException - if the connection cannot be established

openSocketConnection

public SocketAdapter openSocketConnection(java.lang.String addr,
                                          int port,
                                          int mode,
                                          boolean timeout)
                                   throws java.io.IOException
Open a socket connection to the given URL

Parameters:
addr - is the server address
port - the port
mode - can be READ_WRITE
timeout - enable timeout on IO operations
Throws:
java.io.IOException


Copyright © 2001-2009 Funambol.