Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||
Exchange |
|
| 0.0;0 |
1 | /** |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
16 | */ |
|
17 | package org.apache.camel; |
|
18 | ||
19 | import java.util.Map; |
|
20 | ||
21 | /** |
|
22 | * The base message exchange interface providing access to the request, response |
|
23 | * and fault {@link Message} instances. Different providers such as JMS, JBI, |
|
24 | * CXF and HTTP can provide their own derived API to expose the underlying |
|
25 | * transport semantics to avoid the leaky abstractions of generic APIs. |
|
26 | * |
|
27 | * @version $Revision: 563607 $ |
|
28 | */ |
|
29 | public interface Exchange { |
|
30 | ||
31 | /** |
|
32 | * Returns the exchange id |
|
33 | * |
|
34 | * @return the unique id of the exchange |
|
35 | */ |
|
36 | String getExchangeId(); |
|
37 | ||
38 | /** |
|
39 | * Set the exchange id |
|
40 | * |
|
41 | * @param id |
|
42 | */ |
|
43 | void setExchangeId(String id); |
|
44 | ||
45 | /** |
|
46 | * Returns a property associated with this exchange by name |
|
47 | * |
|
48 | * @param name the name of the property |
|
49 | * @return the value of the given header or null if there is no property for |
|
50 | * the given name |
|
51 | */ |
|
52 | Object getProperty(String name); |
|
53 | ||
54 | /** |
|
55 | * Returns a property associated with this exchange by name and specifying |
|
56 | * the type required |
|
57 | * |
|
58 | * @param name the name of the property |
|
59 | * @param type the type of the property |
|
60 | * @return the value of the given header or null if there is no property for |
|
61 | * the given name or null if it cannot be converted to the given |
|
62 | * type |
|
63 | */ |
|
64 | <T> T getProperty(String name, Class<T> type); |
|
65 | ||
66 | /** |
|
67 | * Sets a property on the exchange |
|
68 | * |
|
69 | * @param name of the property |
|
70 | * @param value to associate with the name |
|
71 | */ |
|
72 | void setProperty(String name, Object value); |
|
73 | ||
74 | /** |
|
75 | * Returns all of the properties associated with the exchange |
|
76 | * |
|
77 | * @return all the headers in a Map |
|
78 | */ |
|
79 | Map<String, Object> getProperties(); |
|
80 | ||
81 | /** |
|
82 | * Returns the inbound request message |
|
83 | * |
|
84 | * @return the message |
|
85 | */ |
|
86 | Message getIn(); |
|
87 | ||
88 | /** |
|
89 | * Returns the outbound message, lazily creating one if one has not already |
|
90 | * been associated with this exchange. If you want to inspect this property |
|
91 | * but not force lazy creation then invoke the {@link #getOut(boolean)} |
|
92 | * method passing in null |
|
93 | * |
|
94 | * @return the response |
|
95 | */ |
|
96 | Message getOut(); |
|
97 | ||
98 | /** |
|
99 | * Returns the outbound message; optionally lazily creating one if one has |
|
100 | * not been associated with this exchange |
|
101 | * |
|
102 | * @return the response |
|
103 | */ |
|
104 | Message getOut(boolean lazyCreate); |
|
105 | ||
106 | /** |
|
107 | * Returns the fault message |
|
108 | * |
|
109 | * @return the fault |
|
110 | */ |
|
111 | Message getFault(); |
|
112 | ||
113 | /** |
|
114 | * Returns the exception associated with this exchange |
|
115 | * |
|
116 | * @return the exception (or null if no faults) |
|
117 | */ |
|
118 | Throwable getException(); |
|
119 | ||
120 | /** |
|
121 | * Sets the exception associated with this exchange |
|
122 | * |
|
123 | * @param e |
|
124 | */ |
|
125 | void setException(Throwable e); |
|
126 | ||
127 | /** |
|
128 | * Returns the container so that a processor can resolve endpoints from URIs |
|
129 | * |
|
130 | * @return the container which owns this exchange |
|
131 | */ |
|
132 | CamelContext getContext(); |
|
133 | ||
134 | /** |
|
135 | * Creates a copy of the current message exchange so that it can be |
|
136 | * forwarded to another destination |
|
137 | */ |
|
138 | Exchange copy(); |
|
139 | ||
140 | /** |
|
141 | * Copies the data into this exchange from the given exchange |
|
142 | * |
|
143 | * #param source is the source from which headers and messages will be |
|
144 | * copied |
|
145 | */ |
|
146 | void copyFrom(Exchange source); |
|
147 | } |