Coverage Report - org.mule.providers.jbi.JbiConnector
 
Classes in this File Line Coverage Branch Coverage Complexity
JbiConnector
0%
0/29
N/A
1.125
 
 1  
 /*
 2  
  * $Id: JbiConnector.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;
 12  
 
 13  
 import org.mule.providers.AbstractConnector;
 14  
 import org.mule.umo.UMOException;
 15  
 import org.mule.umo.lifecycle.InitialisationException;
 16  
 
 17  
 import javax.jbi.JBIException;
 18  
 import javax.jbi.component.ComponentContext;
 19  
 import javax.jbi.component.ComponentLifeCycle;
 20  
 import javax.jbi.messaging.DeliveryChannel;
 21  
 import javax.jbi.messaging.MessageExchangeFactory;
 22  
 import javax.management.ObjectName;
 23  
 
 24  
 /**
 25  
  * <code>JbiConnector</code> can bind to a JBI container allowing components to
 26  
  * send events via Mule.
 27  
  */
 28  0
 public class JbiConnector extends AbstractConnector implements ComponentLifeCycle
 29  
 {
 30  
     private ObjectName extensionMBeanName;
 31  
     private ComponentContext context;
 32  
     private DeliveryChannel deliveryChannel;
 33  
     private MessageExchangeFactory exchangeFactory;
 34  
 
 35  
 
 36  
     protected void doInitialise() throws InitialisationException
 37  
     {
 38  
         // template method, nothing to do
 39  0
     }
 40  
 
 41  
     protected void doDispose()
 42  
     {
 43  
         // template method
 44  0
     }
 45  
 
 46  
     protected void doConnect() throws Exception
 47  
     {
 48  
         // template method
 49  0
     }
 50  
 
 51  
     protected void doDisconnect() throws Exception
 52  
     {
 53  
         // template method
 54  0
     }
 55  
 
 56  
     protected void doStart() throws UMOException
 57  
     {
 58  
         // template method
 59  0
     }
 60  
 
 61  
     protected void doStop() throws UMOException
 62  
     {
 63  
         // template method
 64  0
     }
 65  
 
 66  
     public String getProtocol()
 67  
     {
 68  0
         return "jbi";
 69  
     }
 70  
 
 71  
     public ObjectName getExtensionMBeanName()
 72  
     {
 73  0
         return extensionMBeanName;
 74  
     }
 75  
 
 76  
     public void setExtensionMBeanName(ObjectName extensionMBeanName)
 77  
     {
 78  0
         this.extensionMBeanName = extensionMBeanName;
 79  0
     }
 80  
 
 81  
     public ComponentContext getComponentContext()
 82  
     {
 83  0
         return context;
 84  
     }
 85  
 
 86  
     public DeliveryChannel getDeliveryChannel()
 87  
     {
 88  0
         return deliveryChannel;
 89  
     }
 90  
 
 91  
     public MessageExchangeFactory getExchangeFactory()
 92  
     {
 93  0
         return exchangeFactory;
 94  
     }
 95  
 
 96  
     /**
 97  
      * @see ComponentLifeCycle#init(ComponentContext)
 98  
      */
 99  
     // TODO the start/stop/shutdown JBI lifecycle methods are rather picky,
 100  
     // we should probably review the spec here again
 101  
     public void init(ComponentContext componentContext) throws JBIException
 102  
     {
 103  0
         this.context = componentContext;
 104  0
         this.deliveryChannel = context.getDeliveryChannel();
 105  0
         this.exchangeFactory = deliveryChannel.createExchangeFactory();
 106  0
     }
 107  
 
 108  
     /**
 109  
      * @see ComponentLifeCycle#start()
 110  
      */
 111  
     public void start()
 112  
     {
 113  
         try
 114  
         {
 115  0
             startConnector();
 116  
         }
 117  0
         catch (UMOException e)
 118  
         {
 119  0
             handleException(e);
 120  0
         }
 121  0
     }
 122  
 
 123  
     /**
 124  
      * @see ComponentLifeCycle#stop()
 125  
      */
 126  
     public void stop()
 127  
     {
 128  
         try
 129  
         {
 130  0
             stopConnector();
 131  
         }
 132  0
         catch (UMOException e)
 133  
         {
 134  0
             handleException(e);
 135  0
         }
 136  0
     }
 137  
 
 138  
     /**
 139  
      * @see ComponentLifeCycle#shutDown()
 140  
      */
 141  
     public void shutDown() throws JBIException
 142  
     {
 143  
         // nothing to do (for now?)
 144  0
     }
 145  
 
 146  
 }