Class ChannelPool
java.lang.Object
org.jpos.iso.channel.ChannelPool
- All Implemented Interfaces:
Cloneable, Configurable, ISOChannel, ISOSource, LogSource
A pool of
ISOChannel instances; tries each in order until one connects.-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LoggerLogger for this pool.protected StringLog realm for this pool.Fields inherited from interface ISOChannel
CONNECT, RX, SIZEOF_CNT, TXModifier and TypeFieldDescriptionstatic final intCounter index for connection events.static final intCounter index for received messages.static final intNumber of counters maintained by this channel.static final intCounter index for transmitted messages. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChannel(String name) Adds a channel to the pool by its registered name.voidaddChannel(ISOChannel channel) Adds a channel to the pool.clone()Returns a clone of this channel.voidconnect()Connects ISOChannelvoiddisconnects ISOChannelReturns the currently active channel, trying to connect if necessary.Returns the Logger associated with this source.getName()Returns this channel's registered name.Returns the packager used to pack/unpack ISO messages on this channel.getRealm()Returns the log realm associated with this source.booleanIndicates whether this source is currently connected and able to send messages.receive()Receives an ISOMsgvoidReconnect channelvoidremoveChannel(String name) Removes a channel from the pool by its registered name.voidremoveChannel(ISOChannel channel) Removes a channel from the pool.voidsend(byte[] b) sends a byte[] over the TCP/IP sessionvoidsends an ISOMsg over the TCP/IP sessionvoidConfigures this object with the suppliedConfiguration.voidAttaches aLoggerand realm to this log source.voidassociates this ISOChannel with a name on NameRegistrarvoidAssociate a packager with this channelvoidsetUsable(boolean b) Marks this channel as usable or not; a non-usable channel will not accept messages.intsize()Returns the number of channels in the pool.
-
Field Details
-
logger
-
realm
-
-
Constructor Details
-
ChannelPool
public ChannelPool()Default constructor.
-
-
Method Details
-
setPackager
Description copied from interface:ISOChannelAssociate a packager with this channel- Specified by:
setPackagerin interfaceISOChannel- Parameters:
p- an ISOPackager
-
connect
Description copied from interface:ISOChannelConnects ISOChannel- Specified by:
connectin interfaceISOChannel- Throws:
IOException- on I/O failure
-
disconnect
Description copied from interface:ISOChanneldisconnects ISOChannel- Specified by:
disconnectin interfaceISOChannel- Throws:
IOException- on I/O failure
-
reconnect
Description copied from interface:ISOChannelReconnect channel- Specified by:
reconnectin interfaceISOChannel- Throws:
IOException- on I/O failure
-
isConnected
Description copied from interface:ISOSourceIndicates whether this source is currently connected and able to send messages.- Specified by:
isConnectedin interfaceISOChannel- Specified by:
isConnectedin interfaceISOSource- Returns:
- true if Channel is connected and usable
-
receive
Description copied from interface:ISOChannelReceives an ISOMsg- Specified by:
receivein interfaceISOChannel- Returns:
- the Message received
- Throws:
IOException- on I/O failureISOException- on ISO packing/unpacking failure
-
send
Description copied from interface:ISOChannelsends an ISOMsg over the TCP/IP session- Specified by:
sendin interfaceISOChannel- Specified by:
sendin interfaceISOSource- Parameters:
m- the Message to be sent- Throws:
IOException- on I/O failureISOException- on ISO packing/unpacking failure
-
send
Description copied from interface:ISOChannelsends a byte[] over the TCP/IP session- Specified by:
sendin interfaceISOChannel- Parameters:
b- the byte array to be sent- Throws:
IOException- on I/O failureISOException- on ISO packing/unpacking failure
-
setUsable
Description copied from interface:ISOChannelMarks this channel as usable or not; a non-usable channel will not accept messages.- Specified by:
setUsablein interfaceISOChannel- Parameters:
b- - usable state
-
setName
Description copied from interface:ISOChannelassociates this ISOChannel with a name on NameRegistrar- Specified by:
setNamein interfaceISOChannel- Parameters:
name- name to register- See Also:
-
getName
Description copied from interface:ISOChannelReturns this channel's registered name.- Specified by:
getNamein interfaceISOChannel- Returns:
- this ISOChannel's name ("" if no name was set)
-
getPackager
Description copied from interface:ISOChannelReturns the packager used to pack/unpack ISO messages on this channel.- Specified by:
getPackagerin interfaceISOChannel- Returns:
- current packager
-
setLogger
-
getRealm
-
getLogger
-
setConfiguration
Description copied from interface:ConfigurableConfigures this object with the suppliedConfiguration.- Specified by:
setConfigurationin interfaceConfigurable- Parameters:
cfg- Configuration object- Throws:
ConfigurationException- if the configuration is invalid
-
addChannel
Adds a channel to the pool.- Parameters:
channel- the channel to add
-
addChannel
Adds a channel to the pool by its registered name.- Parameters:
name- the NameRegistrar name of the channel to add- Throws:
NameRegistrar.NotFoundException- if name not found
-
removeChannel
Removes a channel from the pool.- Parameters:
channel- the channel to remove
-
removeChannel
Removes a channel from the pool by its registered name.- Parameters:
name- the channel name to remove- Throws:
NameRegistrar.NotFoundException- if name not found
-
size
-
getCurrent
Returns the currently active channel, trying to connect if necessary.- Returns:
- the active ISOChannel
- Throws:
IOException- if no channel can be connected
-
clone
Description copied from interface:ISOChannelReturns a clone of this channel.- Specified by:
clonein interfaceISOChannel- Overrides:
clonein classObject- Returns:
- a deep copy of this ISOChannel
-