1 10 11 package org.mule.transformers.compression; 12 13 import org.apache.commons.lang.SerializationUtils; 14 import org.mule.umo.transformer.TransformerException; 15 import org.mule.util.compression.GZipCompression; 16 17 import java.io.IOException ; 18 19 25 public class GZipUncompressTransformer extends GZipCompressTransformer 26 { 27 30 private static final long serialVersionUID = -861180612454404077L; 31 32 public GZipUncompressTransformer() 33 { 34 super(); 35 this.setStrategy(new GZipCompression()); 36 this.registerSourceType(byte[].class); 37 this.setReturnClass(byte[].class); 38 39 } 40 41 public Object doTransform(Object src, String encoding) throws TransformerException 42 { 43 byte[] buffer = null; 44 45 try 46 { 47 buffer = getStrategy().uncompressByteArray((byte[])src); 48 } 49 catch (IOException e) 50 { 51 logger.error("Failed to uncompress message:", e); 52 throw new TransformerException(this, e); 53 } 54 55 if (!getReturnClass().equals(byte[].class)) 56 { 57 return SerializationUtils.deserialize(buffer); 58 } 59 60 return buffer; 61 } 62 63 } 64 | Popular Tags |