org.jpos.iso
Class ISOServer

java.lang.Object
  extended by java.util.Observable
      extended by org.jpos.iso.ISOServer
All Implemented Interfaces:
Runnable, Observer, Configurable, ISOServerMBean, ISOServerSocketFactory, Loggeable, LogSource, ThreadPoolMBean

public class ISOServer
extends Observable
implements LogSource, Runnable, Observer, ISOServerMBean, Configurable, Loggeable, ISOServerSocketFactory

Accept ServerChannel sessions and forwards them to ISORequestListeners

Version:
$Revision$ $Date$
Author:
Alejandro P. Revilla, Bharavi Gade

Nested Class Summary
protected  class ISOServer.Session
           
 
Field Summary
protected  Configuration cfg
           
protected  Collection clientIncomingFilters
           
protected  Collection clientOutgoingFilters
           
protected  ISOChannel clientSideChannel
           
static int CONNECT
           
static int DEFAULT_MAX_THREADS
           
protected  boolean ignoreISOExceptions
           
static String LAST
           
protected  long lastTxn
           
protected  Collection listeners
           
protected  Logger logger
           
protected  String realm
           
protected  String realmChannel
           
static int SIZEOF_CNT
           
protected  ISOServerSocketFactory socketFactory
           
 
Constructor Summary
ISOServer(int port, ServerChannel clientSide, ThreadPool pool)
           
 
Method Summary
 void addISORequestListener(ISORequestListener l)
          add an ISORequestListener
 ServerSocket createServerSocket(int port)
          Create a server socket on the specified port (port 0 indicates an anonymous port).
protected  ISOServer.Session createSession(ServerChannel channel)
           
 void dump(PrintStream p, String indent)
           
 int getActiveConnections()
           
 int getConnectionCount()
           
 int getConnections()
           
 int[] getCounters()
           
 String getCountersAsString()
           
 String getCountersAsString(String isoChannelName)
           
 int getIdleCount()
           
 long getIdleTimeInMillis()
           
 ISOChannel getISOChannel(String name)
           
 String getISOChannelNames()
           
 int getJobCount()
           
 ISOChannel getLastConnectedISOChannel()
           
 long getLastTxnTimestampInMillis()
           
 Logger getLogger()
           
 int getMaxPoolSize()
           
 String getName()
           
 int getPendingCount()
           
 int getPoolSize()
           
 int getPort()
           
 String getRealm()
           
 int getRXCounter()
           
static ISOServer getServer(String name)
           
 ISOServerSocketFactory getSocketFactory()
          Gets the ISOClientSocketFactory (may be null)
 int getTXCounter()
           
 void removeISORequestListener(ISORequestListener l)
          remove an ISORequestListener
 void resetCounters()
           
 void run()
           
 void setConfiguration(Configuration cfg)
           
 void setLogger(Logger logger, String realm)
           
 void setName(String name)
          associates this ISOServer with a name using NameRegistrar
 void setSocketFactory(ISOServerSocketFactory socketFactory)
          Sets the specified Socket Factory to create sockets
 void shutdown()
          Shutdown this server
 void update(Observable o, Object arg)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

clientSideChannel

protected ISOChannel clientSideChannel

clientOutgoingFilters

protected Collection clientOutgoingFilters

clientIncomingFilters

protected Collection clientIncomingFilters

listeners

protected Collection listeners

DEFAULT_MAX_THREADS

public static final int DEFAULT_MAX_THREADS
See Also:
Constant Field Values

LAST

public static final String LAST
See Also:
Constant Field Values

lastTxn

protected long lastTxn

logger

protected Logger logger

realm

protected String realm

realmChannel

protected String realmChannel

socketFactory

protected ISOServerSocketFactory socketFactory

CONNECT

public static final int CONNECT
See Also:
Constant Field Values

SIZEOF_CNT

public static final int SIZEOF_CNT
See Also:
Constant Field Values

cfg

protected Configuration cfg

ignoreISOExceptions

protected boolean ignoreISOExceptions
Constructor Detail

ISOServer

public ISOServer(int port,
                 ServerChannel clientSide,
                 ThreadPool pool)
Parameters:
port - port to listen
clientSide - client side ISOChannel (where we accept connections)
pool - ThreadPool (created if null)
Method Detail

createSession

protected ISOServer.Session createSession(ServerChannel channel)

addISORequestListener

