Class BCDChannel
java.lang.Object
java.util.Observable
org.jpos.iso.BaseChannel
org.jpos.iso.channel.BCDChannel
- All Implemented Interfaces:
Cloneable, Configurable, ExceptionHandlerAware, BaseChannelMBean, ClientChannel, FactoryChannel, FilteredChannel, ISOChannel, ISOSource, ServerChannel, ISOMsgMetrics.Source, LogSource
Talks with TCP based NCCs
Sends [LEN][TPDU][ISOMSG]
(len=2 bytes HEX)
- See Also:
-
Field Summary
Fields inherited from class BaseChannel
cnt, header, incomingFilters, logger, originalRealm, outgoingFilters, overrideHeader, packager, realm, serverIn, serverInLock, serverOut, serverOutLock, serverSocket, socketFactory, usableModifier and TypeFieldDescriptionprotected int[]Message counters array.protected byte[]Message header bytes.Incoming and outgoing filter chains.protected LoggerThe logger for this channel.protected StringThe original realm before any override.Incoming and outgoing filter chains.protected booleanWhen true, this channel's own header overrides the message's header.protected ISOPackagerThe packager used to pack/unpack ISO messages.protected StringThe realm string for this channel.protected DataInputStreamInput stream for reading from the connected socket.protected LockLock guardingBaseChannel.serverInand read operations.protected DataOutputStreamOutput stream for writing to the connected socket.protected LockLock guardingBaseChannel.serverOutand write operations.protected ServerSocketServer socket used when this channel acts as a server.protected ISOClientSocketFactoryOptional factory for creating client sockets.protected booleanWhether this channel is in a usable state.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
ConstructorsConstructorDescriptionPublic constructorBCDChannel(String host, int port, ISOPackager p, byte[] TPDU) Construct client ISOChannelBCDChannel(ISOPackager p, byte[] TPDU) Construct server ISOChannelBCDChannel(ISOPackager p, byte[] TPDU, ServerSocket serverSocket) constructs server ISOChannel associated with a Server Socket -
Method Summary
Modifier and TypeMethodDescriptionprotected intReads and returns the message length prefix from the stream.protected voidsendMessageHeader(ISOMsg m, int len) Sends the message header bytes.protected voidsendMessageLength(int len) Sends the message length prefix; default implementation is a no-op.voidNew QSP compatible signature (see QSP's ConfigChannel)Methods inherited from class BaseChannel
accept, addFilter, addFilter, addIncomingFilter, addOutgoingFilter, applyIncomingFilters, applyIncomingFilters, applyOutgoingFilters, applyTimeout, clone, closeSocket, connect, connect, createISOMsg, createMsg, disconnect, getBytes, getChannel, getConfiguration, getCounters, getDynamicHeader, getDynamicPackager, getDynamicPackager, getDynamicPackager, getExceptionHandlers, getHeader, getHeaderLength, getHeaderLength, getHeaderLength, getHost, getIncomingFilters, getISOMsgMetrics, getLogger, getMaxPacketLength, getMessage, getMessageTrailer, getMessageTrailler, getName, getOriginalRealm, getOutgoingFilters, getPackager, getPort, getRealm, getServerSocket, getSocket, getSocketFactory, getSoLingerSeconds, getTimeout, incrementMsgInCounter, incrementMsgOutCounter, isConnected, isExpectKeepAlive, isOverrideHeader, isRejected, isSoLingerOn, newSocket, newSocket, pack, postConnectHook, readHeader, receive, reconnect, removeFilter, removeFilter, removeIncomingFilter, removeOutgoingFilter, resetCounters, send, send, sendKeepAlive, sendMessage, sendMessageTrailer, sendMessageTrailler, sendMessageTrailler, setConfiguration, setHeader, setHost, setHost, setIncomingFilters, setISOMsgMetrics, setLocalAddress, setLogger, setMaxPacketLength, setName, setOutgoingFilters, setOverrideHeader, setPackager, setPort, setServerSocket, setSocketFactory, setSoLinger, setTimeout, setUsable, shouldIgnore, streamReceive, toEndpoint, unpackModifier and TypeMethodDescriptionvoidAccepts connectionvoidAdds a filter to this channel.voidAdds a filter to this channel.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, byte[] header, byte[] image, LogEvent evt) Applies all registered incoming filters with the raw message header and image.protected ISOMsgapplyIncomingFilters(ISOMsg m, LogEvent evt) Applies all registered incoming filters to the given message.protected ISOMsgapplyOutgoingFilters(ISOMsg m, LogEvent evt) Applies all registered outgoing filters to the given message.protected voidsets timeout, and also keep aliveclone()Returns a clone of this channel.protected voidCloses the underlying socket.voidconnect()Connects client ISOChannel to serverprotected voidsetup I/O Streams from socketprotected ISOMsgCreates a new ISOMsg instance; may be overridden to return a subclass.protected ISOMsgsupport old factory method name for backward compatibilityvoiddisconnects the TCP/IP session.intgetBytes(byte[] b) Low level receivestatic ISOChannelgetChannel(String name) Retrieves a channel instance by name from the NameRegistrar.Returns the current configuration for this channel.int[]Returns the message counters array.protected ISOHeadergetDynamicHeader(byte[] image) Allow subclasses to override the Default header on incoming messages.protected ISOPackagergetDynamicPackager(byte[] image) allow subclasses to override default packager on incoming messagesprotected ISOPackagergetDynamicPackager(byte[] header, byte[] image) allow subclasses to override default packager on incoming messagesprotected ISOPackagerallow subclasses to override default packager on outgoing messagesMap<Class<? extends Exception>, List<ExceptionHandler>> Returns the map of targeted exception handlers, keyed by exception class.byte[]Returns the message header bytes.protected intReturns the fixed header length for this channel.protected intgetHeaderLength(byte[] b) Returns the header length for the given raw message bytes.protected intReturns the header length for the given ISO message.getHost()Returns the remote host this client channel connects to.Returns all filters in the incoming filter chain.Returns the attached ISOMsgMetrics.Returns the Logger associated with this source.intReturns the maximum packet length accepted by this channel.protected voidgetMessage(byte[] b, int offset, int len) Reads raw message bytes from the stream into the given buffer.protected voidReads the message trailer from the stream and optionally stores it in the given message.protected voidDeprecated.getName()Returns this channel's registered name.Returns the original realm before any override was applied.Returns all filters in the outgoing filter chain.Returns the packager used to pack/unpack ISO messages on this channel.intgetPort()Returns the remote port this client channel connects to.getRealm()Returns the log realm associated with this source.Returns the current server socket.Returns the current connected socket.Gets the ISOClientSocketFactory (may be null)intReturns the SO_LINGER timeout in seconds.intReturns the socket read timeout in milliseconds.protected voidIncrements the incoming message counter for the given message.protected voidIncrements the outgoing message counter for the given message.booleanIndicates whether this source is currently connected and able to send messages.booleanReturns whether this channel expects keep-alive messages.booleanReturns whether the channel header overrides the message header.protected booleanisRejected(byte[] b) Returns whether the given raw message should be rejected.booleanReturns whether SO_LINGER is enabled on the socket.protected SocketCreates a new socket connected to one of the given hosts/ports.protected Socketfactory method pattern (as suggested by Vincent.Greene@amo.com)protected byte[]Packs the given ISOMsg into raw bytes using this channel's packager.protected voidHook called after a successful connection.protected byte[]readHeader(int hLen) Reads in a message header.receive()Waits and receive an ISOMsg over the TCP/IP sessionvoidIssues a disconnect followed by a connectvoidremoveFilter(ISOFilter filter) Removes a filter from this channel.voidremoveFilter(ISOFilter filter, int direction) Removes a filter from this channel.voidremoveIncomingFilter(ISOFilter filter) Removes a filter from the incoming filter chain.voidremoveOutgoingFilter(ISOFilter filter) Removes a filter from the outgoing filter chain.voidreset stat infovoidsend(byte[] b) sends a byte[] over the TCP/IP sessionvoidSends the specifiedISOMsgover this ISOChannel.voidSends a high-level keep-alive message (zero length)protected voidsendMessage(byte[] b, int offset, int len) Writes the given bytes to the output stream.protected voidsendMessageTrailer(ISOMsg m, byte[] b) Sends the message trailer bytes.protected voidsendMessageTrailler(ISOMsg m, byte[] b) Deprecated.useBaseChannel.sendMessageTrailer(ISOMsg, byte[])instead.protected voidsendMessageTrailler(ISOMsg m, int len) Deprecated.use sendMessageTrailer(ISOMsg m, byte[] b) instead.voidImplements Configurable
Properties:
host - destination host (if ClientChannel) port - port number (if ClientChannel) local-iface - local interfase to use (if ClientChannel) local-port - local port to bind (if ClientChannel) (host not present indicates a ServerChannel)voidsetHeader(byte[] header) Sets the message header bytes for this channel.voidSets the remote host name or address.voidinitialize an ISOChannelvoidsetIncomingFilters(Collection filters) Replaces the entire incoming filter chain with the given collection.voidsetISOMsgMetrics(ISOMsgMetrics metrics) Sets the ISOMsgMetrics instance.voidsetLocalAddress(String iface, int port) initialize an ISOChannelvoidAttaches aLoggerand realm to this log source.voidsetMaxPacketLength(int maxPacketLength) Sets the maximum packet length accepted by this channel.voidassociates this ISOChannel with a name using NameRegistrarvoidsetOutgoingFilters(Collection filters) Replaces the entire outgoing filter chain with the given collection.voidsetOverrideHeader(boolean overrideHeader) Controls whether this channel's own header overrides the message header.voidset Packager for channelvoidsetPort(int port) Sets the remote port number.voidsetServerSocket(ServerSocket sock) Associates this ISOChannel with a server socketvoidsetSocketFactory(ISOClientSocketFactory socketFactory) Sets the specified Socket Factory to create socketsvoidsetSoLinger(boolean on, int linger) Socket SO_LINGER option to use when closing the socket.voidsetTimeout(int timeout) sets socket timeout (as suggested by Leonard Thomas <leonard@rhinosystemsinc.com>)voidsetUsable(boolean b) Marks this channel as usable or not; a non-usable channel will not accept messages.protected booleanshouldIgnore(byte[] b) Returns whether the given raw message should be silently ignored.protected byte[]Reads raw bytes from the stream for protocols without explicit length framing.protected StringtoEndpoint(Socket socket) Returns a human-readable endpoint string for the given socket.protected voidUnpacks raw bytes into the given ISOMsg using this channel's packager.Methods inherited from class Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChangedMethods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ExceptionHandlerAware
addHandler, addHandler, handle, removeHandler, removeHandler, removeHandlersModifier and TypeMethodDescriptiondefault voidaddHandler(ExceptionHandler handler) Add a handler to the default pipeline.default voidaddHandler(ExceptionHandler handler, Class<? extends Exception> clazz) Add a handler to an exception specific pipeline.default ExceptionExecute the pipeline by starting with the specific pipeline for the exception followed by the default pipeline.default voidremoveHandler(ExceptionHandler handler) Remove a handler from the default pipeline.default voidremoveHandler(ExceptionHandler handler, Class<? extends Exception> clazz) Remove a handler from an exception specific handler pipeline.default voidremoveHandlers(Class<? extends Exception> clazz) Remove all handler for a specific exception handling pipeline.
-
Constructor Details
-
BCDChannel
public BCDChannel()Public constructor -
BCDChannel
Construct client ISOChannel- Parameters:
host- server TCP Addressport- server port numberp- an ISOPackagerTPDU- an optional raw header (i.e. TPDU)- See Also:
-
BCDChannel
Construct server ISOChannel- Parameters:
p- an ISOPackagerTPDU- an optional raw header (i.e. TPDU)- Throws:
IOException- on I/O failure- See Also:
-
BCDChannel
constructs server ISOChannel associated with a Server Socket- Parameters:
p- an ISOPackagerTPDU- an optional raw header (i.e. TPDU)serverSocket- where to accept a connection- Throws:
IOException- on I/O failure- See Also:
-
-
Method Details
-
sendMessageLength
Description copied from class:BaseChannelSends the message length prefix; default implementation is a no-op.- Overrides:
sendMessageLengthin classBaseChannel- Parameters:
len- the message length to send- Throws:
IOException- on I/O error
-
getMessageLength
Description copied from class:BaseChannelReads and returns the message length prefix from the stream.- Overrides:
getMessageLengthin classBaseChannel- Returns:
- the message length
- Throws:
IOException- on I/O errorISOException- on protocol error
-
sendMessageHeader
Description copied from class:BaseChannelSends the message header bytes.- Overrides:
sendMessageHeaderin classBaseChannel- Parameters:
m- the ISO message being sentlen- the message length- Throws:
IOException- on I/O error
-
setHeader
New QSP compatible signature (see QSP's ConfigChannel)- Overrides:
setHeaderin classBaseChannel- Parameters:
header- String as seen by QSP
-
BaseChannel.getMessageTrailer(ISOMsg)instead.