public final class IntegrationUtils extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
FATAL_WHEN_NO_BEANFACTORY
Should be set to TRUE on CI plans and framework developer systems.
|
static String |
INTEGRATION_CONVERSION_SERVICE_BEAN_NAME |
static String |
INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME |
Modifier and Type | Method and Description |
---|---|
static String |
bytesToString(byte[] bytes,
String encoding)
Utility method for null-safe conversion from byte[] to String
|
static ConversionService |
getConversionService(BeanFactory beanFactory) |
static MessageBuilderFactory |
getMessageBuilderFactory(BeanFactory beanFactory)
Returns the context-wide `messageBuilderFactory` bean from the beanFactory,
or a
DefaultMessageBuilderFactory if not found or the beanFactory is null. |
static String |
obtainComponentName(NamedComponent component)
Obtain a component name from the provided
NamedComponent . |
static byte[] |
stringToBytes(String value,
String encoding)
Utility method for null-safe conversion from String to byte[]
|
static RuntimeException |
wrapInDeliveryExceptionIfNecessary(Message<?> message,
java.util.function.Supplier<String> text,
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 RuntimeException |
wrapInHandlingExceptionIfNecessary(Message<?> message,
java.util.function.Supplier<String> text,
Throwable ex)
If the exception is not a
MessagingException or does not have
a failedMessage , wrap it
in a new MessageHandlingException with the message. |
public static final String INTEGRATION_CONVERSION_SERVICE_BEAN_NAME
public static final String INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME
public static final boolean FATAL_WHEN_NO_BEANFACTORY
public static ConversionService getConversionService(BeanFactory beanFactory)
beanFactory
- BeanFactory for lookup, must not be null.ConversionService
bean whose name is "integrationConversionService" if available.public static MessageBuilderFactory getMessageBuilderFactory(@Nullable BeanFactory beanFactory)
DefaultMessageBuilderFactory
if not found or the beanFactory is null.beanFactory
- The bean factory.public static byte[] stringToBytes(String value, String encoding)
value
- the String to be convertedencoding
- the encodingIllegalArgumentException
- if the encoding is not supportedpublic static String bytesToString(byte[] bytes, String encoding)
bytes
- the byte[] to be convertedencoding
- the encodingIllegalArgumentException
- if the encoding is not supportedpublic static RuntimeException wrapInDeliveryExceptionIfNecessary(Message<?> message, java.util.function.Supplier<String> text, Throwable ex)
MessagingException
or does not have
a failedMessage
, wrap it
in a new MessageDeliveryException
with the message.message
- the message.text
- a Supplier for the new exception's message text.ex
- the exception.public static RuntimeException wrapInHandlingExceptionIfNecessary(Message<?> message, java.util.function.Supplier<String> text, Throwable ex)
MessagingException
or does not have
a failedMessage
, wrap it
in a new MessageHandlingException
with the message.message
- the message.text
- a Supplier for the new exception's message text.ex
- the exception.public static String obtainComponentName(NamedComponent component)
NamedComponent
.component
- the NamedComponent
source for component name.