Class ISOServer
java.lang.Object
java.util.Observable
org.jpos.iso.ISOServer
- All Implemented Interfaces:
Runnable, Observer, Configurable, ISOServerMBean, ISOServerSocketFactory, Loggeable, LogSource
public class ISOServer
extends Observable
implements LogSource, Runnable, Observer, ISOServerMBean, Configurable, Loggeable, ISOServerSocketFactory
Accept ServerChannel sessions and forwards them to ISORequestListeners
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected classHandles the ISO 8583 exchange for a single accepted server connection. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConfigurationThe server configuration.protected CollectionOutgoing and incoming filter chains for client channels.protected CollectionOutgoing and incoming filter chains for client channels.protected ISOChannelThe channel template used for client-side connections.static final intDefault maximum number of concurrent sessions.protected booleanIf true, ISOExceptions are silently ignored.static final StringRealm suffix used for the last connected channel.protected longTimestamp of the last transaction processed.protected List<ISORequestListener> Registered ISO request listeners.protected LoggerThe logger for this server.protected StringThe realm string for this server.protected StringThe realm string for channel sessions.protected List<ISOServerEventListener> Registered server event listeners.protected ISOServerSocketFactoryOptional factory for creating server sockets. -
Constructor Summary
ConstructorsConstructorDescriptionISOServer(int port, ServerChannel clientSide, int maxSessions) Constructs an ISOServer on the given port. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd an ISORequestListenervoidaddServerEventListener(ISOServerEventListener listener) Registers a listener for server events.createServerSocket(int port) Create a server socket on the specified port (port 0 indicates an anonymous port).protected ISOServer.SessioncreateSession(ServerChannel channel) Creates a new server session for the given channel.voiddump(PrintStream p, String indent) Dumps a human-readable representation of this object to the print stream.voidfireEvent(EventObject event) Dispatches an event to all registered server event listeners.intReturns the current number of active (in-use) connections.intReturns the cumulative number of connections accepted by this server.intReturns the current number of active accepted connections.int[]Returns an array of [rx, tx, connected] counters across all active channels.Returns a human-readable string summarising RX/TX/connection counters.getCountersAsString(String isoChannelName) Returns counters as a string for the named channel.longReturns the idle time in milliseconds.getISOChannel(String name) Returns the ISOChannel registered under the given name.Returns the names of connected ISO channels.Returns the most recently accepted ISOChannel.longReturns the timestamp of the last transaction in milliseconds.Returns the Logger associated with this source.getName()Returns this server's registered name.intgetPort()Returns the port this server is listening on.getRealm()Returns the log realm associated with this source.intReturns the receive counter.static ISOServerReturns the ISOServer registered under the given name.Gets the ISOClientSocketFactory (may be null)intReturns the transmit counter.voidremove an ISORequestListenervoidUnregisters a previously added server event listener.voidResets all server counters.voidrun()voidConfigures this object with the suppliedConfiguration.voidAttaches aLoggerand realm to this log source.voidassociates this ISOServer with a name using NameRegistrarvoidsetSocketFactory(ISOServerSocketFactory socketFactory) Sets the specified Socket Factory to create socketsvoidshutdown()Shutdown this servervoidupdate(Observable o, Object arg) Methods inherited from class Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChangedMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Loggeable
dumpModifier and TypeMethodDescriptiondefault voiddump(PrintStream p, String indent, LogRenderer.Type type) Dumps a representation of this object using the specified renderer type.
-
Field Details
-
clientSideChannel
The channel template used for client-side connections. -
clientOutgoingFilters
Outgoing and incoming filter chains for client channels. -
clientIncomingFilters
Outgoing and incoming filter chains for client channels. -
listeners
Registered ISO request listeners. -
DEFAULT_MAX_SESSIONS
Default maximum number of concurrent sessions.- See Also:
-
LAST
-
lastTxn
Timestamp of the last transaction processed. -
logger
-
realm
-
realmChannel
The realm string for channel sessions. -
socketFactory
Optional factory for creating server sockets. -
cfg
The server configuration. -
ignoreISOExceptions
If true, ISOExceptions are silently ignored. -
serverListeners
Registered server event listeners.
-
-
Constructor Details
-
ISOServer
Constructs an ISOServer on the given port.- Parameters:
port- port to listenclientSide- client side ISOChannel, used as a "clonable template" to accept new connectionsmaxSessions- maximum number of concurrent sessions (0 = unlimited)
-
-
Method Details
-
setConfiguration
Description copied from interface:ConfigurableConfigures this object with the suppliedConfiguration.- Specified by:
setConfigurationin interfaceConfigurable- Parameters:
cfg- Configuration object- Throws:
ConfigurationException- if the configuration is invalid
-
addISORequestListener
add an ISORequestListener- Parameters:
l- request listener to be added- See Also:
-
removeISORequestListener
remove an ISORequestListener- Parameters:
l- a request listener to be removed- See Also:
-
shutdown
Shutdown this server -
createServerSocket
Description copied from interface:ISOServerSocketFactoryCreate a server socket on the specified port (port 0 indicates an anonymous port).- Specified by:
createServerSocketin interfaceISOServerSocketFactory- Parameters:
port- the port number- Returns:
- the server socket on the specified port
- Throws:
IOException- should an I/O error occur
-
createSession
Creates a new server session for the given channel.- Parameters:
channel- the accepted server channel- Returns:
- a new Session
-
run
-
setName
-
getServer
Returns the ISOServer registered under the given name.- Parameters:
name- the server's registered name- Returns:
- ISOServer instance with given name.
- Throws:
NameRegistrar.NotFoundException- if not found in registry- See Also:
-
getName
-
setLogger
-
getRealm
-
getLogger
-
update
-
getSocketFactory
Gets the ISOClientSocketFactory (may be null)- Returns:
- the configured server socket factory, or
null - Since:
- 1.3.3
- See Also:
-
setSocketFactory
Sets the specified Socket Factory to create sockets- Parameters:
socketFactory- the ISOClientSocketFactory- Since:
- 1.3.3
- See Also:
-
getPort
Description copied from interface:ISOServerMBeanReturns the port this server is listening on.- Specified by:
getPortin interfaceISOServerMBean- Returns:
- the port number
-
resetCounters
Description copied from interface:ISOServerMBeanResets all server counters.- Specified by:
resetCountersin interfaceISOServerMBean
-
getConnectionCount
Returns the cumulative number of connections accepted by this server.- Specified by:
getConnectionCountin interfaceISOServerMBean- Returns:
- number of connections accepted by this server
-
getLastConnectedISOChannel
Returns the most recently accepted ISOChannel.- Returns:
- most recently connected ISOChannel or null
-
getISOChannel
Returns the ISOChannel registered under the given name.- Parameters:
name- the channel name- Returns:
- ISOChannel under the given name
-
getISOChannelNames
Description copied from interface:ISOServerMBeanReturns the names of connected ISO channels.- Specified by:
getISOChannelNamesin interfaceISOServerMBean- Returns:
- channel names string
-
getCountersAsString
Returns a human-readable string summarising RX/TX/connection counters.- Returns:
- counters summary string
-
getCounters
Returns an array of [rx, tx, connected] counters across all active channels.- Returns:
- int array: [rx, tx, connected]
-
getTXCounter
Description copied from interface:ISOServerMBeanReturns the transmit counter.- Specified by:
getTXCounterin interfaceISOServerMBean- Returns:
- TX count
-
getRXCounter
Description copied from interface:ISOServerMBeanReturns the receive counter.- Specified by:
getRXCounterin interfaceISOServerMBean- Returns:
- RX count
-
getConnections
Returns the current number of active accepted connections.- Returns:
- active connection count
-
getLastTxnTimestampInMillis
Description copied from interface:ISOServerMBeanReturns the timestamp of the last transaction in milliseconds.- Specified by:
getLastTxnTimestampInMillisin interfaceISOServerMBean- Returns:
- last transaction timestamp
-
getIdleTimeInMillis
Description copied from interface:ISOServerMBeanReturns the idle time in milliseconds.- Specified by:
getIdleTimeInMillisin interfaceISOServerMBean- Returns:
- idle time
-
getCountersAsString
Description copied from interface:ISOServerMBeanReturns counters as a string for the named channel.- Specified by:
getCountersAsStringin interfaceISOServerMBean- Parameters:
isoChannelName- the channel name- Returns:
- counters string
-
dump
-
addServerEventListener
Registers a listener for server events.- Parameters:
listener- the listener to add
-
removeServerEventListener
Unregisters a previously added server event listener.- Parameters:
listener- the listener to remove
-
fireEvent
Dispatches an event to all registered server event listeners.- Parameters:
event- the event to dispatch
-
getActiveConnections
Returns the current number of active (in-use) connections.- Returns:
- number of active connections
-