Class JavaListener<M>
- All Implemented Interfaces:
nl.nn.adapterframework.dispatcher.RequestProcessor,FrankElement,HasApplicationContext,HasName,HasPhysicalDestination,IConfigurable,IListener<M>,IPushingListener<M>,IScopeProvider,NameAware,RequestReplyListener,ServiceClient,org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware
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).
Calling the JavaListener via the IbisJavaSender forces all request messages to be passed as strings without
metadata.
When calling the JavaListener via the IbisLocalSender all messages are passed in their native format,
retaining all their metadata.
- Author:
- Gerrit van Brakel
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.frankframework.core.RequestReplyListener
RequestReplyListener.ExceptionHandlingMethod -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterMessageProcessed(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.voidConfigure this component.extractMessage(RawMessageWrapper<M> rawMessage, Map<String, Object> context) Extracts data from message obtained fromIPullingListener.getRawMessage(Map)orIPushingListener.wrapRawMessage(Object, PipeLineSession).static JavaListener<?> getListener(String name) Returns JavaListener registered under the given nameprocessRequest(String correlationId, String rawMessage, HashMap context) processRequest(Message message, PipeLineSession session) Method to implement for processing a request.voidsetExceptionListener(IbisExceptionListener listener) Set a (single) listener that will be notified of any exceptions.voidsetHttpWsdl(boolean httpWsdl) Iftrue, the WSDL of the service provided by this listener will available for downloadvoidInternal name of the listener, as known to the adapter.voidsetReturnedSessionKeys(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.voidsetServiceName(String jndiName) External Name of the listener.voidsetThrowException(boolean throwException) Deprecated.voidstart()Prepares the listener for receiving messages.voidstop()Close all resources used for listening.wrapRawMessage(M rawMessage, PipeLineSession session) Wrap a raw message in a MessageWrapper.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContextMethods inherited from interface org.frankframework.core.FrankElement
addConfigWarningMethods inherited from interface org.frankframework.core.HasApplicationContext
getApplicationContext, getConfigurationClassLoaderMethods inherited from interface org.frankframework.core.IPushingListener
setHandlerMethods inherited from interface org.frankframework.core.RequestReplyListener
getOnException, setOnException
-
Constructor Details
-
JavaListener
public JavaListener()
-
-
Method Details
-
configure
Description copied from interface:IConfigurableConfigure this component.configure()is called once at startup of the framework in the configure method of the owner of thisIConfigurable. Purpose of this method is to check whether the static configuration of the object is correct. As much as possible class-instantiating should take place in theconfigure(), to improve performance.In the case of a container, this will propagate the configure signal to all components that apply.
- Specified by:
configurein interfaceIConfigurable- Throws:
ConfigurationException- in case it was not able to configure the component.
-
start
public void start()Description copied from interface:IListenerPrepares the listener for receiving messages.start()is called once each time the listener is started. -
stop
public void stop()Description copied from interface:IListenerClose all resources used for listening. Called once each time the listener is stopped. -
wrapRawMessage
Description copied from interface:IPushingListenerWrap a raw message in a MessageWrapper. PopulatePipeLineSessionwith properties from the message.- Specified by:
wrapRawMessagein interfaceIPushingListener<M>- Parameters:
rawMessage- The raw message data, unwrappedsession-PipeLineSessionto populate with properties from the message.- Returns:
- Wrapped raw message
-
processRequest
public String processRequest(String correlationId, String rawMessage, HashMap context) throws ListenerException - Specified by:
processRequestin interfacenl.nn.adapterframework.dispatcher.RequestProcessor- Throws:
ListenerException
-
processRequest
public Message processRequest(Message message, @Nonnull PipeLineSession session) throws ListenerException Description copied from interface:ServiceClientMethod to implement for processing a request. This will usually delegate to aIListenerimplementation.
TODO: We may want to add the correlationId parameter back to this method, for cleaner calling and cleaner implementation.- Specified by:
processRequestin interfaceServiceClient- Parameters:
message-Messageto processsession-PipeLineSessionof 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:IPushingListenerSet 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:
setExceptionListenerin interfaceIPushingListener<M>
-
afterMessageProcessed
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<M> rawMessage, PipeLineSession pipeLineSession) throws ListenerException Description copied from interface:IListenerCalled to perform actions (like committing or sending a reply) after a message has been processed by the Pipeline.- Specified by:
afterMessageProcessedin interfaceIListener<M>- Throws:
ListenerException
-
extractMessage
public Message extractMessage(@Nonnull RawMessageWrapper<M> rawMessage, @Nonnull Map<String, Object> context) throws ListenerExceptionDescription copied from interface:IListenerExtracts 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:
extractMessagein interfaceIListener<M>- Parameters:
rawMessage- TheRawMessageWrapperfrom which to extract theMessage.context- Context to populate. Either aPipeLineSessionor aMapthreadContext depending on caller.- Returns:
- input
Messagefor adapter. - Throws:
ListenerException
-
getPhysicalDestinationName
- Specified by:
getPhysicalDestinationNamein interfaceHasPhysicalDestination
-
setName
Internal name of the listener, as known to the adapter. An IbisLocalSender refers to this name in itsjavaListener-attribute. -
setServiceName
External Name of the listener. An IbisJavaSender refers to this name in itsserviceName-attribute. -
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
@Deprecated(since="9.2") @ConfigurationWarning("Replaced with attribute \'onException\', true = \'RETHROW\' and false \'FORMAT_AND_RETURN\'") public void setThrowException(boolean throwException) Deprecated.Should the JavaListener throw a ListenerException when it occurs or return an error message. Please consider using anErrorMessageFormatterinstead of disabling Exception from being thrown.- 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
-