Class Adapter

java.lang.Object
org.springframework.core.io.DefaultResourceLoader
org.springframework.context.support.AbstractApplicationContext
org.springframework.context.support.GenericApplicationContext
org.frankframework.core.Adapter
All Implemented Interfaces:
Closeable, AutoCloseable, FrankElement, HasApplicationContext, HasName, IConfigurable, IScopeProvider, ManagableLifecycle, NameAware, ConfigurableLifecycle, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.ListableBeanFactory, org.springframework.beans.factory.NamedBean, org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.context.ApplicationContext, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationEventPublisher, org.springframework.context.ConfigurableApplicationContext, org.springframework.context.Lifecycle, org.springframework.context.MessageSource, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.core.AliasRegistry, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver

@Category(BASIC) @FrankDocGroup(OTHER) public class Adapter extends org.springframework.context.support.GenericApplicationContext implements ManagableLifecycle, FrankElement, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.NamedBean, NameAware
The Adapter is the central manager in the framework. It has knowledge of both Receivers as well as the PipeLine and statistics. The Adapter is the class that is responsible for configuring, initializing and accessing/activating Receivers, Pipelines, statistics etc.
An Adapter receives a specific type of messages and processes them. It has Receivers that receive the messages and a PipeLine that transforms the incoming messages. Each adapter is part of a Configuration.
If an adapter can receive its messages through multiple channels (e.g. RESTful HTTP requests, incoming files, etc), each channel appears as a separate Receiver nested in the adapter. Each Receiver is also responsible for dealing with the result of its received messages; the result is the output of the PipeLine. The result consists of the transformed message and a state. The Frank!Framework distinguishes between exit states SUCCESS and ERROR. There is also a state REJECTED for messages that are not accepted by the Frank!Framework and that are not processed by the PipeLine. If the exit state is ERROR, the result message may not be usable by the calling system. This can be fixed by adding an errorMessageFormatter that formats the result message if the state is ERROR.

