Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
CxfPayloadToArguments |
|
| 0.0;0 | ||||
CxfPayloadToArguments$1 |
|
| 0.0;0 | ||||
CxfPayloadToArguments$2 |
|
| 0.0;0 |
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.module.cxf; | |
8 | ||
9 | import org.mule.api.endpoint.OutboundEndpoint; | |
10 | import org.mule.transport.NullPayload; | |
11 | ||
12 | /** | |
13 | * This enum defines the strategies to convert a Payload to an array of arguments | |
14 | * that will be used to call the webservice in | |
15 | * {@link CxfOutboundMessageProcessor#doSendWithClient(org.mule.api.MuleEvent)} and in | |
16 | * {@link CxfOutboundMessageProcessor#doSendWithProxy(org.mule.api.MuleEvent)}. | |
17 | */ | |
18 | 0 | public enum CxfPayloadToArguments |
19 | { | |
20 | /** | |
21 | * In this strategy, if the payload is of type {@link NullPayload} it will be | |
22 | * send as a parameter just like any other object. | |
23 | */ | |
24 | 0 | NULL_PAYLOAD_AS_PARAMETER(CxfConstants.PAYLOAD_TO_ARGUMENTS_NULL_PAYLOAD_AS_PARAMETER) |
25 | { | |
26 | ||
27 | }, | |
28 | /** | |
29 | * In this strategy, if the payload is of type {@link NullPayload} it will not be | |
30 | * send as a parameter. The array of arguments in this case will be empty. For | |
31 | * the rest of the objects it behaves just like | |
32 | * {@link #NULL_PAYLOAD_AS_PARAMETER} (it will delegate to | |
33 | * {@link CxfPayloadToArguments#payloadToArrayOfArguments(Object)}). | |
34 | */ | |
35 | 0 | NULL_PAYLOAD_AS_VOID(CxfConstants.PAYLOAD_TO_ARGUMENTS_NULL_PAYLOAD_AS_VOID) |
36 | { | |
37 | @Override | |
38 | public Object[] payloadToArrayOfArguments(Object payload) | |
39 | { | |
40 | 0 | if (payload instanceof NullPayload) |
41 | { | |
42 | 0 | return new Object[]{}; |
43 | } | |
44 | else | |
45 | { | |
46 | 0 | return super.payloadToArrayOfArguments(payload); |
47 | } | |
48 | } | |
49 | }; | |
50 | ||
51 | /** | |
52 | * This is the value that is needed to be configured in the endpoint under | |
53 | * property {@link CxfConstants#PAYLOAD_TO_ARGUMENTS} so this | |
54 | * {@link CxfPayloadToArguments} is selected on method | |
55 | * {@link #getPayloadToArgumentsForEndpoint(OutboundEndpoint)}. | |
56 | */ | |
57 | private final String payloadToArgumentsParameterValue; | |
58 | ||
59 | private CxfPayloadToArguments(String payloadToArgumentsParameterValue) | |
60 | 0 | { |
61 | 0 | this.payloadToArgumentsParameterValue = payloadToArgumentsParameterValue; |
62 | 0 | } |
63 | ||
64 | /** | |
65 | * This method is the one that converts the payload in an array of arguments. In | |
66 | * this default implementation if the payload is already an array of | |
67 | * {@link Object objects} that array will be returned. Otherwise, an array with | |
68 | * one element, the payload, will be returned. | |
69 | * | |
70 | * @param payload the payload to convert to array of arguments. | |
71 | * @return the array of arguments | |
72 | */ | |
73 | public Object[] payloadToArrayOfArguments(Object payload) | |
74 | { | |
75 | Object[] args; | |
76 | 0 | if (payload instanceof Object[]) |
77 | { | |
78 | 0 | args = (Object[]) payload; |
79 | } | |
80 | else | |
81 | { | |
82 | 0 | args = new Object[]{payload}; |
83 | } | |
84 | 0 | return args; |
85 | } | |
86 | ||
87 | public String getPayloadToArgumentsParameterValue() | |
88 | { | |
89 | 0 | return payloadToArgumentsParameterValue; |
90 | } | |
91 | } |