1 10 11 package org.mule.transformers.simple; 12 13 import org.apache.commons.lang.SerializationUtils; 14 import org.mule.config.i18n.Message; 15 import org.mule.config.i18n.Messages; 16 import org.mule.transformers.AbstractTransformer; 17 import org.mule.umo.transformer.TransformerException; 18 19 import java.io.InputStream ; 20 21 25 public class ByteArrayToSerializable extends AbstractTransformer 26 { 27 30 private static final long serialVersionUID = 5305641786345530597L; 31 32 public ByteArrayToSerializable() 33 { 34 registerSourceType(byte[].class); 35 registerSourceType(InputStream .class); 36 } 37 38 public Object doTransform(Object src, String encoding) throws TransformerException 39 { 40 try 41 { 42 if (src instanceof byte[]) 43 { 44 return SerializationUtils.deserialize((byte[])src); 45 } 46 else 47 { 48 return SerializationUtils.deserialize((InputStream )src); 49 50 } 51 } 52 catch (Exception e) 53 { 54 throw new TransformerException(new Message(Messages.TRANSFORM_FAILED_FROM_X_TO_X, "byte[]", 55 "Object"), this, e); 56 } 57 } 58 59 } 60 | Popular Tags |