Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.knipp.rritoolkit
Class PooledPort

    java.lang.Object
      de.knipp.rritoolkit.PooledPort

All Implemented Interfaces:
  Port

    public class PooledPort

extends java.lang.Object
implements Port

class that manages a pool of channels to the registry

Version:
  $Revision: 14936 $
Author:
  Klaus Malorny

Nested Class Summary
`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

Field Summary
`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 mananger
`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 Summary
`PooledPort(ChannelFactory theFactory, Codec theCodec, java.lang.String theUserName, java.lang.String thePassword, int allocate, int min, int max)` constructor

Method Summary
`private RegistryChannel` | `acquireChannel()` acquire a 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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### codec

    private Codec codec

  the codec we are using

### factory

    private ChannelFactory factory

  the channel factory

### allocateChannels

    private int allocateChannels

  the number of channels to allocate

### minChannels

    private int minChannels

  minimum number of channels to leave in the pool

### maxChannels

    private int maxChannels

  the maximum number of channels to allocate

### userName

    private java.lang.String userName

  user name for the login

### password

    private java.lang.String password

  the password for the login

### syncObject

    private final java.lang.Object syncObject

  the object on which internal synchronisation is coordinated

### channelCount

    private int channelCount

  the number of currently allocated channels

### available

    private java.util.Queue<RegistryChannel> available

  the pool of available channels

### waiting

    private java.util.Queue<PooledPort.WaitEntry> waiting

  the queue of waiting threads

### manager

    private PooledPort.PoolManager manager

  the pool mananger

### managerThread

    private java.lang.Thread managerThread

  the thread the manager is running on

### shutdown

    private boolean shutdown

  the shutdown flag

Constructor Detail

### PooledPort

    public PooledPort(ChannelFactory theFactory,
                      Codec theCodec,
                      java.lang.String theUserName,
                      java.lang.String thePassword,
                      int allocate,
                      int min,
                      int max)

  constructor

  Parameters:
    `theFactory` - the channel factory
    `theCodec` - the codec to use; if `null` a default codec is used.
    `theUserName` - the user name
    `thePassword` - the password
    `allocate` - 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 pool
    `max` - the maximum number of channels that shall be allocated

Method Detail

### discardChannel

    private void discardChannel(RegistryChannel channel)

  discard a channel

  Parameters:
    `channel` - the channel to discard

### returnChannel

    private void returnChannel(RegistryChannel channel)

  return a channel to the pool or to a waiting thread

  Parameters:
    `channel` - the channel to return

### acquireChannel

    private RegistryChannel acquireChannel()
                                    throws java.io.IOException

  acquire a channel. If no channel is available, the thread enters a wait until a channel is returned or a new channel is allocated

  Returns:
    the channel
  Throws:
    `java.io.IOException` - if the channel could not be allocated

### execute

    private Response execute(RegistryChannel channel,
                             Request request)
                      throws java.io.IOException

  execute a request on the given channel

  Parameters:
    `channel` - the channel
    `request` - the request
  Returns:
    the response received
  Throws:
    `java.io.IOException` - if either the transmission or the reception failed

### shutdown

    public void shutdown()

  terminate the port and close all open channels. It is the duty of the caller to make sure that no other thread is currently a channels at the point of the call.

### execute

    public Response execute(Request request)
                     throws java.io.IOException

  "execute" a request, i.e. send it to the registry and wait for the response

  Specified by:
    `execute` in interface `Port`
  Parameters:
    `request` - the request
  Returns:
    the response received
  Throws:
    `java.io.IOException` - if either the transmission or the reception failed

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2005-2011 Knipp Medien und Kommunikation GmbH