| 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 and fault {@link Message} instances. |
|
| 23 | * Different providers such as JMS, JBI, CXF and HTTP can provide their own derived API to expose the underlying transport |
|
| 24 | * semantics to avoid the leaky abstractions of generic APIs. |
|
| 25 | * |
|
| 26 | * @version $Revision: 550760 $ |
|
| 27 | */ |
|
| 28 | public interface Exchange { |
|
| 29 | ||
| 30 | /** |
|
| 31 | * Returns the exchange id |
|
| 32 | * @return the unique id of the exchange |
|
| 33 | */ |
|
| 34 | String getExchangeId(); |
|
| 35 | ||
| 36 | /** |
|
| 37 | * Set the exchange id |
|
| 38 | * @param id |
|
| 39 | */ |
|
| 40 | void setExchangeId(String id); |
|
| 41 | ||
| 42 | ||
| 43 | /** |
|
| 44 | * Returns a property associated with this exchange by name |
|
| 45 | * |
|
| 46 | * @param name the name of the property |
|
| 47 | * @return the value of the given header or null if there is no property for the given name |
|
| 48 | */ |
|
| 49 | Object getProperty(String name); |
|
| 50 | ||
| 51 | ||
| 52 | /** |
|
| 53 | * Returns a property associated with this exchange by name and specifying the type required |
|
| 54 | * |
|
| 55 | * @param name the name of the property |
|
| 56 | * @param type the type of the property |
|
| 57 | * @return the value of the given header or null if there is no property for the given name or |
|
| 58 | * null if it cannot be converted to the given type |
|
| 59 | */ |
|
| 60 | <T> T getProperty(String name, Class<T> type); |
|
| 61 | ||
| 62 | /** |
|
| 63 | * Sets a property on the exchange |
|
| 64 | * |
|
| 65 | * @param name of the property |
|
| 66 | * @param value to associate with the name |
|
| 67 | */ |
|
| 68 | void setProperty(String name, Object value); |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Returns all of the properties associated with the exchange |
|
| 72 | * |
|
| 73 | * @return all the headers in a Map |
|
| 74 | */ |
|
| 75 | Map<String, Object> getProperties(); |
|
| 76 | ||
| 77 | ||
| 78 | /** |
|
| 79 | * Returns the inbound request message |
|
| 80 | * @return the message |
|
| 81 | */ |
|
| 82 | Message getIn(); |
|
| 83 | ||
| 84 | /** |
|
| 85 | * Returns the outbound message, lazily creating one if one has not already been associated with this exchange. |
|
| 86 | * If you want to inspect this property but not force lazy creation then invoke the {@link #getOut(boolean)} method |
|
| 87 | * passing in null |
|
| 88 | * |
|
| 89 | * @return the response |
|
| 90 | */ |
|
| 91 | Message getOut(); |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Returns the outbound message; optionally lazily creating one if one has not been associated with this exchange |
|
| 95 | * @return the response |
|
| 96 | */ |
|
| 97 | Message getOut(boolean lazyCreate); |
|
| 98 | ||
| 99 | /** |
|
| 100 | * Returns the fault message |
|
| 101 | * @return the fault |
|
| 102 | */ |
|
| 103 | Message getFault(); |
|
| 104 | ||
| 105 | /** |
|
| 106 | * Returns the exception associated with this exchange |
|
| 107 | * @return the exception (or null if no faults) |
|
| 108 | */ |
|
| 109 | Throwable getException(); |
|
| 110 | ||
| 111 | /** |
|
| 112 | * Sets the exception associated with this exchange |
|
| 113 | * @param e |
|
| 114 | */ |
|
| 115 | void setException(Throwable e); |
|
| 116 | ||
| 117 | /** |
|
| 118 | * Returns the container so that a processor can resolve endpoints from URIs |
|
| 119 | * |
|
| 120 | * @return the container which owns this exchange |
|
| 121 | */ |
|
| 122 | CamelContext getContext(); |
|
| 123 | ||
| 124 | /** |
|
| 125 | * Creates a copy of the current message exchange so that it can be forwarded to another |
|
| 126 | * destination |
|
| 127 | */ |
|
| 128 | Exchange copy(); |
|
| 129 | ||
| 130 | /** |
|
| 131 | * Copies the data into this exchange from the given exchange |
|
| 132 | * |
|
| 133 | * #param source is the source from which headers and messages will be copied |
|
| 134 | */ |
|
| 135 | void copyFrom(Exchange source); |
|
| 136 | } |