1 10 11 package org.mule.providers.stream; 12 13 import org.mule.providers.AbstractMessageAdapter; 14 import org.mule.umo.provider.MessageTypeNotSupportedException; 15 16 19 public class StreamMessageAdapter extends AbstractMessageAdapter 20 { 21 24 private static final long serialVersionUID = 3094357859680956607L; 25 26 private final String message; 28 29 public StreamMessageAdapter(Object message) throws MessageTypeNotSupportedException 30 { 31 if (message instanceof String ) 32 { 33 this.message = (String )message; 34 } 35 else 36 { 37 throw new MessageTypeNotSupportedException(message, StreamMessageAdapter.class); 38 } 39 } 40 41 49 public String getPayloadAsString(String encoding) throws Exception 50 { 51 return message.toString(); 52 } 53 54 60 public byte[] getPayloadAsBytes() throws Exception 61 { 62 String msg = getPayloadAsString(); 63 return msg.getBytes(); 64 } 65 66 69 public Object getPayload() 70 { 71 return message; 72 } 73 74 } 75 | Popular Tags |