Adapters gather statistics about the messages they process.
Adapters can process messages in parallel. They are thread-safe.
Author:
Niels Meijer
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.springframework.core.io.DefaultResourceLoader

    org.springframework.core.io.DefaultResourceLoader.ClassPathContextResource
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.logging.log4j.Logger
     
    static final String
     
    static final String
     

    Fields inherited from class org.springframework.context.support.AbstractApplicationContext

    APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME

    Fields inherited from interface org.springframework.beans.factory.BeanFactory

    FACTORY_BEAN_PREFIX

    Fields inherited from interface org.springframework.context.ConfigurableApplicationContext

    APPLICATION_STARTUP_BEAN_NAME, BOOTSTRAP_EXECUTOR_BEAN_NAME, CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SHUTDOWN_HOOK_THREAD_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME

    Fields inherited from interface org.springframework.core.io.ResourceLoader

    CLASSPATH_URL_PREFIX

    Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver

    CLASSPATH_ALL_URL_PREFIX

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    send an error to the log and to the messagekeeper of the adapter
    void
    addReceiver(Receiver<?> receiver)
    Receives incoming messages.
    void
     
    void
    Instruct the adapter to configure itself.
    void
     
    formatErrorMessage(String errorMessage, Throwable t, Message originalMessage, String messageID, HasName objectInError, long receivedTime)
     
    org.springframework.context.ApplicationContext
     
     
     
     
     
    This ClassLoader is set upon creation of the object, used to retrieve resources configured by the Ibis application.
     
    long
     
    retrieve the date and time of the last message.
     
    the MessageKeeper is for keeping the last messageKeeperSize messages available, for instance for displaying it in the webcontrol
    int
     
     
    double
    The number of messages for which processing ended unsuccessfully.
    int
     
    double
    Total of messages processed
    long[]
     
    int
     
     
    getReceiverByName(String receiverName)
     
     
    Returns the RunState of the object.
    return the date and time since active Creation date: (19-02-2003 12:16:53)
     
    org.springframework.core.task.TaskExecutor
     
    protected void
     
    boolean
    By default these beans are not started.
    boolean
    Check whether this component has successfully been configured.
    boolean
     
    boolean
     
    boolean
    Verifies if this object needs to be started or stopped.
    void
    logToMessageLogWithMessageContentsOrSize(org.apache.logging.log4j.Level level, String logMessage, String dataPrefix, Message data)
     
    processMessageDirect(String messageId, Message message, PipeLineSession pipeLineSession)
    Direct call to the Adapter PipeLine, foregoing any listeners and receivers.
    processMessageWithExceptions(String messageId, Message message, PipeLineSession pipeLineSession)
    This method does the real processing of messages by the adapter.
    protected void
    registerBeanPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
    Enables the Autowired annotation and ConfigurationAware objects.
    void
    setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
     
    void
    setAutoStart(boolean autoStart)
    AutoStart indicates that the adapter should be started when the configuration is started.
    void
     
    void
     
    void
    setDescription(String description)
    some functional description of the Adapter
    void
    Formatter for errors that can occur in this adapter.
    void
    setLastExitState(String pipeName, long lastExitStateDate, String lastExitState)
     
    void
    number of message displayed in ibisconsole
    void
    setMsgLogHidden(boolean b)
    If set to true, the length of the message is shown in the msg log instead of the content of the message
    void
    Defines behaviour for logging messages.
    void
    name of the adapter
    void
    void
    If true a null message is replaced by an empty message
    void
    setRequestReplyLogging(boolean requestReplyLogging)
    Deprecated.
    void
    setTargetDesignDocument(String targetDesignDocument)
     
    void
    setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
     
    void
    Start the adapter.
    void
    This method should ideally not be called directly.
    void
    stop(Runnable callback)
    Stop the Adapter and close all elements like receivers, Pipeline, pipes etc.
     
    void
     
    protected void
    warn(String msg)
    send a warning to the log and to the messagekeeper of the adapter

    Methods inherited from class org.springframework.context.support.GenericApplicationContext

    cancelRefresh, closeBeanFactory, getAutowireCapableBeanFactory, getBeanDefinition, getBeanFactory, getClassLoader, getDefaultListableBeanFactory, getResource, getResources, isAlias, isBeanDefinitionOverridable, isBeanNameInUse, refreshBeanFactory, refreshForAotProcessing, registerAlias, registerBean, registerBean, registerBean, registerBean, registerBean, registerBean, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences, setApplicationStartup, setClassLoader, setParent, setResourceLoader

    Methods inherited from class org.springframework.context.support.AbstractApplicationContext

    addApplicationListener, addBeanFactoryPostProcessor, assertBeanFactoryActive, clearResourceCaches, close, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroyBeans, doClose, findAllAnnotationsOnBean, findAnnotationOnBean, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationName, getApplicationStartup, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResourcePatternResolver, getStartupDate, getType, getType, initApplicationEventMulticaster, initMessageSource, initPropertySources, invokeBeanFactoryPostProcessors, isActive, isClosed, isPrototype, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, postProcessBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, publishEvent, refresh, registerListeners, registerShutdownHook, removeApplicationListener, resetCommonCaches, setDisplayName, setEnvironment, setId

    Methods inherited from class org.springframework.core.io.DefaultResourceLoader

    addProtocolResolver, getProtocolResolvers, getResourceByPath, getResourceCache

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.core.AliasRegistry

    getAliases

    Methods inherited from interface org.springframework.beans.factory.support.BeanDefinitionRegistry

    containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames

    Methods inherited from interface org.springframework.context.ConfigurableApplicationContext

    addProtocolResolver
  • Field Details

  • Constructor Details

    • Adapter

      public Adapter()
  • Method Details

    • initLifecycleProcessor

      protected void initLifecycleProcessor()
      Overrides:
      initLifecycleProcessor in class org.springframework.context.support.AbstractApplicationContext
    • setApplicationContext

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

      public org.springframework.context.ApplicationContext getApplicationContext()
      Specified by:
      getApplicationContext in interface HasApplicationContext
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • registerBeanPostProcessors

      protected void registerBeanPostProcessors(org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
      Enables the Autowired annotation and ConfigurationAware objects.
      Overrides:
      registerBeanPostProcessors in class org.springframework.context.support.AbstractApplicationContext
    • configure

      public void configure() throws ConfigurationException
      Instruct the adapter to configure itself. The adapter will call the pipeline to configure itself, the pipeline will call the individual pipes to configure themselves.
      Specified by:
      configure in interface IConfigurable
      Throws:
      ConfigurationException - in case it was not able to configure the component.
      See Also:
    • configureReceiver

      public void configureReceiver(Receiver<?> receiver) throws ConfigurationException
      Throws:
      ConfigurationException
    • warn

      protected void warn(String msg)
      send a warning to the log and to the messagekeeper of the adapter
    • addErrorMessageToMessageKeeper

      protected void addErrorMessageToMessageKeeper(String msg, Throwable t)
      send an error to the log and to the messagekeeper of the adapter
    • setLastExitState

      public void setLastExitState(String pipeName, long lastExitStateDate, String lastExitState)
    • getLastExitIsTimeoutDate

      public long getLastExitIsTimeoutDate(String pipeName)
    • formatErrorMessage

      public Message formatErrorMessage(String errorMessage, Throwable t, Message originalMessage, String messageID, HasName objectInError, long receivedTime)
    • getLastMessageDateDate

      public Date getLastMessageDateDate()
      retrieve the date and time of the last message.
    • getMessageKeeper

      public MessageKeeper getMessageKeeper()
      the MessageKeeper is for keeping the last messageKeeperSize messages available, for instance for displaying it in the webcontrol
      See Also:
    • getNumOfMessagesInError

      public double getNumOfMessagesInError()
      The number of messages for which processing ended unsuccessfully.
    • getNumOfMessagesInProcess

      public int getNumOfMessagesInProcess()
    • getNumOfMessagesStartProcessingByHour

      public long[] getNumOfMessagesStartProcessingByHour()
    • getNumOfMessagesProcessed

      public double getNumOfMessagesProcessed()
      Total of messages processed
      Returns:
      long total messages processed
    • getReceiverByName

      public Receiver<?> getReceiverByName(String receiverName)
    • getReceivers

      public Iterable<Receiver<?>> getReceivers()
    • getRunState

      public RunState getRunState()
      Description copied from interface: ManagableLifecycle
      Returns the RunState of the object.
      Specified by:
      getRunState in interface ManagableLifecycle
    • getStatsUpSinceDate

      public Date getStatsUpSinceDate()
      return the date and time since active Creation date: (19-02-2003 12:16:53)
      Returns:
      String Date
    • logToMessageLogWithMessageContentsOrSize

      public void logToMessageLogWithMessageContentsOrSize(org.apache.logging.log4j.Level level, String logMessage, String dataPrefix, Message data)
    • processMessageDirect

      public PipeLineResult processMessageDirect(String messageId, Message message, PipeLineSession pipeLineSession)
      Direct call to the Adapter PipeLine, foregoing any listeners and receivers. This method does an amount of setup which is otherwise done by the Receiver.
      This method does not throw any exceptions, and will always return a PipeLineResult. If an error occurred, the error information is in the PipeLineResult.
      Parameters:
      messageId - ID of the message
      message - Message to be processed
      pipeLineSession - PipeLineSession session in which message is to be processed
      Returns:
      The PipeLineResult from processing the message, or indicating what error occurred.
    • processMessageWithExceptions

      public PipeLineResult processMessageWithExceptions(String messageId, Message message, PipeLineSession pipeLineSession) throws ListenerException
      This method does the real processing of messages by the adapter. This method is to be called either from the Receiver, or from processMessageDirect(String, Message, PipeLineSession).
      NB: This method expects most setup to already have been done by the caller! LoggingContext and masking of sensitive information is among things that should be set up by the caller.
      This method will return a PipeLineResult with results of the processing. This might indicate an error if the message could not be processed successfully. If there was an exception from the PipeLine, a ListenerException might be thrown.
      Parameters:
      messageId - ID of the message
      message - Message to be processed
      pipeLineSession - PipeLineSession in which the message is to be processed
      Returns:
      PipeLineResult with result from processing the message in the PipeLine.
      Throws:
      ListenerException - If there was an exception, throws a ListenerException.
    • addReceiver

      public void addReceiver(Receiver<?> receiver)
      Receives incoming messages. If an adapter can receive messages through multiple channels, then add a receiver for each channel.
    • setErrorMessageFormatter

      public void setErrorMessageFormatter(IErrorMessageFormatter errorMessageFormatter)
      Formatter for errors that can occur in this adapter.
    • setPipeLine

      public void setPipeLine(PipeLine pipeline)
    • getPipeLine

      public PipeLine getPipeLine()
    • setConfiguration

      public void setConfiguration(Configuration configuration)
    • start

      public void start()
      Start the adapter. The thread-name will be set to the adapter's name. The run method, called by t.start(), will call the startRunning method of the IReceiver. The Adapter will be a new thread, as this interface extends the Runnable interface. The actual starting is done in the run method.
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Overrides:
      start in class org.springframework.context.support.AbstractApplicationContext
      See Also:
      • Receiver#startRunning()
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface ConfigurableLifecycle
      Specified by:
      getPhase in interface org.springframework.context.Phased
      Specified by:
      getPhase in interface org.springframework.context.SmartLifecycle
    • isRunning

      public boolean isRunning()
      Description copied from interface: ManagableLifecycle
      Verifies if this object needs to be started or stopped.
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
      Specified by:
      isRunning in interface ManagableLifecycle
      Overrides:
      isRunning in class org.springframework.context.support.AbstractApplicationContext
    • stop

      public void stop(@Nonnull Runnable callback)
      Stop the Adapter and close all elements like receivers, Pipeline, pipes etc. The adapter will call the IReceiver to stopListening

      Also the PipeLine.stop() method will be called, closing all registered pipes.

      Specified by:
      stop in interface org.springframework.context.SmartLifecycle
      See Also:
    • stop

      public void stop()
      This method should ideally not be called directly. Since this is a SmartLifecycle the stop(Runnable) must be called instead. Delegates to stop(Runnable) which calls `super.stop()`.
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Overrides:
      stop in class org.springframework.context.support.AbstractApplicationContext
    • toString

      public String toString()
      Overrides:
      toString in class org.springframework.context.support.AbstractApplicationContext
    • waitForNoMessagesInProcess

      public void waitForNoMessagesInProcess() throws InterruptedException
      Throws:
      InterruptedException
    • getBeanName

      public String getBeanName()
      Specified by:
      getBeanName in interface org.springframework.beans.factory.NamedBean
    • setName

      public void setName(String name)
      name of the adapter
      Specified by:
      setName in interface NameAware
    • getName

      public String getName()
      Specified by:
      getName in interface HasName
    • setDescription

      public void setDescription(String description)
      some functional description of the Adapter
    • setAutoStart

      public void setAutoStart(boolean autoStart)
      AutoStart indicates that the adapter should be started when the configuration is started.
      Default value
      true
    • isAutoStartup

      public boolean isAutoStartup()
      Description copied from interface: ConfigurableLifecycle
      By default these beans are not started. The Configuration may do so in the Configuration.configure() method.
      Specified by:
      isAutoStartup in interface ConfigurableLifecycle
      Specified by:
      isAutoStartup in interface org.springframework.context.SmartLifecycle
    • setReplaceNullMessage

      public void setReplaceNullMessage(boolean b)
      If true a null message is replaced by an empty message
      Default value
      false
    • setMessageKeeperSize

      public void setMessageKeeperSize(int size)
      number of message displayed in ibisconsole
      Default value
      10
    • setMsgLogLevel

      public void setMsgLogLevel(org.frankframework.core.Adapter.MessageLogLevel level)
      Defines behaviour for logging messages. Configuration is done in the MSG appender in log4j4ibis.properties.
      Default value
      INFO, unless overridden by property msg.log.level.default
    • setRequestReplyLogging

      @Deprecated public void setRequestReplyLogging(boolean requestReplyLogging)
      Deprecated.
    • setMsgLogHidden

      public void setMsgLogHidden(boolean b)
      If set to true, the length of the message is shown in the msg log instead of the content of the message
      Default value
      false
    • 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 HasApplicationContext
      Specified by:
      getConfigurationClassLoader in interface IScopeProvider
      Returns:
      returns the ClassLoader created by the ClassLoaderManager.
    • getDescription

      public String getDescription()
    • isReplaceNullMessage

      public boolean isReplaceNullMessage()
    • getMessageKeeperSize

      public int getMessageKeeperSize()
    • isMsgLogHidden

      public boolean isMsgLogHidden()
    • setTargetDesignDocument

      public void setTargetDesignDocument(String targetDesignDocument)
    • getTargetDesignDocument

      public String getTargetDesignDocument()
    • getConfiguration

      public Configuration getConfiguration()
    • getLastMessageProcessingState

      public String getLastMessageProcessingState()
    • setConfigurationMetrics

      public void setConfigurationMetrics(MetricsInitializer configurationMetrics)
    • isConfigured

      public boolean isConfigured()
      Description copied from interface: ManagableLifecycle
      Check whether this component has successfully been configured. Similar to ManagableLifecycle.isRunning(), verifies if this object may be started.
      Specified by:
      isConfigured in interface ManagableLifecycle
    • getTaskExecutor

      public org.springframework.core.task.TaskExecutor getTaskExecutor()
    • setTaskExecutor

      public void setTaskExecutor(org.springframework.core.task.TaskExecutor taskExecutor)
    • getComposedHideRegex

      public String getComposedHideRegex()
    • getComposedHideRegexPattern

      public Pattern getComposedHideRegexPattern()