Class LoopbackChannel
java.lang.Object
java.util.Observable
org.jpos.iso.FilteredBase
org.jpos.iso.channel.LoopbackChannel
- All Implemented Interfaces:
Cloneable, FilteredChannel, ISOChannel, ISOSource, LogSource
In-memory ISO channel that loops messages back through a
BlockingQueue,
useful for testing without external network resources.-
Field Summary
Fields inherited from class FilteredBase
incomingFilters, outgoingFiltersFields 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 TypeMethodDescriptionvoidconnect()Connects ISOChannelvoiddisconnects ISOChannelint[]Returns the live counter array (transmitted/received tallies).Returns the Logger associated with this source.getName()Returns this channel's registered name.Returns the packager configured 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 channelvoidResets the connect/transmit/receive counters to zero.voidsend(byte[] b) sends a byte[] over the TCP/IP sessionvoidsends an ISOMsg over the TCP/IP sessionvoidAttaches aLoggerand realm to this log source.voidassociates this ISOChannel with a name on NameRegistrarvoidsetPackager(ISOPackager packager) setPackager is optional on LoopbackChannel, it is used for debugging/formating purposes onlyvoidsetUsable(boolean usable) Marks this channel as usable or not; a non-usable channel will not accept messages.Methods inherited from class FilteredBase
addFilter, addIncomingFilter, addOutgoingFilter, applyIncomingFilters, applyOutgoingFilters, clone, getIncomingFilters, getOutgoingFilters, removeFilter, removeIncomingFilter, removeOutgoingFilter, setIncomingFilters, setOutgoingFiltersModifier and TypeMethodDescriptionvoidAdds a filter to both incoming and outgoing chains.voidaddIncomingFilter(ISOFilter filter) Adds a filter to the incoming filter chain.voidaddOutgoingFilter(ISOFilter filter) Adds a filter to the outgoing filter chain.protected ISOMsgapplyIncomingFilters(ISOMsg m, LogEvent evt) Runs every incoming filter againstmand notifies observers of the result.protected ISOMsgapplyOutgoingFilters(ISOMsg m, LogEvent evt) Runs every outgoing filter againstmand notifies observers of the result.clone()Returns a clone of this channel.Returns all filters in the incoming filter chain.Returns all filters in the outgoing filter chain.voidremoveFilter(ISOFilter filter) Removes a filter from both incoming and outgoing chains.voidremoveIncomingFilter(ISOFilter filter) Removes a filter from the incoming filter chain.voidremoveOutgoingFilter(ISOFilter filter) Removes a filter from the outgoing filter chain.voidsetIncomingFilters(Collection filters) Replaces the entire incoming filter chain with the given collection.voidsetOutgoingFilters(Collection filters) Replaces the entire outgoing filter chain with the given collection.Methods inherited from class Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
-
Constructor Details
-
LoopbackChannel
public LoopbackChannel()Default constructor.
-
-
Method Details
-
setPackager
setPackager is optional on LoopbackChannel, it is used for debugging/formating purposes only- Specified by:
setPackagerin interfaceISOChannel- Parameters:
packager- an ISOPackager
-
connect
Description copied from interface:ISOChannelConnects ISOChannel- Specified by:
connectin interfaceISOChannel
-
disconnect
-
reconnect
Description copied from interface:ISOChannelReconnect channel- Specified by:
reconnectin interfaceISOChannel
-
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
-
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
-
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
-
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:
usable- - usable state
-
getCounters
Returns the live counter array (transmitted/received tallies).- Returns:
- counter array as managed by this channel
-
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
Returns the packager configured on this channel.- Specified by:
getPackagerin interfaceISOChannel- Returns:
null; the loopback channel has no packager because messages are queued as objects
-
resetCounters
Resets the connect/transmit/receive counters to zero. -
setLogger
-
getRealm
-
getLogger
-