|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.jpeterson.pool.ObjectPool | +--com.jpeterson.pool.SocketObjectPool
A pool of Socket
's.
Field Summary | |
protected java.net.InetAddress |
address
Address of sockets in the pool. |
protected int |
port
Port of sockets in the pool. |
Fields inherited from class com.jpeterson.pool.ObjectPool |
DEFAULT_EXPIRATION,
locked,
unlocked |
Constructor Summary | |
SocketObjectPool(java.net.InetAddress address,
int port)
Create an object pool of Socket 's for the specified
address and port. |
|
SocketObjectPool(java.net.InetAddress address,
int port,
long expiration)
Create an object pool of Socket 's for the specified
address and port with the specified expiration. |
|
SocketObjectPool(java.lang.String hostname,
int port)
Create an object pool of Socket 's for the specified
hostname and port. |
|
SocketObjectPool(java.lang.String hostname,
int port,
long expiration)
Create an object pool of Socket 's for the specified
hostname and port with the specified expiration. |
Method Summary | |
java.lang.Object |
borrowObject()
Borrow an object from the pool. |
protected java.lang.Object |
create()
Create a new instance of a Socket . |
protected void |
expire(java.lang.Object o)
Clean up resources on this expired object. |
void |
returnBrokenObject(java.lang.Object o)
Return a broken borrowed object borrowed from a call to borrowObject . |
void |
returnObject(java.lang.Object o)
Return a borrowed object borrowed from a call to borrowObject . |
protected boolean |
validate(java.lang.Object o)
Always returns true . |
Methods inherited from class com.jpeterson.pool.ObjectPool |
broken,
checkIn,
checkOut,
getExpiration,
setExpiration |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
protected java.net.InetAddress address
protected int port
Constructor Detail |
public SocketObjectPool(java.lang.String hostname, int port) throws java.net.UnknownHostException
Socket
's for the specified
hostname and port. Expiration is set to the default value.hostname
- Host name or IP address for sockets in the pool.port
- Port for sockets in the pool.public SocketObjectPool(java.lang.String hostname, int port, long expiration) throws java.net.UnknownHostException
Socket
's for the specified
hostname and port with the specified expiration.hostname
- Host name or IP address for sockets in the pool.port
- Port for sockets in the pool.expiration
- Expiration in milliseconds for sockets in the
pool.public SocketObjectPool(java.net.InetAddress address, int port)
Socket
's for the specified
address and port. Expiration is set to the default value.address
- Address for sockets in the pool.port
- Port for sockets in the pool.public SocketObjectPool(java.net.InetAddress address, int port, long expiration)
Socket
's for the specified
address and port with the specified expiration.address
- Address for sockets in the pool.port
- Port for sockets in the pool.expiration
- Expiration in milliseconds for sockets in the
pool.Method Detail |
protected java.lang.Object create()
Socket
.Socket
or null
if unable to create one.protected boolean validate(java.lang.Object o)
true
.true
.protected void expire(java.lang.Object o)
o
- Object that has expired.public java.lang.Object borrowObject()
returnObject
or returnBrokenObject
.null
if no objects are
available.returnObject
,
returnBrokenObject
public void returnObject(java.lang.Object o)
borrowObject
.o
- Borrowed object being returned.borrowObject
,
returnBrokenObject
public void returnBrokenObject(java.lang.Object o)
borrowObject
.o
- Broken borrowed object being returned.borrowObject
,
returnObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |