Coverage Report - org.mule.model.resolvers.ArrayEntryPointResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
ArrayEntryPointResolver
75%
6/8
50%
2/4
2.5
 
 1  
 /*
 2  
  * $Id: ArrayEntryPointResolver.java 10529 2008-01-25 05:58:36Z dfeist $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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 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  8
 public class ArrayEntryPointResolver extends AbstractArgumentEntryPointResolver
 29  
 {
 30  
     //@java.lang.Override
 31  
     protected Class[] getMethodArgumentTypes(Object[] payload)
 32  
     {
 33  8
         return ClassUtils.getClassTypes(payload);
 34  
     }
 35  
 
 36  
     //@java.lang.Override
 37  
     protected Object[] getPayloadFromMessage(MuleEventContext context) throws TransformerException
 38  
     {
 39  
         Object temp;
 40  16
         if (isTransformFirst())
 41  
         {
 42  16
             temp = context.transformMessage();
 43  
         }
 44  
         else
 45  
         {
 46  0
             temp = context.getMessage().getPayload();
 47  
         }
 48  16
         if (temp instanceof Object[])
 49  
         {
 50  16
             return new Object[]{temp};
 51  
         }
 52  
         else
 53  
         {
 54  
             //Payload type not supported by this resolver
 55  0
             return null;
 56  
         }
 57  
     }
 58  
 }