1 10 11 package org.mule.providers.tcp; 12 13 import org.mule.providers.AbstractMessageAdapter; 14 import org.mule.umo.MessagingException; 15 import org.mule.umo.provider.MessageTypeNotSupportedException; 16 17 23 24 public class TcpMessageAdapter extends AbstractMessageAdapter 25 { 26 29 private static final long serialVersionUID = 7229837140160407794L; 30 31 private byte[] message; 32 33 public TcpMessageAdapter(Object message) throws MessagingException 34 { 35 if (message instanceof byte[]) 36 { 37 this.message = (byte[])message; 38 } 39 else 40 { 41 throw new MessageTypeNotSupportedException(message, getClass()); 42 } 43 } 44 45 53 public String getPayloadAsString(String encoding) throws Exception 54 { 55 return new String (message, encoding); 56 } 57 58 public byte[] getPayloadAsBytes() throws Exception 59 { 60 return message; 61 } 62 63 public Object getPayload() 64 { 65 return message; 66 } 67 } 68 | Popular Tags |