jPOS 1.6.1 API Documentation

org.jpos.iso
Class BaseChannel

java.lang.Object
  extended by java.util.Observable
      extended by org.jpos.iso.BaseChannel
All Implemented Interfaces:
java.lang.Cloneable, Configurable, ReConfigurable, BaseChannelMBean, ClientChannel, FactoryChannel, FilteredChannel, ISOChannel, ISOSource, ServerChannel, LogSource
Direct Known Subclasses:
AmexChannel, ASCIIChannel, BASE24Channel, BASE24TCPChannel, CSChannel, GZIPChannel, HEXChannel, LogChannel, NACChannel, NCCChannel, PADChannel, PostChannel, RawChannel, VAPChannel, X25Channel, XMLChannel

public abstract class BaseChannel
extends java.util.Observable
implements FilteredChannel, ClientChannel, ServerChannel, FactoryChannel, LogSource, ReConfigurable, BaseChannelMBean, java.lang.Cloneable

ISOChannel is an abstract class that provides functionality that allows the transmision and reception of ISO 8583 Messages over a TCP/IP session.

It is not thread-safe, ISOMUX takes care of the synchronization details

ISOChannel is Observable in order to suport GUI components such as ISOChannelPanel.
It now support the new Logger architecture so we will probably setup ISOChannelPanel to be a LogListener insteado of being an Observer in future releases.

Version:
$Revision: 2609 $ $Date: 2008-03-01 15:41:39 -0800 (Sat, 01 Mar 2008) $
Author:
Alejandro P. Revilla, Bharavi Gade
See Also:
ISOMsg, ISOMUX, ISOException, CSChannel, Logger

Field Summary
 
Fields inherited from interface org.jpos.iso.ISOChannel
CONNECT, RX, SIZEOF_CNT, TX
 
Constructor Summary
BaseChannel()
          constructor shared by server and client ISOChannels (which have different signatures)
BaseChannel(ISOPackager p)
          constructs a server ISOChannel
BaseChannel(ISOPackager p, java.net.ServerSocket serverSocket)
          constructs a server ISOChannel associated with a Server Socket
BaseChannel(java.lang.String host, int port, ISOPackager p)
          constructs a client ISOChannel
 
Method Summary
 void accept(java.net.ServerSocket s)
          Accepts connection
 void addFilter(ISOFilter filter)
           
 void addFilter(ISOFilter filter, int direction)
           
 void addIncomingFilter(ISOFilter filter)
           
 void addOutgoingFilter(ISOFilter filter)
           
 java.lang.Object clone()
          Expose channel clonning interface
 void connect()
          Connects client ISOChannel to server
 void disconnect()
          disconnects the TCP/IP session.
 int getBytes(byte[] b)
          Low level receive
static ISOChannel getChannel(java.lang.String name)
           
 Configuration getConfiguration()
           
 int[] getCounters()
           
 byte[] getHeader()
           
 java.lang.String getHost()
           
 java.util.Collection getIncomingFilters()
           
 Logger getLogger()
           
 int getMaxPacketLength()
           
 java.lang.String getName()
           
 java.lang.String getOriginalRealm()
           
 java.util.Collection getOutgoingFilters()
           
 ISOPackager getPackager()
           
 int getPort()
           
 java.lang.String getRealm()
           
 java.net.ServerSocket getServerSocket()
           
 java.net.Socket getSocket()
           
 ISOClientSocketFactory getSocketFactory()
          Gets the ISOClientSocketFactory (may be null)
 int getTimeout()
           
 boolean isConnected()
           
 boolean isOverrideHeader()
           
 ISOMsg receive()
          Waits and receive an ISOMsg over the TCP/IP session
 void reconnect()
          Issues a disconnect followed by a connect
 void removeFilter(ISOFilter filter)
           
 void removeFilter(ISOFilter filter, int direction)
           
 void removeIncomingFilter(ISOFilter filter)
           
 void removeOutgoingFilter(ISOFilter filter)
           
 void resetCounters()
          reset stat info
 void send(ISOMsg m)
          sends an ISOMsg over the TCP/IP session
 void sendKeepAlive()
          Sends a high-level keep-alive message (zero length)
 void setConfiguration(Configuration cfg)
          Implements 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)
 void setHeader(byte[] header)
           
 void setHeader(java.lang.String header)
           
 void setHost(java.lang.String host)
           
 void setHost(java.lang.String host, int port)
          initialize an ISOChannel
 void setIncomingFilters(java.util.Collection filters)
           
 void setLocalAddress(java.lang.String iface, int port)
          initialize an ISOChannel
 void setLogger(Logger logger, java.lang.String realm)
           
 void setMaxPacketLength(int maxPacketLength)
           
 void setName(java.lang.String name)
          associates this ISOChannel with a name using NameRegistrar
 void setOutgoingFilters(java.util.Collection filters)
           
 void setOverrideHeader(boolean overrideHeader)
           
 void setPackager(ISOPackager p)
          set Packager for channel
 void setPort(int port)
           
 void setServerSocket(java.net.ServerSocket sock)
          Associates this ISOChannel with a server socket
 void setSocketFactory(ISOClientSocketFactory socketFactory)
          Sets the specified Socket Factory to create sockets
 void setTimeout(int timeout)
          sets socket timeout (as suggested by Leonard Thomas )
 void setUsable(boolean b)
           
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseChannel

