Show Table of Contents
11.3. Implement a Mime Decoder
Procedure 11.1. Task
- Create a class that activates the
org.jboss.soa.esb.listeners.message.mime.MimeDecoderinterface. - Add the @MimeType annotation to the class, specifying the mime type as the annotation value.
- Define the newly created class in the
META-INF/org/jboss/soa/esb/listeners/message/mime/decoders.lstfile:@MimeType("text/plain") public class TextPlainMimeDecoder implements MimeDecoder, Configurable { private Charset encodingCharset; public void setConfiguration(ConfigTree configTree) throws ConfigurationException { AssertArgument.isNotNull(configTree, "configTree"); String encoding = configTree.getAttribute("encoding", "UTF-8"); encodingCharset = Charset.forName(encoding); } public Object decode(byte[] bytes) throws MimeDecodeException { try { return new String(bytes, encodingCharset.name()); } catch (UnsupportedEncodingException e) { throw new MimeDecodeException("Unexpected character encoding error.", e); } } }Note
This file needs to be present on the classpath at runtime. If your module doesn't have this file, add it to your module source/resources and it will be located at runtime. - Optionally, if the MimeDecoder implementation needs access to the listener configuration (for additional configuration information), have the class implement the
org.jboss.soa.esb.Configurableinterface.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.