Coverage Report - org.mule.processor.ResponseMessageProcessorAdapter
 
Classes in this File Line Coverage Branch Coverage Complexity
ResponseMessageProcessorAdapter
0%
0/28
0%
0/14
0
 
 1  
 /*
 2  
  * $Id: ResponseMessageProcessorAdapter.java 20781 2010-12-16 13:19:09Z dfeist $
 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  
 
 11  
 package org.mule.processor;
 12  
 
 13  
 import org.mule.api.MuleEvent;
 14  
 import org.mule.api.MuleException;
 15  
 import org.mule.api.construct.FlowConstruct;
 16  
 import org.mule.api.construct.FlowConstructAware;
 17  
 import org.mule.api.context.MuleContextAware;
 18  
 import org.mule.api.lifecycle.Disposable;
 19  
 import org.mule.api.lifecycle.Initialisable;
 20  
 import org.mule.api.lifecycle.InitialisationException;
 21  
 import org.mule.api.lifecycle.Lifecycle;
 22  
 import org.mule.api.lifecycle.Startable;
 23  
 import org.mule.api.lifecycle.Stoppable;
 24  
 import org.mule.api.processor.MessageProcessor;
 25  
 
 26  
 public class ResponseMessageProcessorAdapter extends AbstractResponseMessageProcessor implements Lifecycle, FlowConstructAware
 27  
 {
 28  
 
 29  
     protected MessageProcessor responseProcessor;
 30  
     protected FlowConstruct flowConstruct;
 31  
 
 32  
     public ResponseMessageProcessorAdapter()
 33  
     {
 34  0
         super();
 35  0
     }
 36  
 
 37  
     public ResponseMessageProcessorAdapter(MessageProcessor responseProcessor)
 38  
     {
 39  0
         super();
 40  0
         this.responseProcessor = responseProcessor;
 41  0
     }
 42  
 
 43  
     public void setProcessor(MessageProcessor processor)
 44  
     {
 45  0
         this.responseProcessor = processor;
 46  0
     }
 47  
 
 48  
     @Override
 49  
     protected MuleEvent processResponse(MuleEvent event) throws MuleException
 50  
     {
 51  0
         if (responseProcessor == null)
 52  
         {
 53  0
             return event;
 54  
         }
 55  
         else
 56  
         {
 57  0
             return responseProcessor.process(event);
 58  
         }
 59  
     }
 60  
 
 61  
     public void initialise() throws InitialisationException
 62  
     {
 63  0
         if (responseProcessor instanceof MuleContextAware)
 64  
         {
 65  0
             ((MuleContextAware) responseProcessor).setMuleContext(muleContext);
 66  
         }
 67  0
         if (responseProcessor instanceof FlowConstructAware)
 68  
         {
 69  0
             ((FlowConstructAware) responseProcessor).setFlowConstruct(flowConstruct);
 70  
         }
 71  0
         if (responseProcessor instanceof Initialisable)
 72  
         {
 73  0
             ((Initialisable) responseProcessor).initialise();
 74  
         }
 75  0
     }
 76  
 
 77  
     public void start() throws MuleException
 78  
     {
 79  0
         if (responseProcessor instanceof Startable)
 80  
         {
 81  0
             ((Startable) responseProcessor).start();
 82  
         }
 83  0
     }
 84  
 
 85  
     public void stop() throws MuleException
 86  
     {
 87  0
         if (responseProcessor instanceof Stoppable)
 88  
         {
 89  0
             ((Stoppable) responseProcessor).stop();
 90  
         }
 91  0
     }
 92  
 
 93  
     public void dispose()
 94  
     {
 95  0
         if (responseProcessor instanceof Disposable)
 96  
         {
 97  0
             ((Disposable) responseProcessor).dispose();
 98  
         }
 99  0
     }
 100  
 
 101  
     public void setFlowConstruct(FlowConstruct flowConstruct)
 102  
     {
 103  0
         this.flowConstruct = flowConstruct;
 104  0
     }
 105  
 
 106  
 }