Coverage Report - org.mule.impl.model.direct.DirectComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
DirectComponent
69%
18/26
0%
0/2
1.444
 
 1  
 /*
 2  
  * $Id: DirectComponent.java 11728 2008-05-13 07:31:11Z dirk.olmes $
 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  
 
 11  
 package org.mule.impl.model.direct;
 12  
 
 13  
 import org.mule.impl.MuleDescriptor;
 14  
 import org.mule.impl.MuleMessage;
 15  
 import org.mule.impl.model.AbstractComponent;
 16  
 import org.mule.impl.model.DefaultMuleProxy;
 17  
 import org.mule.impl.model.MuleProxy;
 18  
 import org.mule.umo.UMOEvent;
 19  
 import org.mule.umo.UMOException;
 20  
 import org.mule.umo.UMOMessage;
 21  
 import org.mule.umo.lifecycle.InitialisationException;
 22  
 import org.mule.umo.model.UMOModel;
 23  
 
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
  * A direct component invokes the service component directly without any threading or
 28  
  * pooling, even when the invocation is asynchronous
 29  
  */
 30  
 public class DirectComponent extends AbstractComponent
 31  
 {
 32  
     /**
 33  
      * Serial version
 34  
      */
 35  
     private static final long serialVersionUID = -8590955440156945732L;
 36  
 
 37  16
     protected List interceptorList = null;
 38  
     protected MuleProxy proxy;
 39  
 
 40  
     public DirectComponent(MuleDescriptor descriptor, UMOModel model)
 41  
     {
 42  16
         super(descriptor, model);
 43  16
     }
 44  
 
 45  
     protected void doInitialise() throws InitialisationException
 46  
     {
 47  
 
 48  
         try
 49  
         {
 50  10
             Object component = lookupComponent();
 51  10
             proxy = new DefaultMuleProxy(component, descriptor, model);
 52  10
             proxy.setStatistics(getStatistics());
 53  
         }
 54  0
         catch (UMOException e)
 55  
         {
 56  0
             throw new InitialisationException(e, this);
 57  10
         }
 58  10
     }
 59  
 
 60  
     protected UMOMessage doSend(UMOEvent event) throws UMOException
 61  
     {
 62  
 
 63  0
         Object obj = proxy.onCall(event);
 64  0
         if (obj instanceof UMOMessage)
 65  
         {
 66  0
             return (UMOMessage) obj;
 67  
         }
 68  
         else
 69  
         {
 70  0
             return new MuleMessage(obj, event.getMessage());
 71  
         }
 72  
     }
 73  
 
 74  
     protected void doDispatch(UMOEvent event) throws UMOException
 75  
     {
 76  0
         proxy.onCall(event);
 77  0
     }
 78  
 
 79  
     protected void doStop() throws UMOException
 80  
     {
 81  2
         proxy.stop();
 82  2
     }
 83  
 
 84  
     protected void doStart() throws UMOException
 85  
     {
 86  8
         proxy.start();
 87  6
     }
 88  
 
 89  
     protected void doPause()
 90  
     {
 91  8
         proxy.suspend();
 92  6
     }
 93  
 
 94  
     protected void doResume()
 95  
     {
 96  14
         proxy.resume();
 97  10
     }
 98  
 
 99  
     protected void doDispose()
 100  
     {
 101  6
         proxy.dispose();
 102  2
     }
 103  
 }