View Javadoc

1   /*
2    * $Id: OutputHandler.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.umo.provider;
12  
13  import org.mule.umo.UMOEvent;
14  
15  import java.io.IOException;
16  import java.io.OutputStream;
17  import java.util.Map;
18  
19  /**
20   * The OutputHandler is a strategy class that is set on the StreamMessageAdapter to
21   * defer the writing of the message payload until there is a stream available to
22   * write it to.
23   * 
24   * @see org.mule.providers.streaming.StreamMessageAdapter
25   */
26  public interface OutputHandler
27  {
28  
29      /**
30       * Write the event payload to the stream. Depending on the underlying transport,
31       * attachements and message properties may be written to the stream here too.
32       * 
33       * @param event the current event
34       * @param out the output stream to write to
35       * @throws IOException
36       */
37      void write(UMOEvent event, OutputStream out) throws IOException;
38  
39      /**
40       * Used to obtain a set of headers that will be sent with this stream payload.
41       * Headers are typically set independently from a stream payload.
42       * 
43       * @param event the current event
44       * @return a Map of headers or an empty map if there are no headers
45       */
46      Map getHeaders(UMOEvent event);
47  }