public void addISORequestListener(ISORequestListener l)
add an ISORequestListener

Parameters:
l - request listener to be added
See Also:
ISORequestListener

removeISORequestListener

public void removeISORequestListener(ISORequestListener l)
remove an ISORequestListener

Parameters:
l - a request listener to be removed
See Also:
ISORequestListener

shutdown

public void shutdown()
Shutdown this server


createServerSocket

public ServerSocket createServerSocket(int port)
                                throws IOException
Description copied from interface: ISOServerSocketFactory
Create a server socket on the specified port (port 0 indicates an anonymous port).

Specified by:
createServerSocket in interface ISOServerSocketFactory
Parameters:
port - the port number
Returns:
the server socket on the specified port
Throws:
IOException - should an I/O error occur

run

public void run()
Specified by:
run in interface Runnable

setName

public void setName(String name)
associates this ISOServer with a name using NameRegistrar

Parameters:
name - name to register
See Also:
NameRegistrar

getServer

public static ISOServer getServer(String name)
                           throws NameRegistrar.NotFoundException
Returns:
ISOServer instance with given name.
Throws:
NameRegistrar.NotFoundException;
NameRegistrar.NotFoundException
See Also:
NameRegistrar

getName

public String getName()
Returns:
this ISOServer's name ("" if no name was set)

setLogger

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

getRealm

public String getRealm()
Specified by:
getRealm in interface LogSource

getLogger

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

update

public void update(Observable o,
                   Object arg)
Specified by:
update in interface Observer

getSocketFactory

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

Since:
1.3.3
See Also:
ISOClientSocketFactory

setSocketFactory

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

Parameters:
socketFactory - the ISOClientSocketFactory
Since:
1.3.3
See Also:
ISOClientSocketFactory

getPort

public int getPort()
Specified by:
getPort in interface ISOServerMBean

resetCounters

public void resetCounters()
Specified by:
resetCounters in interface ISOServerMBean

getConnectionCount

public int getConnectionCount()
Specified by:
getConnectionCount in interface ISOServerMBean
Returns:
number of connections accepted by this server

getJobCount

public int getJobCount()
Specified by:
getJobCount in interface ThreadPoolMBean
Returns:
number of jobs processed by this pool

getPoolSize

public int getPoolSize()
Specified by:
getPoolSize in interface ThreadPoolMBean
Returns:
number of active threads

getMaxPoolSize

public int getMaxPoolSize()
Specified by:
getMaxPoolSize in interface ThreadPoolMBean
Returns:
max number of active threads allowed

getIdleCount

public int getIdleCount()
Specified by:
getIdleCount in interface ThreadPoolMBean
Returns:
number of idle threads

getPendingCount

public int getPendingCount()
Specified by:
getPendingCount in interface ThreadPoolMBean
Returns:
number of Pending jobs

getActiveConnections

public int getActiveConnections()

getLastConnectedISOChannel

public ISOChannel getLastConnectedISOChannel()
Returns:
most recently connected ISOChannel or null

getISOChannel

public ISOChannel getISOChannel(String name)
Returns:
ISOChannel under the given name

setConfiguration

public void setConfiguration(Configuration cfg)
                      throws ConfigurationException
Specified by:
setConfiguration in interface Configurable
Parameters:
cfg - Configuration object
Throws:
ConfigurationException

getISOChannelNames

public String getISOChannelNames()
Specified by:
getISOChannelNames in interface ISOServerMBean

getCountersAsString

public String getCountersAsString()

getCounters

public int[] getCounters()

getTXCounter

public int getTXCounter()
Specified by:
getTXCounter in interface ISOServerMBean

getRXCounter

public int getRXCounter()
Specified by:
getRXCounter in interface ISOServerMBean

getConnections

public int getConnections()

getLastTxnTimestampInMillis

public long getLastTxnTimestampInMillis()
Specified by:
getLastTxnTimestampInMillis in interface ISOServerMBean

getIdleTimeInMillis

public long getIdleTimeInMillis()
Specified by:
getIdleTimeInMillis in interface ISOServerMBean

getCountersAsString

public String getCountersAsString(String isoChannelName)
Specified by:
getCountersAsString in interface ISOServerMBean

dump

public void dump(PrintStream p,
                 String indent)
Specified by:
dump in interface Loggeable


Copyright © 1998-2012 jPOS.org. All Rights Reserved.