Class ChannelAdaptor
java.lang.Object
org.jpos.q2.QBeanSupport
org.jpos.q2.iso.ChannelAdaptor
- All Implemented Interfaces:
Configurable, ExceptionHandlerConfigAware, Channel, ChannelAdaptorMBean, QBean, QBeanSupportMBean, QPersist, Loggeable
- Direct Known Subclasses:
MultiSessionChannelAdaptor
public class ChannelAdaptor
extends QBeanSupport
implements ChannelAdaptorMBean, Channel, Loggeable, ExceptionHandlerConfigAware
A Q2 adaptor that wraps an
ISOChannel for use within the Q2 container.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassBackground thread that reads incoming messages from the channel.classBackground thread that forwards outgoing messages to the channel. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected SpaceThe space used for inter-process message passing.Fields inherited from class QBeanSupport
cfg, log, scheduledThreadPoolExecutorModifier and TypeFieldDescriptionprotected ConfigurationConfiguration applied to this bean by the container.protected LogLogger associated with this bean.protected ScheduledThreadPoolExecutorLazily-allocated scheduler shared with subclasses; seeQBeanSupport.getScheduledThreadPoolExecutor().Fields inherited from interface QBean
DESTROYED, FAILED, STARTED, STARTING, stateString, STOPPED, STOPPINGModifier and TypeFieldDescriptionstatic final intQBean has been destroyed.static final intQBean has failed.static final intQBean is running.static final intQBean is in the process of starting.static final String[]Human-readable names for each QBean state, indexed by state constant.static final intQBean is stopped.static final intQBean is in the process of stopping. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddFilters(FilteredChannel channel, org.jdom2.Element e, QFactory fact) Registers filters defined in the configuration element with the channel.protected voidappend(StringBuilder sb, String name, int value) Appends a name=value counter entry to the string builder.protected voidWaits until the reconnect token clears, then attempts to reconnect.protected StringReturns the default realm for this bean; subclasses may override.voidCalled during the destroy lifecycle phase; subclasses may override.protected voidDisconnects the channel and releases associated resources.voiddump(PrintStream p, String indent) Dumps a human-readable representation of this object to the print stream.intReturns the number of successful connections since last reset.Returns all counters as a human-readable string.getHost()Returns the remote host name or address.longReturns the idle time since the last transaction.Returns the incoming space queue name.longReturns the timestamp of the last transaction.Returns the outgoing space queue name.intgetPort()Returns the remote port number.longReturns the reconnect delay.intReturns the received message count.Returns the socket factory class name.intReturns the transmitted message count.protected SpacegrabSpace(org.jdom2.Element e) Returns the Space referenced by the given element, or the default space if null.protected ISOChannelInitialises and returns the ISOChannel from the current configuration.voidCalled during the init lifecycle phase; subclasses may override.protected voidInitialises the Space and in/out queues used by this adaptor.booleanReturns true if the channel is currently connected.newChannel(org.jdom2.Element e, QFactory f) Parses a<channel>element, returning anISOChannel.newChannel(org.jdom2.Element e, QFactory f, String fallbackRealm) Parses a<channel>element, using the provided fallback realm when none is configured.receive()Receive messagereceive(long timeout) Receive messagevoidResets all message counters to zero.voidQueue a message to be transmitted by this adaptorvoidQueue a message to be transmitted by this adaptorvoidSets the remote host name or address.voidsetInQueue(String in) Sets the incoming space queue name.voidsetOutQueue(String out) Sets the outgoing space queue name.voidsetPort(int port) Sets the remote port number.voidsetReconnectDelay(long delay) Sets the reconnect delay.voidsetSocketFactory(String sFac) Sets the socket factory class name.voidCalled during the start lifecycle phase; subclasses may override.voidCalled during the stop lifecycle phase; subclasses may override.Methods inherited from class QBeanSupport
addAttr, close, createElement, destroy, getAttrs, getAttrs, getConfiguration, getDump, getFactory, getLoader, getLoaderURLS, getLog, getLogger, getName, getPersist, getProperties, getProperty, getRealm, getScheduledThreadPoolExecutor, getServer, getState, getStateAsString, init, isModified, running, setAttr, setConfiguration, setLogger, setModified, setName, setPersist, setProperty, setRealm, setServer, setState, start, stopModifier and TypeMethodDescriptionprotected voidAppends an<attr>child element with name/type/value toe.protected voidCloses a sequence ofCloseableresources, logging any failures as a warning.protected org.jdom2.ElementcreateElement(String name, Class mbeanClass) Builds a JDOMElementreflecting the bean's persistent attributes, driven by the JavaBean introspection ofmbeanClass.voiddestroy()destroy the serviceprotected IteratorgetAttrs()Iterates over top-level<attr>children of the persisted element.protected IteratorIterates over<attr>children nested under the given parent element name.Returns the configuration applied to this bean.getDump()Returns a textual dump of this bean's state.Returns theQFactoryassociated with the hosting Q2 server.Returns the QClassLoader for this bean.URL[]Returns the URLs registered with the class loader.getLog()Returns theLogused by this bean.Returns the logger name.getName()Returns the bean name.org.jdom2.ElementReturns the persistent configuration element for this QBean.protected IteratorgetProperties(String parent) Iterates over<property>children nested under the given parent element name.protected StringgetProperty(Iterator props, String name) Returns the value of the named property from an iterator of<property>elements.getRealm()Returns the logging realm.protected ScheduledThreadPoolExecutorLazily creates and returns aScheduledThreadPoolExecutorfor use by subclasses.Returns the Q2 server instance.intgetState()Returns the current state of this QBean.Returns the current state as a human-readable string.voidinit()init the servicebooleanReturnstrueif this QBean's configuration has been modified since last save.booleanrunning()Indicates whether this bean is currently starting or running.protected voidUpdates the value of the named attribute within an iterator of<attr>elements.voidConfigures this object with the suppliedConfiguration.voidSets the logger by name.voidsetModified(boolean modified) Marks this bean's persistent state as modified or in sync.voidSets the bean name.voidsetPersist(org.jdom2.Element persist) Sets the persistent configuration element.protected voidsetProperty(Iterator props, String name, String value) Updates the value attribute of the named property within an iterator of<property>elements.voidSets the logging realm.voidSets the Q2 server instance for this QBean.voidsetState(int state) Sets the lifecycle state of this bean.voidstart()start the servicevoidstop()stop the serviceMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ExceptionHandlerConfigAware
addExceptionHandlersModifier and TypeMethodDescriptiondefault voidaddExceptionHandlers(ExceptionHandlerAware receiver, org.jdom2.Element elem, QFactory fact) Parsesexception-handlerchild elements fromelemand registers them withreceiver.Methods 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
-
sp
-
-
Constructor Details
-
ChannelAdaptor
public ChannelAdaptor()Default constructor.
-
-
Method Details
-
defaultRealm
Description copied from class:QBeanSupportReturns the default realm for this bean; subclasses may override.- Overrides:
defaultRealmin classQBeanSupport- Returns:
- default realm string, or null
-
initService
Description copied from class:QBeanSupportCalled during the init lifecycle phase; subclasses may override.- Overrides:
initServicein classQBeanSupport- Throws:
ConfigurationException
-
startService
Description copied from class:QBeanSupportCalled during the start lifecycle phase; subclasses may override.- Overrides:
startServicein classQBeanSupport
-
stopService
Description copied from class:QBeanSupportCalled during the stop lifecycle phase; subclasses may override.- Overrides:
stopServicein classQBeanSupport
-
destroyService
Description copied from class:QBeanSupportCalled during the destroy lifecycle phase; subclasses may override.- Overrides:
destroyServicein classQBeanSupport
-
setReconnectDelay
Description copied from interface:ChannelAdaptorMBeanSets the reconnect delay.- Specified by:
setReconnectDelayin interfaceChannelAdaptorMBean- Parameters:
delay- reconnect delay in milliseconds
-
getReconnectDelay
Description copied from interface:ChannelAdaptorMBeanReturns the reconnect delay.- Specified by:
getReconnectDelayin interfaceChannelAdaptorMBean- Returns:
- reconnect delay in milliseconds
-
setInQueue
Description copied from interface:ChannelAdaptorMBeanSets the incoming space queue name.- Specified by:
setInQueuein interfaceChannelAdaptorMBean- Parameters:
in- name of the incoming space queue
-
getInQueue
Description copied from interface:ChannelAdaptorMBeanReturns the incoming space queue name.- Specified by:
getInQueuein interfaceChannelAdaptorMBean- Returns:
- name of the incoming space queue
-
setOutQueue
Description copied from interface:ChannelAdaptorMBeanSets the outgoing space queue name.- Specified by:
setOutQueuein interfaceChannelAdaptorMBean- Parameters:
out- name of the outgoing space queue
-
send
-
send
-
receive
-
receive
-
isConnected
Description copied from interface:ChannelAdaptorMBeanReturns true if the channel is currently connected.- Specified by:
isConnectedin interfaceChannelAdaptorMBean- Returns:
- true if channel is connected
-
getOutQueue
Description copied from interface:ChannelAdaptorMBeanReturns the outgoing space queue name.- Specified by:
getOutQueuein interfaceChannelAdaptorMBean- Returns:
- name of the outgoing space queue
-
newChannel
Parses a<channel>element, returning anISOChannel.- Parameters:
e- the configuration elementf- the QFactory- Returns:
- a configured ISOChannel
- Throws:
ConfigurationException- on configuration error
-
newChannel
public ISOChannel newChannel(org.jdom2.Element e, QFactory f, String fallbackRealm) throws ConfigurationException Parses a<channel>element, using the provided fallback realm when none is configured.- Parameters:
e- the configuration elementf- the QFactoryfallbackRealm- realm to use if none is configured- Returns:
- a configured ISOChannel
- Throws:
ConfigurationException- on configuration error
-
addFilters
protected void addFilters(FilteredChannel channel, org.jdom2.Element e, QFactory fact) throws ConfigurationException Registers filters defined in the configuration element with the channel.- Parameters:
channel- the channel to configuree- the configuration elementfact- the QFactory- Throws:
ConfigurationException- on error
-
initChannel
Initialises and returns the ISOChannel from the current configuration.- Returns:
- the initialised channel
- Throws:
ConfigurationException- on error
-
initSpaceAndQueues
Initialises the Space and in/out queues used by this adaptor.- Throws:
ConfigurationException- on error
-
checkConnection
Waits until the reconnect token clears, then attempts to reconnect. -
disconnect
Disconnects the channel and releases associated resources. -
setHost
Description copied from interface:ChannelAdaptorMBeanSets the remote host name or address.- Specified by:
setHostin interfaceChannelAdaptorMBean- Parameters:
host- remote host
-
getHost
Description copied from interface:ChannelAdaptorMBeanReturns the remote host name or address.- Specified by:
getHostin interfaceChannelAdaptorMBean- Returns:
- remote host
-
setPort
Description copied from interface:ChannelAdaptorMBeanSets the remote port number.- Specified by:
setPortin interfaceChannelAdaptorMBean- Parameters:
port- remote port
-
getPort
Description copied from interface:ChannelAdaptorMBeanReturns the remote port number.- Specified by:
getPortin interfaceChannelAdaptorMBean- Returns:
- remote port
-
setSocketFactory
Description copied from interface:ChannelAdaptorMBeanSets the socket factory class name.- Specified by:
setSocketFactoryin interfaceChannelAdaptorMBean- Parameters:
sFac- socket factory class name
-
resetCounters
Description copied from interface:ChannelAdaptorMBeanResets all message counters to zero.- Specified by:
resetCountersin interfaceChannelAdaptorMBean
-
getCountersAsString
Description copied from interface:ChannelAdaptorMBeanReturns all counters as a human-readable string.- Specified by:
getCountersAsStringin interfaceChannelAdaptorMBean- Returns:
- counters string
-
getTXCounter
Description copied from interface:ChannelAdaptorMBeanReturns the transmitted message count.- Specified by:
getTXCounterin interfaceChannelAdaptorMBean- Returns:
- TX count
-
getRXCounter
Description copied from interface:ChannelAdaptorMBeanReturns the received message count.- Specified by:
getRXCounterin interfaceChannelAdaptorMBean- Returns:
- RX count
-
getConnectsCounter
Description copied from interface:ChannelAdaptorMBeanReturns the number of successful connections since last reset.- Specified by:
getConnectsCounterin interfaceChannelAdaptorMBean- Returns:
- connect count
-
getLastTxnTimestampInMillis
Description copied from interface:ChannelAdaptorMBeanReturns the timestamp of the last transaction.- Specified by:
getLastTxnTimestampInMillisin interfaceChannelAdaptorMBean- Returns:
- timestamp in milliseconds
-
getIdleTimeInMillis
Description copied from interface:ChannelAdaptorMBeanReturns the idle time since the last transaction.- Specified by:
getIdleTimeInMillisin interfaceChannelAdaptorMBean- Returns:
- idle time in milliseconds
-
getSocketFactory
Description copied from interface:ChannelAdaptorMBeanReturns the socket factory class name.- Specified by:
getSocketFactoryin interfaceChannelAdaptorMBean- Returns:
- socket factory class name
-
dump
-
grabSpace
-
append
Appends a name=value counter entry to the string builder.- Parameters:
sb- the builder to append toname- the counter namevalue- the counter value
-