Coverage Report - org.mule.model.resolvers.CallableEntryPointResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
CallableEntryPointResolver
0%
0/13
0%
0/2
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.model.resolvers;
 8  
 
 9  
 import org.mule.api.MuleEventContext;
 10  
 import org.mule.api.MuleRuntimeException;
 11  
 import org.mule.api.lifecycle.Callable;
 12  
 import org.mule.api.model.EntryPointResolver;
 13  
 import org.mule.api.model.InvocationResult;
 14  
 import org.mule.config.i18n.CoreMessages;
 15  
 import org.mule.config.i18n.MessageFactory;
 16  
 
 17  
 import java.lang.reflect.Method;
 18  
 
 19  
 /**
 20  
  * An entry-point resolver that only allows Service objects that implement the
 21  
  * Callable interface
 22  
  *
 23  
  * @see org.mule.api.lifecycle.Callable
 24  
  */
 25  0
 public class CallableEntryPointResolver implements EntryPointResolver
 26  
 {
 27  
     protected static final Method callableMethod;
 28  
 
 29  
     static
 30  
     {
 31  
         try
 32  
         {
 33  0
             callableMethod = Callable.class.getMethod("onCall", new Class[] {MuleEventContext.class});
 34  
         }
 35  0
         catch (NoSuchMethodException e)
 36  
         {
 37  0
             throw new MuleRuntimeException(
 38  
                     MessageFactory.createStaticMessage("Panic! No onCall(MuleEventContext) method found in the Callable interface."));
 39  0
         }
 40  0
     }
 41  
 
 42  
     public InvocationResult invoke(Object component, MuleEventContext context) throws Exception
 43  
     {
 44  0
         if (component instanceof Callable)
 45  
         {
 46  0
             Object result = ((Callable) component).onCall(context);
 47  0
             return new InvocationResult(this, result, callableMethod);
 48  
         }
 49  
         else
 50  
         {
 51  0
             InvocationResult result = new InvocationResult(this, InvocationResult.State.NOT_SUPPORTED);
 52  0
             result.setErrorMessage(CoreMessages.objectDoesNotImplementInterface(component, Callable.class).toString());
 53  0
             return result;
 54  
         }
 55  
     }
 56  
 
 57  
     @Override
 58  
     public String toString()
 59  
     {
 60  0
         return "CallableEntryPointResolver{}";
 61  
     }
 62  
 }