Coverage Report - org.mule.module.ibeans.spi.support.DynamicRequestInterfaceBinding
 
Classes in this File Line Coverage Branch Coverage Complexity
DynamicRequestInterfaceBinding
0%
0/10
0%
0/4
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.ibeans.spi.support;
 8  
 
 9  
 import org.mule.DefaultMuleEvent;
 10  
 import org.mule.DefaultMuleMessage;
 11  
 import org.mule.api.MessagingException;
 12  
 import org.mule.api.MuleEvent;
 13  
 import org.mule.api.MuleMessage;
 14  
 import org.mule.config.i18n.CoreMessages;
 15  
 import org.mule.transport.NullPayload;
 16  
 
 17  
 import org.ibeans.api.channel.CHANNEL;
 18  
 
 19  
 /**
 20  
  * Creates an component binding that can use the {@link org.mule.api.transport.MessageRequester} interface to make
 21  
  * a call.  The need for this class is that the MessageRequester has no support for passing an {@link org.mule.api.MuleMessage} so this
 22  
  * binding will set the message on the endpoint and use it when the request is made
 23  
  */
 24  0
 public class DynamicRequestInterfaceBinding extends DefaultRequestInterfaceBinding
 25  
 {
 26  
     @Override
 27  
     public MuleEvent process(MuleEvent event) throws MessagingException
 28  
     {
 29  
         try
 30  
         {
 31  0
             int timeout = event.getMessage().getInboundProperty(CHANNEL.TIMEOUT, event.getMuleContext().getConfiguration().getDefaultResponseTimeout());
 32  0
             if (inboundEndpoint instanceof DynamicRequestEndpoint)
 33  
             {
 34  0
                 MuleMessage message =((DynamicRequestEndpoint) inboundEndpoint).request(timeout, event);
 35  0
                 if(message == null)
 36  
                 {
 37  0
                     message = new DefaultMuleMessage(NullPayload.getInstance(), event.getMuleContext());
 38  
                 }
 39  0
                 return new DefaultMuleEvent(message, event);
 40  
             }
 41  
             else
 42  
             {
 43  0
                 return new DefaultMuleEvent(inboundEndpoint.request(event.getMuleContext()
 44  
                     .getConfiguration()
 45  
                     .getDefaultResponseTimeout()), event);
 46  
             }
 47  
         }
 48  0
         catch (Exception e)
 49  
         {
 50  0
             throw new MessagingException(CoreMessages.failedToInvoke("inboundEndpoint.request()"), event, e);
 51  
         }
 52  
     }
 53  
 }