01: /*
02: * $Id: ArrayEntryPointResolver.java 10529 2008-01-25 05:58:36Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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 resolver method endtry 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: public class ArrayEntryPointResolver extends
29: AbstractArgumentEntryPointResolver {
30: //@java.lang.Override
31: protected Class[] getMethodArgumentTypes(Object[] payload) {
32: return ClassUtils.getClassTypes(payload);
33: }
34:
35: //@java.lang.Override
36: protected Object[] getPayloadFromMessage(MuleEventContext context)
37: throws TransformerException {
38: Object temp;
39: if (isTransformFirst()) {
40: temp = context.transformMessage();
41: } else {
42: temp = context.getMessage().getPayload();
43: }
44: if (temp instanceof Object[]) {
45: return new Object[] { temp };
46: } else {
47: //Payload type not supported by this resolver
48: return null;
49: }
50: }
51: }
|