|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectnet.sourceforge.java.feednread.backend.configuration.ConnectionManager
Manages and allocates online connections available to the application. All
components that need to establish an online connection need to request a free
connection slot from the ConnectionManager via its
getConnectionSlot(URL) method. It is mandatory to notify the
ConnectionManager as soon as the connection is freed up again
using the connectionClosed() method to get other demanding objects
the chance to allocate a free connection slot.
| Field Summary | |
private int |
allocatedConnectionSlots
The number of allocated connection slots |
private ProxyServerSettings |
proxy
The optional proxy server to use for all connections |
private static ConnectionManager |
SINGLETON_INSTANCE
The single unique ConnectionManager instance |
| Constructor Summary | |
private |
ConnectionManager()
Creates a new ConnectionManager instance.
|
| Method Summary | |
void |
connectionClosed()
Notifies this ConnectionManager that a previously
allocated connection slot has been freed up as the connection was
closed. |
int |
getAllocatedConnectionSlots()
Gets the number of currently alloocated connection slots in this ConnectionManager.
|
URLConnection |
getConnectionSlot(URL url)
Tries to allocate a free connection slot. |
int |
getFreeConnectionSlots()
Gets the number of free connection slots in this ConnectionManager at the moment.
|
static ConnectionManager |
getInstance()
Gets the single unique ConnectionManager instance
|
ProxyServerSettings |
getProxySettings()
Gets the ProxyServerSettings used for all connections
established by this ConnectionManager.
|
boolean |
isFreeConnectionSlot()
Returns true if a free connection slot is available at the
moment.
|
void |
setProxySettings(ProxyServerSettings settings)
Sets the ProxyServerSettings used for all connections
established by this ConnectionManager.
|
void |
setupConnectionSettings()
Setups the connection settings used for all HttpUrlConnection instances.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
private int allocatedConnectionSlots
The number of allocated connection slots
private ProxyServerSettings proxy
The optional proxy server to use for all connections
private static ConnectionManager SINGLETON_INSTANCE
The single unique ConnectionManager instance
| Constructor Detail |
private ConnectionManager()
Creates a new ConnectionManager instance.
| Method Detail |
public static ConnectionManager getInstance()
Gets the single unique ConnectionManager instance
ConnectionManager instancepublic boolean isFreeConnectionSlot()
Returns true if a free connection slot is available at the
moment.
true if a free connection slot is available at the
moment; false otherwise
public URLConnection getConnectionSlot(URL url)
throws IOException
Tries to allocate a free connection slot. If the allocation succeeded
this method returns an ULRConnection to the specified
url.
Note that a connection slot requested by this method has always to be
freed up correctly by calling the connectionClosed() method. For
the ConnectionManager to work properly it is therefore
mandatory to call the connectionClosed() method instantly after
a requested URLConnection returned by this method has been
closed. Otherwise an allocated connection slot never gets freed up again
and stays blocked for other requests made to this
ConnectionManager.
url - the URL to connect
ULRConnection to the specified url
IOException - if a connection to the specified url
could not be establishedpublic void connectionClosed()
Notifies this ConnectionManager that a previously
allocated connection slot has been freed up as the connection was
closed. The allocated connection slot gets available again.
Note that a connection slot requested by the
getConnectionSlot(URL) method has always to be freed up
correctly by calling this method.
For the ConnectionManager to work properly it is
therefore mandatory to call this method instantly after
a requested URLConnection has been closed.
Otherwise an allocated connection slot never gets freed up
again and stays blocked for other requests made to
this ConnectionManager.
public int getFreeConnectionSlots()
Gets the number of free connection slots in this
ConnectionManager at the moment.
ConnectionManager at the momentpublic int getAllocatedConnectionSlots()
Gets the number of currently alloocated connection slots in this
ConnectionManager.
ConnectionManagerpublic ProxyServerSettings getProxySettings()
Gets the ProxyServerSettings used for all connections
established by this ConnectionManager.
ProxyServerSettingspublic void setProxySettings(ProxyServerSettings settings)
Sets the ProxyServerSettings used for all connections
established by this ConnectionManager.
settings - the ProxyServerSettings to use
IllegalArgumentException - if a null value is
specified for the settings argument. To switch off a proxy
server use the ProxyServerSettings.setEnabled(boolean) method.public void setupConnectionSettings()
Setups the connection settings used for all
HttpUrlConnection instances.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||