org.mule.providers.streaming
Class StreamMessageAdapter

java.lang.Object
  extended by org.mule.providers.AbstractMessageAdapter
      extended by org.mule.providers.streaming.StreamMessageAdapter
All Implemented Interfaces:
Serializable, ThreadSafeAccess, UMOMessageAdapter, UMOStreamMessageAdapter
Direct Known Subclasses:
HttpStreamMessageAdapter

public class StreamMessageAdapter
extends AbstractMessageAdapter
implements UMOStreamMessageAdapter

Provides a generic base class for stream based message flows in Mule. This adapter represents the 3 flows of data that Mule identifies, namely inbound, outbound and response flows. These are represented by three streams on the adapter.

See Also:
Serialized Form

Field Summary
protected  OutputHandler handler
           
protected  InputStream in
           
protected  OutputStream out
           
 
Fields inherited from class org.mule.providers.AbstractMessageAdapter
attachments, DEFAULT_FAILFAST, encoding, exceptionPayload, id, logger, properties, READ, WRITE
 
Constructor Summary
  StreamMessageAdapter(InputStream in)
           
  StreamMessageAdapter(InputStream in, OutputStream out)
           
  StreamMessageAdapter(InputStream in, OutputStream out, OutputHandler handler)
           
  StreamMessageAdapter(OutputHandler handler)
           
  StreamMessageAdapter(OutputStream out, OutputHandler handler)
           
protected StreamMessageAdapter(StreamMessageAdapter template)
           
 
Method Summary
 InputStream getInputStream()
          Gets the input Stream associated with this event
 OutputHandler getOutputHandler()
          The Output handler is a callback that will handle the writing to an output Stream when the Stream is available
 OutputStream getOutputStream()
          Gets the output Stream associated with this event
 Object getPayload()
          This is an InputStream if triggered from an inbound event or response.
 byte[] getPayloadAsBytes()
          Converts the message implementation into a String representation
 String getPayloadAsString(String encoding)
          Converts the message implementation into a String representation
 ThreadSafeAccess newThreadCopy()
          By default we return "this".
 void release()
          The release method is called by Mule to notify this adapter that it is no longer needed.
 void setOutputHandler(OutputHandler handler)
          The Output handler is a callback that will handle the writing to an output Stream when the Stream is available
 void write(UMOEvent event)
          Writes the event to the current outputStream using the OutputHandler set on the StreamAdapter.
 
Methods inherited from class org.mule.providers.AbstractMessageAdapter
addAttachment, addProperties, assertAccess, clearProperties, convertToBytes, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getPayloadAsString, getProperty, getProperty, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, isDisabled, newException, removeAttachment, removeProperty, resetAccessControl, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setProperty, setReplyTo, setStringProperty, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mule.umo.provider.UMOMessageAdapter
addAttachment, addProperties, clearProperties, getAttachment, getAttachmentNames, getBooleanProperty, getCorrelationGroupSize, getCorrelationId, getCorrelationSequence, getDoubleProperty, getEncoding, getExceptionPayload, getIntProperty, getLongProperty, getPayloadAsString, getProperty, getProperty, getPropertyNames, getReplyTo, getStringProperty, getUniqueId, removeAttachment, removeProperty, setBooleanProperty, setCorrelationGroupSize, setCorrelationId, setCorrelationSequence, setDoubleProperty, setEncoding, setExceptionPayload, setIntProperty, setLongProperty, setProperty, setReplyTo, setStringProperty
 

Field Detail

in

protected InputStream in

out

protected OutputStream out

handler

protected OutputHandler handler
Constructor Detail

StreamMessageAdapter

public StreamMessageAdapter(InputStream in)

StreamMessageAdapter

public StreamMessageAdapter(InputStream in,
                            OutputStream out)

StreamMessageAdapter

public StreamMessageAdapter(OutputHandler handler)

StreamMessageAdapter

public StreamMessageAdapter(OutputStream out,
                            OutputHandler handler)

StreamMessageAdapter

public StreamMessageAdapter(InputStream in,
                            OutputStream out,
                            OutputHandler handler)

StreamMessageAdapter

protected StreamMessageAdapter(StreamMessageAdapter template)
Method Detail

getPayloadAsString

public String getPayloadAsString(String encoding)
                          throws Exception
Converts the message implementation into a String representation

Specified by:
getPayloadAsString in interface UMOMessageAdapter
Parameters:
encoding - The encoding to use when transforming the message (if necessary). The parameter is used when converting from a byte array
Returns:
String representation of the message payload
Throws:
Exception - Implementation may throw an endpoint specific exception

getPayloadAsBytes

public byte[] getPayloadAsBytes()
                         throws Exception
Converts the message implementation into a String representation

Specified by:
getPayloadAsBytes in interface UMOMessageAdapter
Returns:
String representation of the message
Throws:
Exception - Implemetation may throw an endpoint specific exception

getPayload

public Object getPayload()
This is an InputStream if triggered from an inbound event or response. If the Message has a response stream it is assumed that the message the response stream should be used. If the Message has been triggered from an outbound request and NullPayload will be used

Specified by:
getPayload in interface UMOMessageAdapter
Returns:
the current message

getInputStream

public InputStream getInputStream()
Description copied from interface: UMOStreamMessageAdapter
Gets the input Stream associated with this event

Specified by:
getInputStream in interface UMOStreamMessageAdapter
Returns:
the input Stream associated with this event

getOutputStream

public OutputStream getOutputStream()
Description copied from interface: UMOStreamMessageAdapter
Gets the output Stream associated with this event

Specified by:
getOutputStream in interface UMOStreamMessageAdapter
Returns:
the output Stream associated with this event

write

public void write(UMOEvent event)
           throws IOException
Description copied from interface: UMOStreamMessageAdapter
Writes the event to the current outputStream using the OutputHandler set on the StreamAdapter.

Specified by:
write in interface UMOStreamMessageAdapter
Parameters:
event - the event to write to the stream
Throws:
IOException

getOutputHandler

public OutputHandler getOutputHandler()
Description copied from interface: UMOStreamMessageAdapter
The Output handler is a callback that will handle the writing to an output Stream when the Stream is available

Specified by:
getOutputHandler in interface UMOStreamMessageAdapter
Returns:
the handler used to write to the stream

setOutputHandler

public void setOutputHandler(OutputHandler handler)
Description copied from interface: UMOStreamMessageAdapter
The Output handler is a callback that will handle the writing to an output Stream when the Stream is available

Specified by:
setOutputHandler in interface UMOStreamMessageAdapter
Parameters:
handler - the handler used to write to the stream

release

public void release()
The release method is called by Mule to notify this adapter that it is no longer needed. This method can be used to release any resources that a custom StreamAdapter may have associated with it.

Specified by:
release in interface UMOStreamMessageAdapter

newThreadCopy

public ThreadSafeAccess newThreadCopy()
Description copied from class: AbstractMessageAdapter
By default we return "this". This allows older code to inter-operate but doesn't, of course, give the required safety. Subclasses should override this method. Re-writing the threading handling should remove this requirement....

Specified by:
newThreadCopy in interface ThreadSafeAccess
Overrides:
newThreadCopy in class AbstractMessageAdapter
Returns:
A new copy of this


Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.