public BaseChannel()
constructor shared by server and client ISOChannels (which have different signatures)


BaseChannel

public BaseChannel(java.lang.String host,
                   int port,
                   ISOPackager p)
constructs a client ISOChannel

Parameters:
host - server TCP Address
port - server port number
p - an ISOPackager
See Also:
ISOPackager

BaseChannel

public BaseChannel(ISOPackager p)
            throws java.io.IOException
constructs a server ISOChannel

Parameters:
p - an ISOPackager
Throws:
java.io.IOException
See Also:
ISOPackager

BaseChannel

public BaseChannel(ISOPackager p,
                   java.net.ServerSocket serverSocket)
            throws java.io.IOException
constructs a server ISOChannel associated with a Server Socket

Parameters:
p - an ISOPackager
serverSocket - where to accept a connection
Throws:
java.io.IOException
See Also:
ISOPackager
Method Detail

setHost

public void setHost(java.lang.String host,
                    int port)
initialize an ISOChannel

Specified by:
setHost in interface ClientChannel
Parameters:
host - server TCP Address
port - server port number

setLocalAddress

public void setLocalAddress(java.lang.String iface,
                            int port)
initialize an ISOChannel

Parameters:
host - server TCP Address
port - server port number

setHost

public void setHost(java.lang.String host)
Specified by:
setHost in interface BaseChannelMBean
Parameters:
host - to connect (client ISOChannel)

setPort

public void setPort(int port)
Specified by:
setPort in interface BaseChannelMBean
Parameters:
port - to connect (client ISOChannel)

getHost

public java.lang.String getHost()
Specified by:
getHost in interface BaseChannelMBean
Specified by:
getHost in interface ClientChannel
Returns:
hostname (may be null)

getPort

public int getPort()
Specified by:
getPort in interface BaseChannelMBean
Specified by:
getPort in interface ClientChannel
Returns:
port number

setPackager

public void setPackager(ISOPackager p)
set Packager for channel

Specified by:
setPackager in interface ISOChannel
Parameters:
p - an ISOPackager
See Also:
ISOPackager

getPackager

public ISOPackager getPackager()
Specified by:
getPackager in interface ISOChannel
Returns:
current packager

setServerSocket

public void setServerSocket(java.net.ServerSocket sock)
Associates this ISOChannel with a server socket

Parameters:
sock - where to accept a connection

resetCounters

public void resetCounters()
reset stat info


getCounters

public int[] getCounters()
Returns:
counters

isConnected

public boolean isConnected()
Specified by:
isConnected in interface BaseChannelMBean
Specified by:
isConnected in interface ISOChannel
Specified by:
isConnected in interface ISOSource
Returns:
the connection state

getSocket

public java.net.Socket getSocket()
Returns:
current socket

getServerSocket

public java.net.ServerSocket getServerSocket()
Returns:
current serverSocket

setTimeout

public void setTimeout(int timeout)
                throws java.net.SocketException
sets socket timeout (as suggested by Leonard Thomas )

Parameters:
timeout - in milliseconds
Throws:
java.net.SocketException

getTimeout

public int getTimeout()

connect

public void connect()
             throws java.io.IOException
Connects client ISOChannel to server

Specified by:
connect in interface BaseChannelMBean
Specified by:
connect in interface ISOChannel
Throws:
java.io.IOException

accept

public void accept(java.net.ServerSocket s)
            throws java.io.IOException
Accepts connection

Specified by:
accept in interface ServerChannel
Throws:
java.io.IOException

setUsable

public void setUsable(boolean b)
Specified by:
setUsable in interface ISOChannel
Parameters:
b - - new Usable state (used by ISOMUX internals to flag as unusable in order to force a reconnection)

send

public void send(ISOMsg m)
          throws java.io.IOException,
                 ISOException,
                 ISOFilter.VetoException
sends an ISOMsg over the TCP/IP session

Specified by:
send in interface ISOChannel
Specified by:
send in interface ISOSource
Parameters:
m - the Message to be sent
Throws:
java.io.IOException
ISOException
ISOFilter.VetoException;
ISOFilter.VetoException

sendKeepAlive

public void sendKeepAlive()
                   throws java.io.IOException
Sends a high-level keep-alive message (zero length)

Throws:
java.io.IOException

receive

public ISOMsg receive()
               throws java.io.IOException,
                      ISOException
Waits and receive an ISOMsg over the TCP/IP session

Specified by:
receive in interface ISOChannel
Returns:
the Message received
Throws:
java.io.IOException
ISOException

getBytes

public int getBytes(byte[] b)
             throws java.io.IOException
Low level receive

Parameters:
b - byte array
Throws:
java.io.IOException

disconnect

public void disconnect()
                throws java.io.IOException
disconnects the TCP/IP session. The instance is ready for a reconnection. There is no need to create a new ISOChannel

