Class IntegrationObjectSupport

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, ExpressionCapable, NamedComponent
Direct Known Subclasses:
AbstractEndpoint, AbstractHandleMessageAdvice, AbstractMessageChannel, AbstractRequestHandlerAdvice, AbstractTransformer, CodecMessageConverter, DefaultHeaderChannelRegistry, ExpressionEvaluatingTransactionSynchronizationProcessor, HeaderEnricher, HeaderFilter, MessageHandlerSupport

public abstract class IntegrationObjectSupport
extends java.lang.Object
implements org.springframework.beans.factory.BeanNameAware, NamedComponent, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.InitializingBean, ExpressionCapable
A base class that provides convenient access to the bean factory as well as TaskScheduler and ConversionService instances.

This is intended to be used as a base class for internal framework components whereas code built upon the integration framework should not require tight coupling with the context but rather rely on standard dependency injection.

  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected static org.springframework.expression.ExpressionParser EXPRESSION_PARSER  
    protected org.springframework.core.log.LogAccessor logger  
  • Constructor Summary

    Constructors 
    Constructor Description
    IntegrationObjectSupport()  
  • Method Summary

    Modifier and Type Method Description
    void afterPropertiesSet()  
    static <T> T extractTypeIfPossible​(java.lang.Object targetObject, java.lang.Class<T> expectedType)  
    static java.util.UUID generateId()  
    protected org.springframework.context.ApplicationContext getApplicationContext()  
    java.lang.String getApplicationContextId()
    Returns the ApplicationContext.getId() if the ApplicationContext is available.
    java.lang.String getBeanDescription()  
    protected org.springframework.beans.factory.BeanFactory getBeanFactory()  
    java.lang.String getBeanName()  
    protected org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel> getChannelResolver()  
    java.lang.String getComponentName()
    Will return the name of this component identified by componentName field.
    java.lang.String getComponentType()
    Subclasses may implement this method to provide component type information.
    org.springframework.core.convert.ConversionService getConversionService()  
    org.springframework.expression.Expression getExpression()
    Return the primary SpEL expression if this component is expression-based.
    protected java.util.Properties getIntegrationProperties()
    Deprecated.
    since version 5.5 in favor of getIntegrationProperty(String, Class); will be replaced with IntegrationProperties variant in the next major version.
    protected <T> T getIntegrationProperty​(java.lang.String key, java.lang.Class<T> tClass)  
    protected MessageBuilderFactory getMessageBuilderFactory()  
    protected org.springframework.scheduling.TaskScheduler getTaskScheduler()  
    protected boolean isInitialized()
    Return the status of this component if it has been initialized already.
    protected void onInit()
    Subclasses may implement this for initialization logic.
    void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)  
    void setBeanFactory​(org.springframework.beans.factory.BeanFactory beanFactory)  
    void setBeanName​(java.lang.String beanName)  
    void setChannelResolver​(org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel> channelResolver)
    Specify the DestinationResolver strategy to use.
    void setComponentName​(java.lang.String componentName)
    Sets the name of this component.
    protected void setConversionService​(org.springframework.core.convert.ConversionService conversionService)  
    void setMessageBuilderFactory​(MessageBuilderFactory messageBuilderFactory)  
    void setPrimaryExpression​(org.springframework.expression.Expression expression)
    For expression-based components, set the primary expression.
    void setTaskScheduler​(org.springframework.scheduling.TaskScheduler taskScheduler)
    Configure a TaskScheduler for those components which logic relies on the scheduled tasks.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • EXPRESSION_PARSER

      protected static final org.springframework.expression.ExpressionParser EXPRESSION_PARSER
    • logger

      protected final org.springframework.core.log.LogAccessor logger
  • Constructor Details

  • Method Details

    • setBeanName

      public final void setBeanName​(java.lang.String beanName)
      Specified by:
      setBeanName in interface org.springframework.beans.factory.BeanNameAware
    • getBeanName

      public java.lang.String getBeanName()
      Specified by:
      getBeanName in interface NamedComponent
    • getComponentName

      public java.lang.String getComponentName()
      Will return the name of this component identified by componentName field. If componentName was not set this method will default to the 'beanName' of this component;
      Specified by:
      getComponentName in interface NamedComponent
    • setComponentName

      public void setComponentName​(java.lang.String componentName)
      Sets the name of this component.
      Parameters:
      componentName - The component name.
    • getComponentType

      public java.lang.String getComponentType()
      Subclasses may implement this method to provide component type information.
      Specified by:
      getComponentType in interface NamedComponent
    • getBeanDescription

      public java.lang.String getBeanDescription()
    • setBeanFactory

      public void setBeanFactory​(org.springframework.beans.factory.BeanFactory beanFactory)
      Specified by:
      setBeanFactory in interface org.springframework.beans.factory.BeanFactoryAware
    • setApplicationContext

      public void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • setChannelResolver

      public void setChannelResolver​(org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel> channelResolver)
      Specify the DestinationResolver strategy to use. The default is a BeanFactoryChannelResolver.
      Parameters:
      channelResolver - The channel resolver.
    • getExpression

      public org.springframework.expression.Expression getExpression()
      Description copied from interface: ExpressionCapable
      Return the primary SpEL expression if this component is expression-based.
      Specified by:
      getExpression in interface ExpressionCapable
      Returns:
      the expression as a String.
    • setPrimaryExpression

      public final void setPrimaryExpression​(org.springframework.expression.Expression expression)
      For expression-based components, set the primary expression.
      Parameters:
      expression - the expression.
      Since:
      4.3
    • afterPropertiesSet

      public final void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • onInit

      protected void onInit()
      Subclasses may implement this for initialization logic.
    • isInitialized

      protected boolean isInitialized()
      Return the status of this component if it has been initialized already.
      Returns:
      the flag if this component has been initialized already.
    • getBeanFactory

      protected org.springframework.beans.factory.BeanFactory getBeanFactory()
    • setTaskScheduler

      public void setTaskScheduler​(org.springframework.scheduling.TaskScheduler taskScheduler)
      Configure a TaskScheduler for those components which logic relies on the scheduled tasks. If not provided, falls back to the global taskScheduler bean in the application context, provided by the Spring Integration infrastructure.
      Parameters:
      taskScheduler - the TaskScheduler to use.
      Since:
      5.1.3
      See Also:
      getTaskScheduler()
    • getTaskScheduler

      protected org.springframework.scheduling.TaskScheduler getTaskScheduler()
    • getChannelResolver

      protected org.springframework.messaging.core.DestinationResolver<org.springframework.messaging.MessageChannel> getChannelResolver()
    • getConversionService

      public org.springframework.core.convert.ConversionService getConversionService()
    • setConversionService

      protected void setConversionService​(org.springframework.core.convert.ConversionService conversionService)
    • getApplicationContextId

      public java.lang.String getApplicationContextId()
      Returns the ApplicationContext.getId() if the ApplicationContext is available.
      Returns:
      The id, or null if there is no application context.
    • getApplicationContext

      protected org.springframework.context.ApplicationContext getApplicationContext()
      Returns:
      the applicationContext
    • getIntegrationProperties

      @Deprecated protected java.util.Properties getIntegrationProperties()
      Deprecated.
      since version 5.5 in favor of getIntegrationProperty(String, Class); will be replaced with IntegrationProperties variant in the next major version.
      Returns:
      The global integration properties.
      See Also:
      IntegrationContextUtils.getIntegrationProperties(BeanFactory)
    • getMessageBuilderFactory

      protected MessageBuilderFactory getMessageBuilderFactory()
    • setMessageBuilderFactory

      public void setMessageBuilderFactory​(MessageBuilderFactory messageBuilderFactory)
    • getIntegrationProperty

      protected <T> T getIntegrationProperty​(java.lang.String key, java.lang.Class<T> tClass)
      Type Parameters:
      T - The expected type of the property.
      Parameters:
      key - Integration property.
      tClass - the class to convert a value of Integration property.
      Returns:
      the value of the Integration property converted to the provide type.
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • extractTypeIfPossible

      @Nullable public static <T> T extractTypeIfPossible​(@Nullable java.lang.Object targetObject, java.lang.Class<T> expectedType)
    • generateId

      public static java.util.UUID generateId()