public class TransformationService extends Object
Message but decoupled from Message.
TODO Redefine this interface as part of Mule 4.0 transformation improvements (MULE-9141)| Constructor and Description |
|---|
TransformationService(MuleContext muleContext) |
| Modifier and Type | Method and Description |
|---|---|
org.mule.runtime.api.message.Message |
applyTransformers(org.mule.runtime.api.message.Message message,
Event event,
List<? extends Transformer> transformers)
Applies a list of transformers returning the result of the transformation as a new message instance.
|
org.mule.runtime.api.message.Message |
applyTransformers(org.mule.runtime.api.message.Message message,
Event event,
Transformer... transformers)
Applies a list of transformers returning the result of the transformation as a new message instance.
|
String |
getPayloadForLogging(org.mule.runtime.api.message.Message message)
Obtains a
String representation of the message payload for logging without throwing exception. |
String |
getPayloadForLogging(org.mule.runtime.api.message.Message message,
Charset encoding)
Obtains a
String representation of the message payload for logging without throwing exception. |
protected Charset |
resolveEncoding(org.mule.runtime.api.message.Message message) |
org.mule.runtime.api.message.Message |
transform(org.mule.runtime.api.message.Message message,
org.mule.runtime.api.metadata.DataType outputDataType)
Attempts to obtain the payload of this message with the desired Class type.
|
Object |
transform(Object value,
org.mule.runtime.api.metadata.DataType valueDataType,
org.mule.runtime.api.metadata.DataType expectedDataType)
Given a value) it will try to transform it to the expected type defined in the {@code expectedDataType}
|
@Inject public TransformationService(MuleContext muleContext)
public Object transform(Object value, org.mule.runtime.api.metadata.DataType valueDataType, org.mule.runtime.api.metadata.DataType expectedDataType) throws MessagingException, MessageTransformerException, TransformerException
value - the value to transformvalueDataType - the value's DataTypeexpectedDataType - the expected type's DataTypeevent - the event to perform the transformationMessagingException - If could not be able to find a proper transformer do obtain the desired typeMessageTransformerException - If a problem occurs transforming the valueTransformerException - If a problem occurs transforming the valuepublic org.mule.runtime.api.message.Message applyTransformers(org.mule.runtime.api.message.Message message,
Event event,
List<? extends Transformer> transformers)
throws org.mule.runtime.api.exception.MuleException
message - event - the event being processedtransformers - the transformers to apply to the message payloadTransformerException - if a transformation error occurs or one or more of the transformers passed in a are incompatible
with the message payloadorg.mule.runtime.api.exception.MuleExceptionpublic org.mule.runtime.api.message.Message applyTransformers(org.mule.runtime.api.message.Message message,
Event event,
Transformer... transformers)
throws org.mule.runtime.api.exception.MuleException
message - event - the event being processedtransformers - the transformers to apply to the message payloadTransformerException - if a transformation error occurs or one or more of the transformers passed in a are incompatible
with the message payloadorg.mule.runtime.api.exception.MuleExceptionpublic org.mule.runtime.api.message.Message transform(org.mule.runtime.api.message.Message message,
org.mule.runtime.api.metadata.DataType outputDataType)
throws TransformerException
message - outputDataType - the desired return typeTransformerException - if a transformer cannot be found or there is an error during transformation of the payloadpublic String getPayloadForLogging(org.mule.runtime.api.message.Message message)
String representation of the message payload for logging without throwing exception.
If the existing payload is consumable (i.e. can't be read twice) then the existing payload of the message will be replaced
with a byte[] representation as part of this operations.message - protected Charset resolveEncoding(org.mule.runtime.api.message.Message message)
public String getPayloadForLogging(org.mule.runtime.api.message.Message message, Charset encoding)
String representation of the message payload for logging without throwing exception. If encoding is
required it will use the encoding set on the message.
If the existing payload is consumable (i.e. can't be read twice) or an exception occurs during transformation then the an exception won't be thrown but rather a description of the payload type will be returned.
Copyright © 2003–2017 MuleSoft, Inc.. All rights reserved.