Modifier and Type | Class and Description |
---|---|
private class |
PooledPort.PoolManager
thread that coordinates the pool, i.e. allocates and deallocates
channels depending on the needs
|
private static class |
PooledPort.WaitEntry
class that describes a waiting thread
|
private static class |
PooledPort.WriteException
exception that specifically marks I/O exceptions that happen during
the sending of the EPP command
|
Modifier and Type | Field and Description |
---|---|
private int |
allocateChannels
the number of channels to allocate
|
private java.util.Queue<RegistryChannel> |
available
the pool of available channels
|
private int |
channelCount
the number of currently allocated channels
|
private Codec |
codec
the codec we are using
|
private ChannelFactory |
factory
the channel factory
|
private PooledPort.PoolManager |
manager
the pool manager
|
private java.lang.Thread |
managerThread
the thread the manager is running on
|
private int |
maxChannels
the maximum number of channels to allocate
|
private int |
minChannels
minimum number of channels to leave in the pool
|
private java.lang.String |
password
the password for the login
|
private boolean |
shutdown
the shutdown flag
|
private java.lang.Object |
syncObject
the object on which internal synchronisation is coordinated
|
private java.lang.String |
userName
user name for the login
|
private java.util.Queue<PooledPort.WaitEntry> |
waiting
the queue of waiting threads
|
Constructor and Description |
---|
PooledPort(ChannelFactory theFactory,
Codec theCodec,
java.lang.String theUserName,
java.lang.String thePassword,
int allocate,
int min,
int max)
constructor
|
Modifier and Type | Method and Description |
---|---|
private RegistryChannel |
acquireChannel()
acquire a channel.
|
private void |
closeChannel(RegistryChannel channel)
close and discard channel
|
private void |
discardChannel(RegistryChannel channel)
discard a channel
|
private Response |
execute(RegistryChannel channel,
Request request)
execute a request on the given channel
|
Response |
execute(Request request)
"execute" a request, i.e. send it to the registry and wait for the
response
|
private void |
returnChannel(RegistryChannel channel)
return a channel to the pool or to a waiting thread
|
void |
shutdown()
terminate the port and close all open channels.
|
private Codec codec
private ChannelFactory factory
private int allocateChannels
private int minChannels
private int maxChannels
private java.lang.String userName
private java.lang.String password
private final java.lang.Object syncObject
private int channelCount
private java.util.Queue<RegistryChannel> available
private java.util.Queue<PooledPort.WaitEntry> waiting
private PooledPort.PoolManager manager
private java.lang.Thread managerThread
private boolean shutdown
public PooledPort(ChannelFactory theFactory, Codec theCodec, java.lang.String theUserName, java.lang.String thePassword, int allocate, int min, int max)
theFactory
- the channel factorytheCodec
- the codec to use; if null
a default codec is used.theUserName
- the user namethePassword
- the passwordallocate
- the number of connections that shall
be allocated without request (should be
less or equal to min)min
- the minium number of channels to keep in
the poolmax
- the maximum number of channels that
shall be allocatedprivate void discardChannel(RegistryChannel channel)
channel
- the channel to discardprivate void closeChannel(RegistryChannel channel)
channel
- the channel to closeprivate void returnChannel(RegistryChannel channel)
channel
- the channel to returnprivate RegistryChannel acquireChannel() throws java.io.IOException
java.io.IOException
- if the channel could not be allocatedprivate Response execute(RegistryChannel channel, Request request) throws java.io.IOException
channel
- the channelrequest
- the requestjava.io.IOException
- if either the transmission or the reception failedpublic void shutdown()
Copyright © 2005-2013 Knipp Medien und Kommunikation GmbH