Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
OutboundResponsePropertiesMessageProcessor |
|
| 0.0;0 |
1 | /* | |
2 | * $Id: OutboundResponsePropertiesMessageProcessor.java 19191 2010-08-25 21:05:23Z tcarlson $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.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.endpoint.outbound; | |
12 | ||
13 | import org.mule.api.MuleEvent; | |
14 | import org.mule.api.MuleException; | |
15 | import org.mule.api.endpoint.OutboundEndpoint; | |
16 | import org.mule.processor.AbstractInterceptingMessageProcessor; | |
17 | ||
18 | import java.util.List; | |
19 | ||
20 | /** | |
21 | * Propagates properties from request message to response message as defined by | |
22 | * {@link OutboundEndpoint#getResponseProperties()}. | |
23 | * <p> | |
24 | * //TODO This can became a standard MessageProcessor in the response chain if/when | |
25 | * event has a (immutable) reference to request message. | |
26 | */ | |
27 | public class OutboundResponsePropertiesMessageProcessor extends AbstractInterceptingMessageProcessor | |
28 | { | |
29 | ||
30 | private OutboundEndpoint endpoint; | |
31 | ||
32 | public OutboundResponsePropertiesMessageProcessor(OutboundEndpoint endpoint) | |
33 | 0 | { |
34 | 0 | this.endpoint = endpoint; |
35 | 0 | } |
36 | ||
37 | public MuleEvent process(MuleEvent event) throws MuleException | |
38 | { | |
39 | 0 | MuleEvent responseEvent = processNext(event); |
40 | ||
41 | 0 | if (responseEvent != null) |
42 | { | |
43 | // Properties which should be carried over from the request message | |
44 | // to the response message | |
45 | 0 | List<String> responseProperties = endpoint.getResponseProperties(); |
46 | 0 | for (String propertyName : responseProperties) |
47 | { | |
48 | 0 | Object propertyValue = event.getMessage().getOutboundProperty(propertyName); |
49 | 0 | if (propertyValue != null) |
50 | { | |
51 | 0 | responseEvent.getMessage().setOutboundProperty(propertyName, propertyValue); |
52 | } | |
53 | 0 | } |
54 | } | |
55 | 0 | return responseEvent; |
56 | } | |
57 | } |