|
![]() |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public static interface HttpRequest.HttpSocketPool
This interface represents a cache of idle sockets. Once a request has
been handled, the now-idle socket can be remembered and reused later in
case another HTTP request is made to the same remote host. Currently, the
only instance of this interface is used by the HttpRequest
class.
Method Summary | |
---|---|
void |
close(HttpRequest.HttpSocket hs,
boolean reuse)
Releases an HttpSocket to this pool when it is not
in use any more. |
HttpRequest.HttpSocket |
get(String host,
int port,
boolean reuse)
Returns an HttpSocket that can be used to communicate
with the specified port on the named host. |
int |
getDefaultPort()
Return the default port (this doesn't belong here) |
boolean |
isMine(URL url)
Return true if this is one of the url's my pool can handle |
Method Detail |
---|
boolean isMine(URL url)
int getDefaultPort()
HttpRequest.HttpSocket get(String host, int port, boolean reuse) throws IOException
HttpSocket
that can be used to communicate
with the specified port on the named host.
It is this method's responsibility to to fill in all the public
member variables of the HttpSocket
before returning.
For each call to this method, there should eventually be a call to
close
when the HttpSocket
isn't needed
anymore.
host
- The host name.port
- The port number.reuse
- true
to request that this pool attempt to
find and reuse an existing idle connection,
false
to request that this pool establish a new connection to
the named host.
HttpSocket
.
IOException
- if there is a problem connecting the specified port on
the named host. The IOException
s (and
subclasses) that might be thrown depend upon how the
socket connection is established. See the socket
documentation for further details. Some subclasses that
might be thrown are as follows:
java.io.UnknownHostException
- if the host name cannot be resolved.
java.io.ConnectionException
- if the named host is not listening on "port".
InterruptedIOException
- if the connection times out or this thread is
interrupted by Thread.interrupt
.void close(HttpRequest.HttpSocket hs, boolean reuse)
HttpSocket
to this pool when it is not
in use any more.
It is this method's responsibility to release resources used
by the HttpSocket
, e.g. closing the underlying socket.
After calling this method, the user should not refer to the specified
HttpSocket
any more.
hs
- The HttpSocket
to release.reuse
- true
: the specified HttpSocket
should be put back into the idle pool,
false
if it should be released immediately.
|
Version Kenai-svn-r24, Generated 08/18/09 Copyright (c) 2001-2009, Sun Microsystems. |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |