View Javadoc

1   /*
2    * $Id: MuleMessageToByteArray.java 10776 2008-02-11 18:15:42Z rossmason $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  package org.mule.transformer.simple;
11  
12  import org.mule.api.MuleMessage;
13  import org.mule.api.transformer.TransformerException;
14  import org.mule.transformer.AbstractMessageAwareTransformer;
15  
16  import org.apache.commons.lang.SerializationUtils;
17  
18  /** TODO */
19  public class MuleMessageToByteArray extends AbstractMessageAwareTransformer
20  {
21      public MuleMessageToByteArray()
22      {
23          registerSourceType(MuleMessage.class);
24          setReturnClass(byte[].class);
25      }
26  
27      public Object transform(MuleMessage message, String outputEncoding) throws TransformerException
28      {
29          return SerializationUtils.serialize(message);
30      }
31  }