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 IbisJavaSender (external call) or IbisLocalSender (internal call). For more information see the ibis-servicedispatcher project.
Author:
Gerrit van Brakel
  • Field Details

    • log

      protected org.apache.logging.log4j.Logger log
  • Constructor Details

    • JavaListener

      public JavaListener()
  • Method Details

    • configure

      public void configure() throws ConfigurationException
      Description copied from interface: IListener
      configure() is called once at startup of the framework in the configure() method of the owner of this listener. Purpose of this method is to reduce creating connections to databases etc. in the IPullingListener.getRawMessage(Map) method. As much as possible class-instantiating should take place in the configure() or IListener.start() method, to improve performance.
      Specified by:
      configure in interface IConfigurable
      Specified by:
      configure in interface IListener<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.
      Specified by:
      start in interface IListener<M>
    • stop

      public void stop()
      Description copied from interface: IListener
      Close all resources used for listening. Called once each time the listener is stopped.
      Specified by:
      stop in interface IListener<M>
    • wrapRawMessage

      public RawMessageWrapper<M> wrapRawMessage(M rawMessage, PipeLineSession session)
      Description copied from interface: IPushingListener
      Wrap a raw message in a MessageWrapper. Populate PipeLineSession with properties from the message.
      Specified by:
      wrapRawMessage in interface IPushingListener<M>
      Parameters:
      rawMessage - The raw message data, unwrapped
      session - 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 interface nl.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 a IListener implementation.
      TODO: We may want to add the correlationId parameter back to this method, for cleaner calling and cleaner implementation.
      Specified by:
      processRequest in interface ServiceClient
      Parameters:
      message - Message to process
      session - 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

      public static JavaListener<?> getListener(String name)
      Returns JavaListener registered under the given name
    • getListenerNames

      public static Set<String> getListenerNames()
    • setExceptionListener

      public void setExceptionListener(IbisExceptionListener listener)
      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 interface IPushingListener<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 interface IListener<M>
      Throws:
      ListenerException
    • extractMessage

      public Message extractMessage(@Nonnull RawMessageWrapper<M> rawMessage, @Nonnull Map<String,Object> context) throws ListenerException
      Description copied from interface: IListener
      Extracts data from message obtained from IPullingListener.getRawMessage(Map) or IPushingListener.wrapRawMessage(Object, PipeLineSession). May also extract other parameters from the message and put those into the context.
      Specified by:
      extractMessage in interface IListener<M>
      Parameters:
      rawMessage - The RawMessageWrapper from which to extract the Message.
      context - Context to populate. Either a PipeLineSession or a Map threadContext depending on caller.
      Returns:
      input Message for adapter.
      Throws:
      ListenerException
    • getPhysicalDestinationName

      public String getPhysicalDestinationName()
      Specified by:
      getPhysicalDestinationName in interface HasPhysicalDestination
    • setName

      @Mandatory public void setName(String name)
      Internal name of the listener, as known to the adapter. An IbisLocalSender refers to this name in its javaListener-attribute.
      Specified by:
      setName in interface INamedObject
    • setServiceName

      public void setServiceName(String jndiName)
      External Name of the listener. An IbisJavaSender refers to this name in its serviceName-attribute.
    • setLocal

      @Deprecated(forRemoval=true, since="7.7.0") public void setLocal(String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setIsolated

      @Deprecated(forRemoval=true, since="7.7.0") public void setIsolated(boolean b)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setSynchronous

      @Deprecated(forRemoval=true, since="7.7.0") public void setSynchronous(boolean b)
      Deprecated, for removal: This API element is subject to removal in a future version.
      If set false, the request is executed asynchronously. N.B. be aware that there is no limit on the number of threads generated
      Default value
      true
    • setReturnedSessionKeys

      public 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. 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)
      If true, the WSDL of the service provided by this listener will available for download
      Default value
      false
    • getDomain

      public String getDomain()
      Specified by:
      getDomain in interface HasPhysicalDestination
    • getConfigurationClassLoader

      public ClassLoader 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 interface IScopeProvider
      Returns:
      returns the ClassLoader created by the ClassLoaderManager.
    • getApplicationContext

      public org.springframework.context.ApplicationContext getApplicationContext()
      Specified by:
      getApplicationContext in interface IConfigurationAware
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • getName

      public String getName()
      Specified by:
      getName in interface IConfigurationAware
      Specified by:
      getName in interface INamedObject
    • getServiceName

      public String getServiceName()
    • isSynchronous

      public boolean isSynchronous()
    • getReturnedSessionKeys

      public String getReturnedSessionKeys()
    • isThrowException

      public boolean isThrowException()
    • isHttpWsdl

      public boolean isHttpWsdl()
    • isOpen

      public boolean isOpen()
    • getHandler

      public IMessageHandler<M> getHandler()
    • setHandler

      public void setHandler(IMessageHandler<M> handler)
      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 interface IPushingListener<M>