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