Class IntegrationUtils

java.lang.Object
org.springframework.integration.support.utils.IntegrationUtils

public final class IntegrationUtils
extends java.lang.Object
General utility methods.
Since:
4.0
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static boolean FATAL_WHEN_NO_BEANFACTORY
    Should be set to TRUE on CI plans and framework developer systems.
    static java.lang.String INTEGRATION_CONVERSION_SERVICE_BEAN_NAME  
    static java.lang.String INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String bytesToString​(byte[] bytes, java.lang.String encoding)
    Utility method for null-safe conversion from byte[] to String
    static org.springframework.core.convert.ConversionService getConversionService​(org.springframework.beans.factory.BeanFactory beanFactory)  
    static MessageBuilderFactory getMessageBuilderFactory​(org.springframework.beans.factory.BeanFactory beanFactory)
    Returns the context-wide `messageBuilderFactory` bean from the beanFactory, or a DefaultMessageBuilderFactory if not found or the beanFactory is null.
    static java.lang.String obtainComponentName​(NamedComponent component)
    Obtain a component name from the provided NamedComponent.
    static byte[] stringToBytes​(java.lang.String value, java.lang.String encoding)
    Utility method for null-safe conversion from String to byte[]
    static java.lang.RuntimeException wrapInDeliveryExceptionIfNecessary​(org.springframework.messaging.Message<?> message, java.util.function.Supplier<java.lang.String> text, java.lang.Throwable ex)
    If the exception is not a MessagingException or does not have a failedMessage, wrap it in a new MessageDeliveryException with the message.
    static java.lang.RuntimeException wrapInHandlingExceptionIfNecessary​(org.springframework.messaging.Message<?> message, java.util.function.Supplier<java.lang.String> text, java.lang.Throwable ex)
    If the exception is not a MessagingException or does not have a failedMessage, wrap it in a new MessageHandlingException with the message.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • getConversionService

      public static org.springframework.core.convert.ConversionService getConversionService​(org.springframework.beans.factory.BeanFactory beanFactory)
      Parameters:
      beanFactory - BeanFactory for lookup, must not be null.
      Returns:
      The ConversionService bean whose name is "integrationConversionService" if available.
    • getMessageBuilderFactory

      public static MessageBuilderFactory getMessageBuilderFactory​(@Nullable org.springframework.beans.factory.BeanFactory beanFactory)
      Returns the context-wide `messageBuilderFactory` bean from the beanFactory, or a DefaultMessageBuilderFactory if not found or the beanFactory is null.
      Parameters:
      beanFactory - The bean factory.
      Returns:
      The message builder factory.
    • stringToBytes

      public static byte[] stringToBytes​(java.lang.String value, java.lang.String encoding)
      Utility method for null-safe conversion from String to byte[]
      Parameters:
      value - the String to be converted
      encoding - the encoding
      Returns:
      the byte[] corresponding to the given String and encoding, null if provided String argument was null
      Throws:
      java.lang.IllegalArgumentException - if the encoding is not supported
    • bytesToString

      public static java.lang.String bytesToString​(byte[] bytes, java.lang.String encoding)
      Utility method for null-safe conversion from byte[] to String
      Parameters:
      bytes - the byte[] to be converted
      encoding - the encoding
      Returns:
      the String corresponding to the given byte[] and encoding, null if provided byte[] argument was null
      Throws:
      java.lang.IllegalArgumentException - if the encoding is not supported
    • wrapInDeliveryExceptionIfNecessary

      public static java.lang.RuntimeException wrapInDeliveryExceptionIfNecessary​(org.springframework.messaging.Message<?> message, java.util.function.Supplier<java.lang.String> text, java.lang.Throwable ex)
      If the exception is not a MessagingException or does not have a failedMessage, wrap it in a new MessageDeliveryException with the message.
      Parameters:
      message - the message.
      text - a Supplier for the new exception's message text.
      ex - the exception.
      Returns:
      the wrapper, if necessary, or the original exception.
      Since:
      5.0.4
    • wrapInHandlingExceptionIfNecessary

      public static java.lang.RuntimeException wrapInHandlingExceptionIfNecessary​(org.springframework.messaging.Message<?> message, java.util.function.Supplier<java.lang.String> text, java.lang.Throwable ex)
      If the exception is not a MessagingException or does not have a failedMessage, wrap it in a new MessageHandlingException with the message.
      Parameters:
      message - the message.
      text - a Supplier for the new exception's message text.
      ex - the exception.
      Returns:
      the wrapper, if necessary, or the original exception.
      Since:
      5.0.4
    • obtainComponentName

      public static java.lang.String obtainComponentName​(NamedComponent component)
      Obtain a component name from the provided NamedComponent.
      Parameters:
      component - the NamedComponent source for component name.
      Returns:
      the component name
      Since:
      5.3