Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MessageDispatcher |
|
| 1.0;1 |
1 | /* | |
2 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
3 | * The software in this package is published under the terms of the CPAL v1.0 | |
4 | * license, a copy of which has been included with this distribution in the | |
5 | * LICENSE.txt file. | |
6 | */ | |
7 | package org.mule.api.transport; | |
8 | ||
9 | import org.mule.api.MuleException; | |
10 | import org.mule.api.MuleMessage; | |
11 | import org.mule.api.endpoint.OutboundEndpoint; | |
12 | import org.mule.api.lifecycle.Disposable; | |
13 | import org.mule.api.lifecycle.LifecycleStateEnabled; | |
14 | import org.mule.api.processor.MessageProcessor; | |
15 | ||
16 | /** | |
17 | * Combine {@link MessageDispatching} with | |
18 | * various lifecycle methods for the actual instances doing message sending. | |
19 | */ | |
20 | public interface MessageDispatcher extends Connectable, MessageProcessor, LifecycleStateEnabled | |
21 | { | |
22 | long RECEIVE_WAIT_INDEFINITELY = 0; | |
23 | long RECEIVE_NO_WAIT = -1; | |
24 | ||
25 | /** | |
26 | * This method can perform necessary state updates before any of the | |
27 | * {@link MessageDispatching} methods are invoked. | |
28 | * | |
29 | * @see MessageDispatcherFactory#activate(OutboundEndpoint, MessageDispatcher) | |
30 | */ | |
31 | void activate(); | |
32 | ||
33 | /** | |
34 | * After sending a message, the dispatcher can use this method e.g. to | |
35 | * clean up its internal state (if it has any) or return pooled resources to | |
36 | * whereever it got them during {@link #activate()}. | |
37 | * | |
38 | * @see MessageDispatcherFactory#passivate(OutboundEndpoint, MessageDispatcher) | |
39 | */ | |
40 | void passivate(); | |
41 | ||
42 | /** | |
43 | * Determines whether this dispatcher can be reused after message sending. | |
44 | * | |
45 | * @return <code>true</code> if this dispatcher can be reused, | |
46 | * <code>false</code> otherwise (for example when | |
47 | * {@link Disposable#dispose()} has been called because an Exception was | |
48 | * raised) | |
49 | */ | |
50 | boolean validate(); | |
51 | ||
52 | /** | |
53 | * Gets the connector for this dispatcher | |
54 | * | |
55 | * @return the connector for this dispatcher | |
56 | */ | |
57 | Connector getConnector(); | |
58 | ||
59 | /** | |
60 | * @return the endpoint which we are dispatching events to | |
61 | */ | |
62 | OutboundEndpoint getEndpoint(); | |
63 | ||
64 | MuleMessage createMuleMessage(Object transportMessage, String encoding) throws MuleException; | |
65 | ||
66 | MuleMessage createMuleMessage(Object transportMessage) throws MuleException; | |
67 | } |