org.ops4j.net
Class ConnectionCache

java.lang.Object
  extended by org.ops4j.net.ConnectionCache
All Implemented Interfaces:
java.lang.Runnable, ExceptionSource

public final class ConnectionCache
extends java.lang.Object
implements java.lang.Runnable, ExceptionSource

This class is to be used to cache URLConnections.


Method Summary
 java.net.URLConnection get(java.lang.Object key)
          Returns the URLConnection associated with the given key.
 java.util.List<ExceptionMonitor> getExceptionMonitors()
          Returns all ExceptionMonitors that are registered.
static ConnectionCache getInstance()
          Returns the singleton instance.
 void put(java.lang.Object key, java.net.URLConnection conn)
          Stores a URLConnection in association with a key.
 void registerExceptionMonitor(ExceptionMonitor monitor)
          Register a ExceptionMonitor with the source.
 void run()
          When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.
 void unregisterExceptionMonitor(ExceptionMonitor monitor)
          Unregister a ExceptionMonitor with the source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static ConnectionCache getInstance()
Returns the singleton instance.

Returns:
the singleton instance.

get

public java.net.URLConnection get(java.lang.Object key)
Returns the URLConnection associated with the given key.

Parameters:
key - The key that is associated to the URL.
Returns:
the URLConnection associated with the given key.

put

public void put(java.lang.Object key,
                java.net.URLConnection conn)
Stores a URLConnection in association with a key.

Parameters:
key - The key that is associated to the URLConnection.
conn - The URLConnection that should be stored in association with the key.

run

public void run()
When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's run method to be called in that separately executing thread.

The general contract of the method run is that it may take any action whatsoever.

Specified by:
run in interface java.lang.Runnable
See Also:
Thread.run()

registerExceptionMonitor

public void registerExceptionMonitor(ExceptionMonitor monitor)
                              throws TooManyMonitorsException
Register a ExceptionMonitor with the source.

Specified by:
registerExceptionMonitor in interface ExceptionSource
Parameters:
monitor - The ExceptionMonitor to be notified.
Throws:
TooManyMonitorsException - If more than one monitor is registered.

unregisterExceptionMonitor

public void unregisterExceptionMonitor(ExceptionMonitor monitor)
Unregister a ExceptionMonitor with the source.

Specified by:
unregisterExceptionMonitor in interface ExceptionSource
Parameters:
monitor - The ExceptionMonitor to be unregistered.

getExceptionMonitors

public java.util.List<ExceptionMonitor> getExceptionMonitors()
Returns all ExceptionMonitors that are registered.

Specified by:
getExceptionMonitors in interface ExceptionSource
Returns:
all ExceptionMonitors that are registered.


Copyright © 2006-2008 OPS4J - Open Participation Software for Java. All Rights Reserved.