Package org.jpos.iso
Class ISOServer
- java.lang.Object
-
- java.util.Observable
-
- org.jpos.iso.ISOServer
-
- All Implemented Interfaces:
java.lang.Runnable
,java.util.Observer
,Configurable
,ISOServerMBean
,ISOServerSocketFactory
,Loggeable
,LogSource
,ThreadPoolMBean
public class ISOServer extends java.util.Observable implements LogSource, java.lang.Runnable, java.util.Observer, ISOServerMBean, Configurable, Loggeable, ISOServerSocketFactory
Accept ServerChannel sessions and forwards them to ISORequestListeners
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
ISOServer.Session
-
Field Summary
Fields Modifier and Type Field Description protected Configuration
cfg
protected java.util.Collection
clientIncomingFilters
protected java.util.Collection
clientOutgoingFilters
protected ISOChannel
clientSideChannel
static int
CONNECT
static int
DEFAULT_MAX_THREADS
protected boolean
ignoreISOExceptions
static java.lang.String
LAST
protected long
lastTxn
protected java.util.Collection
listeners
protected Logger
logger
protected java.lang.String
realm
protected java.lang.String
realmChannel
protected java.util.List<ISOServerEventListener>
serverListeners
static int
SIZEOF_CNT
protected ISOServerSocketFactory
socketFactory
-
Constructor Summary
Constructors Constructor Description ISOServer(int port, ServerChannel clientSide, ThreadPool pool)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addISORequestListener(ISORequestListener l)
add an ISORequestListenervoid
addServerEventListener(ISOServerEventListener listener)
java.net.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(java.io.PrintStream p, java.lang.String indent)
void
fireEvent(java.util.EventObject event)
int
getActiveConnections()
int
getConnectionCount()
int
getConnections()
int[]
getCounters()
java.lang.String
getCountersAsString()
java.lang.String
getCountersAsString(java.lang.String isoChannelName)
int
getIdleCount()
long
getIdleTimeInMillis()
ISOChannel
getISOChannel(java.lang.String name)
java.lang.String
getISOChannelNames()
int
getJobCount()
ISOChannel
getLastConnectedISOChannel()
long
getLastTxnTimestampInMillis()
Logger
getLogger()
int
getMaxPoolSize()
java.lang.String
getName()
int
getPendingCount()
int
getPoolSize()
int
getPort()
java.lang.String
getRealm()
int
getRXCounter()
static ISOServer
getServer(java.lang.String name)
ISOServerSocketFactory
getSocketFactory()
Gets the ISOClientSocketFactory (may be null)int
getTXCounter()
void
removeISORequestListener(ISORequestListener l)
remove an ISORequestListenervoid
removeServerEventListener(ISOServerEventListener listener)
void
resetCounters()
void
run()
void
setConfiguration(Configuration cfg)
void
setLogger(Logger logger, java.lang.String realm)
void
setName(java.lang.String name)
associates this ISOServer with a name using NameRegistrarvoid
setSocketFactory(ISOServerSocketFactory socketFactory)
Sets the specified Socket Factory to create socketsvoid
shutdown()
Shutdown this servervoid
update(java.util.Observable o, java.lang.Object arg)
-
-
-
Field Detail
-
clientSideChannel
protected ISOChannel clientSideChannel
-
clientOutgoingFilters
protected java.util.Collection clientOutgoingFilters
-
clientIncomingFilters
protected java.util.Collection clientIncomingFilters
-
listeners
protected java.util.Collection listeners
-
DEFAULT_MAX_THREADS
public static final int DEFAULT_MAX_THREADS
- See Also:
- Constant Field Values
-
LAST
public static final java.lang.String LAST
- See Also:
- Constant Field Values
-
lastTxn
protected long lastTxn
-
realm
protected java.lang.String realm
-
realmChannel
protected java.lang.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
-
serverListeners
protected java.util.List<ISOServerEventListener> serverListeners
-
-
Constructor Detail
-
ISOServer
public ISOServer(int port, ServerChannel clientSide, ThreadPool pool)
- Parameters:
port
- port to listenclientSide
- client side ISOChannel (where we accept connections)pool
- ThreadPool (created if null)
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration cfg) throws ConfigurationException
- Specified by:
setConfiguration
in interfaceConfigurable
- Parameters:
cfg
- Configuration object- Throws:
ConfigurationException
-
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 java.net.ServerSocket createServerSocket(int port) throws java.io.IOException
Description copied from interface:ISOServerSocketFactory
Create a server socket on the specified port (port 0 indicates an anonymous port).- Specified by:
createServerSocket
in interfaceISOServerSocketFactory
- Parameters:
port
- the port number- Returns:
- the server socket on the specified port
- Throws:
java.io.IOException
- should an I/O error occur
-
createSession
protected ISOServer.Session createSession(ServerChannel channel)
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
setName
public void setName(java.lang.String name)
associates this ISOServer with a name using NameRegistrar- Parameters:
name
- name to register- See Also:
NameRegistrar
-
getServer
public static ISOServer getServer(java.lang.String name) throws NameRegistrar.NotFoundException
- Returns:
- ISOServer instance with given name.
- Throws:
NameRegistrar.NotFoundException
- See Also:
NameRegistrar
-
getName
public java.lang.String getName()
- Returns:
- this ISOServer's name ("" if no name was set)
-
update
public void update(java.util.Observable o, java.lang.Object arg)
- Specified by:
update
in interfacejava.util.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 interfaceISOServerMBean
-
resetCounters
public void resetCounters()
- Specified by:
resetCounters
in interfaceISOServerMBean
-
getConnectionCount
public int getConnectionCount()
- Specified by:
getConnectionCount
in interfaceISOServerMBean
- Returns:
- number of connections accepted by this server
-
getJobCount
public int getJobCount()
- Specified by:
getJobCount
in interfaceThreadPoolMBean
- Returns:
- number of jobs processed by this pool
-
getPoolSize
public int getPoolSize()
- Specified by:
getPoolSize
in interfaceThreadPoolMBean
- Returns:
- number of active threads
-
getMaxPoolSize
public int getMaxPoolSize()
- Specified by:
getMaxPoolSize
in interfaceThreadPoolMBean
- Returns:
- max number of active threads allowed
-
getIdleCount
public int getIdleCount()
- Specified by:
getIdleCount
in interfaceThreadPoolMBean
- Returns:
- number of idle threads
-
getPendingCount
public int getPendingCount()
- Specified by:
getPendingCount
in interfaceThreadPoolMBean
- Returns:
- number of Pending jobs
-
getActiveConnections
public int getActiveConnections()
-
getLastConnectedISOChannel
public ISOChannel getLastConnectedISOChannel()
- Returns:
- most recently connected ISOChannel or null
-
getISOChannel
public ISOChannel getISOChannel(java.lang.String name)
- Returns:
- ISOChannel under the given name
-
getISOChannelNames
public java.lang.String getISOChannelNames()
- Specified by:
getISOChannelNames
in interfaceISOServerMBean
-
getCountersAsString
public java.lang.String getCountersAsString()
-
getCounters
public int[] getCounters()
-
getTXCounter
public int getTXCounter()
- Specified by:
getTXCounter
in interfaceISOServerMBean
-
getRXCounter
public int getRXCounter()
- Specified by:
getRXCounter
in interfaceISOServerMBean
-
getConnections
public int getConnections()
-
getLastTxnTimestampInMillis
public long getLastTxnTimestampInMillis()
- Specified by:
getLastTxnTimestampInMillis
in interfaceISOServerMBean
-
getIdleTimeInMillis
public long getIdleTimeInMillis()
- Specified by:
getIdleTimeInMillis
in interfaceISOServerMBean
-
getCountersAsString
public java.lang.String getCountersAsString(java.lang.String isoChannelName)
- Specified by:
getCountersAsString
in interfaceISOServerMBean
-
dump
public void dump(java.io.PrintStream p, java.lang.String indent)
-
addServerEventListener
public void addServerEventListener(ISOServerEventListener listener)
-
removeServerEventListener
public void removeServerEventListener(ISOServerEventListener listener)
-
fireEvent
public void fireEvent(java.util.EventObject event)
-
-