Coverage Report - org.mule.providers.jbi.components.AbstractEndpointComponent
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractEndpointComponent
54%
15/28
50%
4/8
2
 
 1  
 /*
 2  
  * $Id: AbstractEndpointComponent.java 7963 2007-08-21 08:53:15Z 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.providers.jbi.components;
 12  
 
 13  
 import org.mule.MuleManager;
 14  
 import org.mule.impl.endpoint.MuleEndpoint;
 15  
 import org.mule.umo.UMOException;
 16  
 import org.mule.umo.endpoint.UMOEndpoint;
 17  
 
 18  
 import java.util.Map;
 19  
 
 20  
 import javax.jbi.JBIException;
 21  
 
 22  
 /**
 23  
  * A Jbi component that has a Mule muleEndpoint component configured on it. Both the
 24  
  * Dispatcher and Receiver components extend this component.
 25  
  */
 26  
 public abstract class AbstractEndpointComponent extends AbstractJbiComponent
 27  
 {
 28  
 
 29  
     protected UMOEndpoint muleEndpoint;
 30  
 
 31  
     protected String endpoint;
 32  
 
 33  
     protected Map endpointProperties;
 34  
 
 35  
     protected AbstractEndpointComponent()
 36  2
     {
 37  2
         if (!MuleManager.isInstanciated())
 38  
         {
 39  2
             MuleManager.getConfiguration().setEmbedded(true);
 40  
             try
 41  
             {
 42  2
                 MuleManager.getInstance().start();
 43  
             }
 44  0
             catch (UMOException e)
 45  
             {
 46  0
                 e.printStackTrace();
 47  2
             }
 48  
         }
 49  2
     }
 50  
 
 51  
     public UMOEndpoint getMuleEndpoint()
 52  
     {
 53  0
         return muleEndpoint;
 54  
     }
 55  
 
 56  
     public void setMuleEndpoint(UMOEndpoint muleEndpoint)
 57  
     {
 58  0
         this.muleEndpoint = muleEndpoint;
 59  0
     }
 60  
 
 61  
     public String getEndpoint()
 62  
     {
 63  0
         return endpoint;
 64  
     }
 65  
 
 66  
     public void setEndpoint(String endpoint)
 67  
     {
 68  2
         this.endpoint = endpoint;
 69  2
     }
 70  
 
 71  
     public Map getEndpointProperties()
 72  
     {
 73  0
         return endpointProperties;
 74  
     }
 75  
 
 76  
     public void setEndpointProperties(Map endpointProperties)
 77  
     {
 78  0
         this.endpointProperties = endpointProperties;
 79  0
     }
 80  
 
 81  
     protected void doInit() throws JBIException
 82  
     {
 83  
         try
 84  
         {
 85  2
             if (muleEndpoint == null)
 86  
             {
 87  2
                 if (endpoint == null)
 88  
                 {
 89  0
                     throw new IllegalArgumentException("A Mule muleEndpoint must be set on this component");
 90  
                 }
 91  
                 else
 92  
                 {
 93  2
                     muleEndpoint = new MuleEndpoint(endpoint, true);
 94  
                 }
 95  
             }
 96  
 
 97  2
             if (endpointProperties != null)
 98  
             {
 99  0
                 muleEndpoint.getProperties().putAll(endpointProperties);
 100  
             }
 101  2
             muleEndpoint.initialise();
 102  
 
 103  
         }
 104  0
         catch (Exception e)
 105  
         {
 106  0
             throw new JBIException(e);
 107  2
         }
 108  2
     }
 109  
 }