Specified by:
disconnect in interface BaseChannelMBean
Specified by:
disconnect in interface ISOChannel
Throws:
java.io.IOException

reconnect

public void reconnect()
               throws java.io.IOException
Issues a disconnect followed by a connect

Specified by:
reconnect in interface BaseChannelMBean
Specified by:
reconnect in interface ISOChannel
Throws:
java.io.IOException

setLogger

public void setLogger(Logger logger,
                      java.lang.String realm)
Specified by:
setLogger in interface LogSource

getRealm

public java.lang.String getRealm()
Specified by:
getRealm in interface LogSource

getLogger

public Logger getLogger()
Specified by:
getLogger in interface LogSource

getOriginalRealm

public java.lang.String getOriginalRealm()

setName

public void setName(java.lang.String name)
associates this ISOChannel with a name using NameRegistrar

Specified by:
setName in interface ISOChannel
Parameters:
name - name to register
See Also:
NameRegistrar

getName

public java.lang.String getName()
Specified by:
getName in interface ISOChannel
Returns:
this ISOChannel's name ("" if no name was set)

addFilter

public void addFilter(ISOFilter filter,
                      int direction)
Parameters:
filter - filter to add
direction - ISOMsg.INCOMING, ISOMsg.OUTGOING, 0 for both

addIncomingFilter

public void addIncomingFilter(ISOFilter filter)
Specified by:
addIncomingFilter in interface FilteredChannel
Parameters:
filter - incoming filter to add

addOutgoingFilter

public void addOutgoingFilter(ISOFilter filter)
Specified by:
addOutgoingFilter in interface FilteredChannel
Parameters:
filter - outgoing filter to add

addFilter

public void addFilter(ISOFilter filter)
Specified by:
addFilter in interface FilteredChannel
Parameters:
filter - filter to add (both directions, incoming/outgoing)

removeFilter

public void removeFilter(ISOFilter filter,
                         int direction)
Parameters:
filter - filter to remove
direction - ISOMsg.INCOMING, ISOMsg.OUTGOING, 0 for both

removeFilter

public void removeFilter(ISOFilter filter)
Specified by:
removeFilter in interface FilteredChannel
Parameters:
filter - filter to remove (both directions)

removeIncomingFilter

public void removeIncomingFilter(ISOFilter filter)
Specified by:
removeIncomingFilter in interface FilteredChannel
Parameters:
filter - incoming filter to remove

removeOutgoingFilter

public void removeOutgoingFilter(ISOFilter filter)
Specified by:
removeOutgoingFilter in interface FilteredChannel
Parameters:
filter - outgoing filter to remove

setConfiguration

public void setConfiguration(Configuration cfg)
                      throws ConfigurationException
Implements Configurable
Properties:
(host not present indicates a ServerChannel)

Specified by:
setConfiguration in interface Configurable
Parameters:
cfg - Configuration
Throws:
ConfigurationException

getConfiguration

public Configuration getConfiguration()

getIncomingFilters

public java.util.Collection getIncomingFilters()
Specified by:
getIncomingFilters in interface FilteredChannel
Returns:
Collection containing all incoming filters

getOutgoingFilters

public java.util.Collection getOutgoingFilters()
Specified by:
getOutgoingFilters in interface FilteredChannel
Returns:
Collection containing all outgoing filters

setIncomingFilters

public void setIncomingFilters(java.util.Collection filters)
Specified by:
setIncomingFilters in interface FilteredChannel
Parameters:
filters - incoming filter set

setOutgoingFilters

public void setOutgoingFilters(java.util.Collection filters)
Specified by:
setOutgoingFilters in interface FilteredChannel
Parameters:
filters - outgoing filter set

setHeader

public void setHeader(byte[] header)

setHeader

public void setHeader(java.lang.String header)

getHeader

public byte[] getHeader()

setOverrideHeader

public void setOverrideHeader(boolean overrideHeader)

isOverrideHeader

public boolean isOverrideHeader()

getChannel

public static ISOChannel getChannel(java.lang.String name)
                             throws NameRegistrar.NotFoundException
Returns:
ISOChannel instance with given name.
Throws:
NameRegistrar.NotFoundException;
NameRegistrar.NotFoundException
See Also:
NameRegistrar

getSocketFactory

public ISOClientSocketFactory getSocketFactory()
Gets the ISOClientSocketFactory (may be null)

Since:
1.3.3
See Also:
ISOClientSocketFactory

setSocketFactory

public void setSocketFactory(ISOClientSocketFactory socketFactory)
Sets the specified Socket Factory to create sockets

Specified by:
setSocketFactory in interface FactoryChannel
Parameters:
socketFactory - the ISOClientSocketFactory
Since:
1.3.3
See Also:
ISOClientSocketFactory

getMaxPacketLength

public int getMaxPacketLength()

setMaxPacketLength

public void setMaxPacketLength(int maxPacketLength)

clone

public java.lang.Object clone()
Description copied from interface: ISOChannel
Expose channel clonning interface

Specified by:
clone in interface ISOChannel
Overrides:
clone in class java.lang.Object

jPOS.org