Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
ArrayEntryPointResolver |
|
| 0.0;0 |
1 | /* | |
2 | * $Id: ArrayEntryPointResolver.java 20321 2010-11-24 15:21:24Z dfeist $ | |
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 | package org.mule.model.resolvers; | |
11 | ||
12 | import org.mule.api.MuleEventContext; | |
13 | import org.mule.api.transformer.TransformerException; | |
14 | import org.mule.util.ClassUtils; | |
15 | ||
16 | /** | |
17 | * Will resolver entry point methods on a service service that accept a single array. | |
18 | * i.e. | |
19 | * <code>public Object eat(Fruit[] fruit)</code> | |
20 | * <p/> | |
21 | * This resolver will NOT resolve method entry points such as - | |
22 | * <code>public Object eat(Fruit[] fruit, Banana banana)</code> | |
23 | * <p/> | |
24 | * If you require to mix an array type with complex types you need to specify an inbound transformer that return a | |
25 | * multi-dimensional array of arguments i.e. | |
26 | * <code>new Object[]{new Fruit[]{new Apple(), new Orange()}, new Banana()};</code> | |
27 | */ | |
28 | 0 | public class ArrayEntryPointResolver extends AbstractArgumentEntryPointResolver |
29 | { | |
30 | @Override | |
31 | protected Class<?>[] getMethodArgumentTypes(Object[] payload) | |
32 | { | |
33 | 0 | return ClassUtils.getClassTypes(payload); |
34 | } | |
35 | ||
36 | @Override | |
37 | protected Object[] getPayloadFromMessage(MuleEventContext context) throws TransformerException | |
38 | { | |
39 | 0 | Object temp = context.getMessage().getPayload(); |
40 | 0 | if (temp instanceof Object[]) |
41 | { | |
42 | 0 | return new Object[]{temp}; |
43 | } | |
44 | else | |
45 | { | |
46 | // Payload type not supported by this resolver | |
47 | 0 | return null; |
48 | } | |
49 | } | |
50 | } |