Package org.frankframework.receivers
Class JavaListener<M>
java.lang.Object
org.frankframework.receivers.JavaListener<M>
- All Implemented Interfaces:
nl.nn.adapterframework.dispatcher.RequestProcessor
,HasPhysicalDestination
,IConfigurable
,IConfigurationAware
,IListener<M>
,INamedObject
,IPushingListener<M>
,IScopeProvider
,ServiceClient
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
@Category(BASIC)
public class JavaListener<M>
extends Object
implements IPushingListener<M>, nl.nn.adapterframework.dispatcher.RequestProcessor, HasPhysicalDestination, ServiceClient
Use this listener to receive messages from other adapters or a scheduler within the same Frank-application or from other components residing in the same JVM.
JavaListeners can receive calls made via de ibis-servicedispatcher, which should be located on the JVM classpath to receive calls from other components in the JVM. If you want to call an adapter in the same Frank-application, consider using the IbisLocalSender.
To understand what this listener does exactly, please remember that the Frank!Framework is a Java application. The JavaListener listens to Java method calls. You can issue Java method calls using a
To understand what this listener does exactly, please remember that the Frank!Framework is a Java application. The JavaListener listens to Java method calls. You can issue Java method calls using a
IbisJavaSender
(external call)
or IbisLocalSender
(internal call).
For more information see the ibis-servicedispatcher project.- Author:
- Gerrit van Brakel
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterMessageProcessed
(PipeLineResult processResult, RawMessageWrapper<M> rawMessage, PipeLineSession pipeLineSession) Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.void
configure()
is called once at startup of the framework in theconfigure()
method of the owner of this listener.extractMessage
(RawMessageWrapper<M> rawMessage, Map<String, Object> context) Extracts data from message obtained fromIPullingListener.getRawMessage(Map)
orIPushingListener.wrapRawMessage(Object, PipeLineSession)
.org.springframework.context.ApplicationContext
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.static JavaListener<?>
getListener
(String name) Returns JavaListener registered under the given namegetName()
boolean
boolean
isOpen()
boolean
boolean
processRequest
(String correlationId, String rawMessage, HashMap context) processRequest
(Message message, PipeLineSession session) Method to implement for processing a request.void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) void
setExceptionListener
(IbisExceptionListener listener) Set a (single) listener that will be notified of any exceptions.void
setHandler
(IMessageHandler<M> handler) Set the handler that will do the processing of the message.void
setHttpWsdl
(boolean httpWsdl) Iftrue
, the WSDL of the service provided by this listener will available for downloadvoid
setIsolated
(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.void
Deprecated, for removal: This API element is subject to removal in a future version.void
Internal name of the listener, as known to the adapter.void
setReturnedSessionKeys
(String string) Comma separated list of keys of session variables that should be returned to caller, for correct results as well as for erroneous results.void
setServiceName
(String jndiName) External Name of the listener.void
setSynchronous
(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.void
setThrowException
(boolean throwException) Should the JavaListener throw a ListenerException when it occurs or return an error messagevoid
start()
Prepares the listener for receiving messages.void
stop()
Close all resources used for listening.wrapRawMessage
(M rawMessage, PipeLineSession session) Wrap a raw message in a MessageWrapper.
-
Field Details
-
log
protected org.apache.logging.log4j.Logger log
-
-
Constructor Details
-
JavaListener
public JavaListener()
-
-
Method Details
-
configure
Description copied from interface:IListener
configure()
is called once at startup of the framework in theconfigure()
method of the owner of this listener. Purpose of this method is to reduce creating connections to databases etc. in theIPullingListener.getRawMessage(Map)
method. As much as possible class-instantiating should take place in theconfigure()
orIListener.start()
method, to improve performance.- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceIListener<M>
- Throws:
ConfigurationException
-
start
public void start()Description copied from interface:IListener
Prepares the listener for receiving messages.open()
is called once each time the listener is started. -
stop
public void stop()Description copied from interface:IListener
Close all resources used for listening. Called once each time the listener is stopped. -
wrapRawMessage
Description copied from interface:IPushingListener
Wrap a raw message in a MessageWrapper. PopulatePipeLineSession
with properties from the message.- Specified by:
wrapRawMessage
in interfaceIPushingListener<M>
- Parameters:
rawMessage
- The raw message data, unwrappedsession
-PipeLineSession
to populate with properties from the message.- Returns:
- Wrapped raw message
-
processRequest
public String processRequest(String correlationId, String rawMessage, HashMap context) throws ListenerException - Specified by:
processRequest
in interfacenl.nn.adapterframework.dispatcher.RequestProcessor
- Throws:
ListenerException
-
processRequest
public Message processRequest(Message message, @Nonnull PipeLineSession session) throws ListenerException Description copied from interface:ServiceClient
Method to implement for processing a request. This will usually delegate to aIListener
implementation.
TODO: We may want to add the correlationId parameter back to this method, for cleaner calling and cleaner implementation.- Specified by:
processRequest
in interfaceServiceClient
- Parameters:
message
-Message
to processsession
-PipeLineSession
of the request. If the request has a correlation ID, it should be put into this session.- Returns:
- Resulting
Message
. - Throws:
ListenerException
- Thrown if an exception occurs.
-
getListener
Returns JavaListener registered under the given name -
getListenerNames
-
setExceptionListener
Description copied from interface:IPushingListener
Set a (single) listener that will be notified of any exceptions. The listener should use this listener to notify the receiver of any exception that occurs outside the processing of a message.- Specified by:
setExceptionListener
in interfaceIPushingListener<M>
-
afterMessageProcessed
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<M> rawMessage, PipeLineSession pipeLineSession) throws ListenerException Description copied from interface:IListener
Called to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessed
in interfaceIListener<M>
- Throws:
ListenerException
-
extractMessage
public Message extractMessage(@Nonnull RawMessageWrapper<M> rawMessage, @Nonnull Map<String, Object> context) throws ListenerExceptionDescription copied from interface:IListener
Extracts data from message obtained fromIPullingListener.getRawMessage(Map)
orIPushingListener.wrapRawMessage(Object, PipeLineSession)
. May also extract other parameters from the message and put those into the context.- Specified by:
extractMessage
in interfaceIListener<M>
- Parameters:
rawMessage
- TheRawMessageWrapper
from which to extract theMessage
.context
- Context to populate. Either aPipeLineSession
or aMap
threadContext depending on caller.- Returns:
- input
Message
for adapter. - Throws:
ListenerException
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationName
in interfaceHasPhysicalDestination
-
setName
Internal name of the listener, as known to the adapter. An IbisLocalSender refers to this name in itsjavaListener
-attribute.- Specified by:
setName
in interfaceINamedObject
-
setServiceName
External Name of the listener. An IbisJavaSender refers to this name in itsserviceName
-attribute. -
setLocal
Deprecated, for removal: This API element is subject to removal in a future version. -
setIsolated
Deprecated, for removal: This API element is subject to removal in a future version. -
setSynchronous
Deprecated, for removal: This API element is subject to removal in a future version.If setfalse
, the request is executed asynchronously. N.B. be aware that there is no limit on the number of threads generated- Default value
- true
-
setReturnedSessionKeys
Comma separated list of keys of session variables that should be returned to caller, for correct results as well as for erroneous results. If not set (not even to an empty value), all session keys can be returned.- Default value
- all session keys can be returned
-
setThrowException
public void setThrowException(boolean throwException) Should the JavaListener throw a ListenerException when it occurs or return an error message- Default value
- true
-
setHttpWsdl
public void setHttpWsdl(boolean httpWsdl) Iftrue
, the WSDL of the service provided by this listener will available for download- Default value
- false
-
getDomain
- Specified by:
getDomain
in interfaceHasPhysicalDestination
-
getConfigurationClassLoader
Description copied from interface:IScopeProvider
This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.- Specified by:
getConfigurationClassLoader
in interfaceIScopeProvider
- Returns:
- returns the ClassLoader created by the
ClassLoaderManager
.
-
getApplicationContext
public org.springframework.context.ApplicationContext getApplicationContext()- Specified by:
getApplicationContext
in interfaceIConfigurationAware
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) - Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
-
getName
- Specified by:
getName
in interfaceIConfigurationAware
- Specified by:
getName
in interfaceINamedObject
-
getServiceName
-
isSynchronous
public boolean isSynchronous() -
getReturnedSessionKeys
-
isThrowException
public boolean isThrowException() -
isHttpWsdl
public boolean isHttpWsdl() -
isOpen
public boolean isOpen() -
getHandler
-
setHandler
Description copied from interface:IPushingListener
Set the handler that will do the processing of the message. Each of the received messages must be pushed through handler.processMessage()- Specified by:
setHandler
in interfaceIPushingListener<M>
-