|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.Observable
org.jpos.iso.BaseChannel
public abstract class BaseChannel
ISOChannel is an abstract class that provides functionality that allows the transmision and reception of ISO 8583 Messages over a TCP/IP session.
This class is not thread-safe.
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.
ISOMsg,
MUX,
ISOException,
CSChannel,
Logger| Field Summary | |
|---|---|
protected int[] |
cnt
|
protected byte[] |
header
|
protected Vector |
incomingFilters
|
protected Logger |
logger
|
protected String |
originalRealm
|
protected Vector |
outgoingFilters
|
protected boolean |
overrideHeader
|
protected ISOPackager |
packager
|
protected String |
realm
|
protected DataInputStream |
serverIn
|
protected Object |
serverInLock
|
protected DataOutputStream |
serverOut
|
protected Object |
serverOutLock
|
protected ServerSocket |
serverSocket
|
protected ISOClientSocketFactory |
socketFactory
|
protected boolean |
usable
|
| 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,
ServerSocket serverSocket)
constructs a server ISOChannel associated with a Server Socket |
|
BaseChannel(String host,
int port,
ISOPackager p)
constructs a client ISOChannel |
|
| Method Summary | |
|---|---|
void |
accept(ServerSocket s)
Accepts connection |
void |
addFilter(ISOFilter filter)
|
void |
addFilter(ISOFilter filter,
int direction)
|
void |
addIncomingFilter(ISOFilter filter)
|
void |
addOutgoingFilter(ISOFilter filter)
|
protected ISOMsg |
applyIncomingFilters(ISOMsg m,
byte[] header,
byte[] image,
LogEvent evt)
|
protected ISOMsg |
applyIncomingFilters(ISOMsg m,
LogEvent evt)
|
protected ISOMsg |
applyOutgoingFilters(ISOMsg m,
LogEvent evt)
|
protected void |
applyTimeout()
|
Object |
clone()
Expose channel clonning interface |
void |
connect()
Connects client ISOChannel to server |
protected void |
connect(Socket socket)
setup I/O Streams from socket |
protected ISOMsg |
createISOMsg()
|
protected ISOMsg |
createMsg()
support old factory method name for backward compatibility |
void |
disconnect()
disconnects the TCP/IP session. |
int |
getBytes(byte[] b)
Low level receive |
static ISOChannel |
getChannel(String name)
|
Configuration |
getConfiguration()
|
int[] |
getCounters()
|
protected ISOHeader |
getDynamicHeader(byte[] image)
Allow subclasses to override the Default header on incoming messages. |
protected ISOPackager |
getDynamicPackager(byte[] image)
allow subclasses to override default packager on outgoing messages |
protected ISOPackager |
getDynamicPackager(byte[] header,
byte[] image)
allow subclasses to override default packager on outgoing messages |
protected ISOPackager |
getDynamicPackager(ISOMsg m)
allow subclasses to override default packager on outgoing messages |
byte[] |
getHeader()
|
protected int |
getHeaderLength()
|
protected int |
getHeaderLength(byte[] b)
|
protected int |
getHeaderLength(ISOMsg m)
|
String |
getHost()
|
Collection |
getIncomingFilters()
|
Logger |
getLogger()
|
int |
getMaxPacketLength()
|
protected void |
getMessage(byte[] b,
int offset,
int len)
|
protected int |
getMessageLength()
|
protected void |
getMessageTrailler()
|
String |
getName()
|
String |
getOriginalRealm()
|
Collection |
getOutgoingFilters()
|
ISOPackager |
getPackager()
|
int |
getPort()
|
String |
getRealm()
|
ServerSocket |
getServerSocket()
|
Socket |
getSocket()
|
ISOClientSocketFactory |
getSocketFactory()
Gets the ISOClientSocketFactory (may be null) |
int |
getTimeout()
|
boolean |
isConnected()
|
boolean |
isOverrideHeader()
|
protected boolean |
isRejected(byte[] b)
|
protected Socket |
newSocket(String[] hosts,
int[] ports,
LogEvent evt)
|
protected Socket |
newSocket(String host,
int port)
factory method pattern (as suggested by Vincent.Greene@amo.com) |
protected void |
postConnectHook()
|
protected byte[] |
readHeader(int hLen)
Reads in a message header. |
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(byte[] b)
sends a byte[] over the TCP/IP session |
void |
send(ISOMsg m)
sends an ISOMsg over the TCP/IP session |
void |
sendKeepAlive()
Sends a high-level keep-alive message (zero length) |
protected void |
sendMessage(byte[] b,
int offset,
int len)
|
protected void |
sendMessageHeader(ISOMsg m,
int len)
|
protected void |
sendMessageLength(int len)
|
protected void |
sendMessageTrailler(ISOMsg m,
byte[] b)
|
protected void |
sendMessageTrailler(ISOMsg m,
int len)
Deprecated. use sendMessageTrailler(ISOMsg m, byte[] b) instead. |
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(String header)
|
void |
setHost(String host)
|
void |
setHost(String host,
int port)
initialize an ISOChannel |
void |
setIncomingFilters(Collection filters)
|
void |
setLocalAddress(String iface,
int port)
initialize an ISOChannel |
void |
setLogger(Logger logger,
String realm)
|
void |
setMaxPacketLength(int maxPacketLength)
|
void |
setName(String name)
associates this ISOChannel with a name using NameRegistrar |
void |
setOutgoingFilters(Collection filters)
|
void |
setOverrideHeader(boolean overrideHeader)
|
void |
setPackager(ISOPackager p)
set Packager for channel |
void |
setPort(int port)
|
void |
setServerSocket(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)
|
protected boolean |
shouldIgnore(byte[] b)
|
protected byte[] |
streamReceive()
|
protected void |
unpack(ISOMsg m,
byte[] b)
|
| Methods inherited from class java.util.Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean usable
protected boolean overrideHeader
protected DataInputStream serverIn
protected DataOutputStream serverOut
protected Object serverInLock
protected Object serverOutLock
protected ISOPackager packager
protected ServerSocket serverSocket
protected Vector incomingFilters
protected Vector outgoingFilters
protected ISOClientSocketFactory socketFactory
protected int[] cnt
protected Logger logger
protected String realm
protected String originalRealm
protected byte[] header
| Constructor Detail |
|---|
public BaseChannel()
public BaseChannel(String host,
int port,
ISOPackager p)
host - server TCP Addressport - server port numberp - an ISOPackagerISOPackager
public BaseChannel(ISOPackager p)
throws IOException
p - an ISOPackager
IOException - on errorISOPackager
public BaseChannel(ISOPackager p,
ServerSocket serverSocket)
throws IOException
p - an ISOPackagerserverSocket - where to accept a connection
IOException - on errorISOPackager| Method Detail |
|---|
public void setHost(String host,
int port)
setHost in interface ClientChannelhost - server TCP Addressport - server port number
public void setLocalAddress(String iface,
int port)
iface - server TCP Addressport - server port numberpublic void setHost(String host)
setHost in interface BaseChannelMBeanhost - to connect (client ISOChannel)public void setPort(int port)
setPort in interface BaseChannelMBeanport - to connect (client ISOChannel)public String getHost()
getHost in interface BaseChannelMBeangetHost in interface ClientChannelpublic int getPort()
getPort in interface BaseChannelMBeangetPort in interface ClientChannelpublic void setPackager(ISOPackager p)
setPackager in interface ISOChannelp - an ISOPackagerISOPackagerpublic ISOPackager getPackager()
getPackager in interface ISOChannelpublic void setServerSocket(ServerSocket sock)
sock - where to accept a connectionpublic void resetCounters()
public int[] getCounters()
public boolean isConnected()
isConnected in interface BaseChannelMBeanisConnected in interface ISOChannelisConnected in interface ISOSource
protected void connect(Socket socket)
throws IOException
socket - a Socket (client or server)
IOException - on error
protected void postConnectHook()
throws IOException
IOException
protected Socket newSocket(String host,
int port)
throws IOException
host - remote hostport - remote port
IOException - on error
Use Socket factory if exists. If it is missing create a normal socketISOClientSocketFactory
protected Socket newSocket(String[] hosts,
int[] ports,
LogEvent evt)
throws IOException
IOExceptionpublic Socket getSocket()
public ServerSocket getServerSocket()
public void setTimeout(int timeout)
throws SocketException
timeout - in milliseconds
SocketException - on errorpublic int getTimeout()
protected void applyTimeout()
throws SocketException
SocketException
public void connect()
throws IOException
connect in interface BaseChannelMBeanconnect in interface ISOChannelIOException
public void accept(ServerSocket s)
throws IOException
accept in interface ServerChannelIOExceptionpublic void setUsable(boolean b)
setUsable in interface ISOChannelb - - new Usable state (used by ISOMUX internals to
flag as unusable in order to force a reconnection)protected ISOPackager getDynamicPackager(ISOMsg m)
m - outgoing ISOMsg
protected ISOPackager getDynamicPackager(byte[] image)
image - incoming message image
protected ISOPackager getDynamicPackager(byte[] header,
byte[] image)
header - message headerimage - incoming message image
protected ISOHeader getDynamicHeader(byte[] image)
image - message image
protected void sendMessageLength(int len)
throws IOException
IOException
protected void sendMessageHeader(ISOMsg m,
int len)
throws IOException
IOException
protected void sendMessageTrailler(ISOMsg m,
int len)
throws IOException
m - a reference to the ISOMsglen - the packed image length
IOException - on error
protected void sendMessageTrailler(ISOMsg m,
byte[] b)
throws IOException
IOException
protected void getMessageTrailler()
throws IOException
IOException
protected void getMessage(byte[] b,
int offset,
int len)
throws IOException,
ISOException
IOException
ISOException
protected int getMessageLength()
throws IOException,
ISOException
IOException
ISOExceptionprotected int getHeaderLength()
protected int getHeaderLength(byte[] b)
protected int getHeaderLength(ISOMsg m)
protected byte[] streamReceive()
throws IOException
IOException
protected void sendMessage(byte[] b,
int offset,
int len)
throws IOException
IOException
public void send(ISOMsg m)
throws IOException,
ISOException
send in interface ISOChannelsend in interface ISOSourcem - the Message to be sent
IOException
ISOException
ISOFilter.VetoException;
public void send(byte[] b)
throws IOException,
ISOException
send in interface ISOChannelb - the byte array to be sent
IOException
ISOException
ISOFilter.VetoException;
public void sendKeepAlive()
throws IOException
IOException - on exceptionprotected boolean isRejected(byte[] b)
protected boolean shouldIgnore(byte[] b)
protected ISOMsg createMsg()
protected ISOMsg createISOMsg()
protected byte[] readHeader(int hLen)
throws IOException
hLen - The Length og the reader to read
IOException - on error
public ISOMsg receive()
throws IOException,
ISOException
receive in interface ISOChannelIOException
ISOException
public int getBytes(byte[] b)
throws IOException
b - byte array
IOException - on error
public void disconnect()
throws IOException
disconnect in interface BaseChannelMBeandisconnect in interface ISOChannelIOException
public void reconnect()
throws IOException
reconnect in interface BaseChannelMBeanreconnect in interface ISOChannelIOException
public void setLogger(Logger logger,
String realm)
setLogger in interface LogSourcepublic String getRealm()
getRealm in interface LogSourcepublic Logger getLogger()
getLogger in interface LogSourcepublic String getOriginalRealm()
public void setName(String name)
setName in interface ISOChannelname - name to registerNameRegistrarpublic String getName()
getName in interface ISOChannel
public void addFilter(ISOFilter filter,
int direction)
filter - filter to adddirection - ISOMsg.INCOMING, ISOMsg.OUTGOING, 0 for bothpublic void addIncomingFilter(ISOFilter filter)
addIncomingFilter in interface FilteredChannelfilter - incoming filter to addpublic void addOutgoingFilter(ISOFilter filter)
addOutgoingFilter in interface FilteredChannelfilter - outgoing filter to addpublic void addFilter(ISOFilter filter)
addFilter in interface FilteredChannelfilter - filter to add (both directions, incoming/outgoing)
public void removeFilter(ISOFilter filter,
int direction)
filter - filter to removedirection - ISOMsg.INCOMING, ISOMsg.OUTGOING, 0 for bothpublic void removeFilter(ISOFilter filter)
removeFilter in interface FilteredChannelfilter - filter to remove (both directions)public void removeIncomingFilter(ISOFilter filter)
removeIncomingFilter in interface FilteredChannelfilter - incoming filter to removepublic void removeOutgoingFilter(ISOFilter filter)
removeOutgoingFilter in interface FilteredChannelfilter - outgoing filter to remove
protected ISOMsg applyOutgoingFilters(ISOMsg m,
LogEvent evt)
throws ISOFilter.VetoException
ISOFilter.VetoException
protected ISOMsg applyIncomingFilters(ISOMsg m,
LogEvent evt)
throws ISOFilter.VetoException
ISOFilter.VetoException
protected ISOMsg applyIncomingFilters(ISOMsg m,
byte[] header,
byte[] image,
LogEvent evt)
throws ISOFilter.VetoException
ISOFilter.VetoException
protected void unpack(ISOMsg m,
byte[] b)
throws ISOException
ISOException
public void setConfiguration(Configuration cfg)
throws ConfigurationException
setConfiguration in interface Configurablecfg - Configuration
ConfigurationExceptionpublic Configuration getConfiguration()
public Collection getIncomingFilters()
getIncomingFilters in interface FilteredChannelpublic Collection getOutgoingFilters()
getOutgoingFilters in interface FilteredChannelpublic void setIncomingFilters(Collection filters)
setIncomingFilters in interface FilteredChannelfilters - incoming filter setpublic void setOutgoingFilters(Collection filters)
setOutgoingFilters in interface FilteredChannelfilters - outgoing filter setpublic void setHeader(byte[] header)
public void setHeader(String header)
public byte[] getHeader()
public void setOverrideHeader(boolean overrideHeader)
public boolean isOverrideHeader()
public static ISOChannel getChannel(String name)
throws NameRegistrar.NotFoundException
name - the Channel's name (without the "channel." prefix)
NameRegistrar.NotFoundException;
NameRegistrar.NotFoundExceptionNameRegistrarpublic ISOClientSocketFactory getSocketFactory()
ISOClientSocketFactorypublic void setSocketFactory(ISOClientSocketFactory socketFactory)
setSocketFactory in interface FactoryChannelsocketFactory - the ISOClientSocketFactoryISOClientSocketFactorypublic int getMaxPacketLength()
public void setMaxPacketLength(int maxPacketLength)
public Object clone()
ISOChannel
clone in interface ISOChannelclone in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||