1 10 11 package org.mule.providers.streaming; 12 13 import org.mule.providers.AbstractMessageAdapter; 14 import org.mule.providers.NullPayload; 15 import org.mule.umo.UMOEvent; 16 import org.mule.umo.provider.OutputHandler; 17 import org.mule.umo.provider.UMOStreamMessageAdapter; 18 19 import java.io.IOException ; 20 import java.io.InputStream ; 21 import java.io.OutputStream ; 22 23 31 public class StreamMessageAdapter extends AbstractMessageAdapter implements UMOStreamMessageAdapter 32 { 33 36 private static final long serialVersionUID = 6794965828515586752L; 37 38 protected InputStream in; 39 protected InputStream response; 40 protected OutputStream out; 41 protected OutputHandler handler; 42 private NullPayload nullPayload = new NullPayload(); 43 44 public StreamMessageAdapter(InputStream in) 45 { 46 this.in = in; 47 } 48 49 public StreamMessageAdapter(InputStream in, OutputStream out) 50 { 51 this.in = in; 52 this.out = out; 53 } 54 55 public StreamMessageAdapter(OutputHandler handler) 56 { 57 this.handler = handler; 58 } 59 60 public StreamMessageAdapter(OutputStream out, OutputHandler handler) 61 { 62 this.out = out; 63 this.handler = handler; 64 } 65 66 public StreamMessageAdapter(InputStream in, OutputStream out, OutputHandler handler) 67 { 68 this.in = in; 69 this.out = out; 70 this.handler = handler; 71 } 72 73 81 public String getPayloadAsString(String encoding) throws Exception 82 { 83 throw new UnsupportedOperationException ("getPayloadAsString"); 84 } 85 86 92 public byte[] getPayloadAsBytes() throws Exception 93 { 94 throw new UnsupportedOperationException ("getPayloadAsBytes"); 95 } 96 97 105 public Object getPayload() 106 { 107 if (in != null) 108 { 109 return in; 110 } 111 return nullPayload; 112 } 113 114 public InputStream getInputStream() 115 { 116 return in; 117 } 118 119 public OutputStream getOutputStream() 120 { 121 return out; 122 } 123 124 public void write(UMOEvent event) throws IOException 125 { 126 handler.write(event, out); 127 } 128 129 public OutputHandler getOutputHandler() 130 { 131 return handler; 132 } 133 134 public void setOutputHandler(OutputHandler handler) 135 { 136 this.handler = handler; 137 } 138 139 144 public void release() 145 { 146 } 148 149 } 150 | Popular Tags |