KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > umo > provider > UMOMessageDispatcher


1 /*
2  * $Id: UMOMessageDispatcher.java 3798 2006-11-04 04:07:14Z aperepel $
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 MuleSource MPL
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 import org.mule.umo.UMOException;
15 import org.mule.umo.UMOMessage;
16 import org.mule.umo.endpoint.UMOEndpointURI;
17 import org.mule.umo.endpoint.UMOImmutableEndpoint;
18 import org.mule.umo.lifecycle.Disposable;
19
20 import java.io.OutputStream JavaDoc;
21
22 /**
23  * <code>UMOMessageDispatcher</code> is the interface responsible for distpatching
24  * events to a particular transport. It implements the client code necessary to write
25  * data to the underlying protocol. The dispatcher also exposes a receive method that
26  * allows users to make specific calls to the underlying transport to receive an
27  * event.
28  *
29  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
30  * @version $Revision: 3798 $
31  */

32 public interface UMOMessageDispatcher extends Disposable, UMOConnectable
33 {
34     long RECEIVE_WAIT_INDEFINITELY = 0;
35     long RECEIVE_NO_WAIT = -1;
36
37     /**
38      * Dispatches an event from the endpoint to the external system
39      *
40      * @param event The event to dispatch
41      * @throws DispatchException if the event fails to be dispatched
42      */

43     void dispatch(UMOEvent event) throws DispatchException;
44
45     /**
46      * Sends an event from the endpoint to the external system
47      *
48      * @param event The event to send
49      * @return event the response form the external system wrapped in a UMOEvent
50      * @throws DispatchException if the event fails to be dispatched
51      */

52     UMOMessage send(UMOEvent event) throws DispatchException;
53
54     /**
55      * Make a specific request to the underlying transport
56      *
57      * @param endpointUri the endpoint URI to use when connecting to the resource
58      * @param timeout the maximum time the operation should block before returning.
59      * The call should return immediately if there is data available. If
60      * no data becomes available before the timeout elapses, null will be
61      * returned
62      * @return the result of the request wrapped in a UMOMessage object. Null will be
63      * returned if no data was avaialable
64      * @throws Exception if the call to the underlying protocal cuases an exception
65      * @deprecated Use receive(UMOImmutableEndpoint endpoint, long timeout)
66      */

67     UMOMessage receive(UMOEndpointURI endpointUri, long timeout) throws Exception JavaDoc;
68
69     /**
70      * Make a specific request to the underlying transport
71      *
72      * @param endpoint the endpoint to use when connecting to the resource
73      * @param timeout the maximum time the operation should block before returning.
74      * The call should return immediately if there is data available. If
75      * no data becomes available before the timeout elapses, null will be
76      * returned
77      * @return the result of the request wrapped in a UMOMessage object. Null will be
78      * returned if no data was avaialable
79      * @throws Exception if the call to the underlying protocal cuases an exception
80      */

81     UMOMessage receive(UMOImmutableEndpoint endpoint, long timeout) throws Exception JavaDoc;
82
83     /**
84      * If the underlying transport has the notion of a client session when writing to
85      * it, the session should be obtainable using this method. If there is no session
86      * a null will be returned
87      *
88      * @return the transport specific session or null if there is no session
89      * @throws UMOException
90      */

91     Object JavaDoc getDelegateSession() throws UMOException;
92
93     /**
94      * Gets the connector for this dispatcher
95      *
96      * @return the connector for this dispatcher
97      */

98     UMOConnector getConnector();
99
100     /**
101      * Determines if this dispatcher has been disposed. Once disposed a dispatcher
102      * cannot be used again
103      *
104      * @return true if this dispatcher has been disposed, false otherwise
105      */

106     boolean isDisposed();
107
108     /**
109      * Well get the output stream (if any) for this type of transport. Typically this
110      * will be called only when Streaming is being used on an outbound endpoint
111      *
112      * @param endpoint the endpoint that releates to this Dispatcher
113      * @param message the current message being processed
114      * @return the output stream to use for this request or null if the transport
115      * does not support streaming
116      * @throws UMOException
117      */

118     OutputStream JavaDoc getOutputStream(UMOImmutableEndpoint endpoint, UMOMessage message) throws UMOException;
119 }
120
Popular Tags