Coverage Report - org.mule.transport.ConnectorLifecycleManager
 
Classes in this File Line Coverage Branch Coverage Complexity
ConnectorLifecycleManager
0%
0/24
0%
0/8
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport;
 8  
 
 9  
 import org.mule.api.MuleException;
 10  
 import org.mule.api.lifecycle.Disposable;
 11  
 import org.mule.api.lifecycle.Initialisable;
 12  
 import org.mule.api.lifecycle.LifecycleCallback;
 13  
 import org.mule.api.lifecycle.Startable;
 14  
 import org.mule.api.lifecycle.Stoppable;
 15  
 import org.mule.api.transport.Connector;
 16  
 import org.mule.context.notification.ConnectionNotification;
 17  
 import org.mule.lifecycle.SimpleLifecycleManager;
 18  
 
 19  
 /**
 20  
  * Manages the lifecycle of connectors in Mule. Currently only manages the
 21  
  * 'initialsie', 'start', 'stop' and 'dispose' phases, not the connect phase which is
 22  
  * managed by the Retry handler
 23  
  *
 24  
  * @since 3.0
 25  
  */
 26  
 public class ConnectorLifecycleManager extends SimpleLifecycleManager<Connector>
 27  
 {
 28  
     public ConnectorLifecycleManager(AbstractConnector connector)
 29  
     {
 30  0
         super(connector.getName(), connector);
 31  0
     }
 32  
 
 33  
     @Override
 34  
     public void fireInitialisePhase(LifecycleCallback<Connector> callback) throws MuleException
 35  
     {
 36  0
         checkPhase(Initialisable.PHASE_NAME);
 37  
 
 38  0
         if (logger.isInfoEnabled())
 39  
         {
 40  0
             logger.info("Initialising connector: " + getLifecycleObject().getName());
 41  
         }
 42  
 
 43  
         // No pre notification
 44  0
         invokePhase(Initialisable.PHASE_NAME, getLifecycleObject(), callback);
 45  
         // No post notification
 46  0
     }
 47  
 
 48  
     @Override
 49  
     public void fireStartPhase(LifecycleCallback<Connector> callback) throws MuleException
 50  
     {
 51  0
         checkPhase(Startable.PHASE_NAME);
 52  
 
 53  0
         if (logger.isInfoEnabled())
 54  
         {
 55  0
             logger.info("Starting connector: " + getLifecycleObject().getName());
 56  
         }
 57  
 
 58  
         // No pre notification
 59  0
         invokePhase(Startable.PHASE_NAME, getLifecycleObject(), callback);
 60  
         // No post notification
 61  0
     }
 62  
 
 63  
     @Override
 64  
     public void fireStopPhase(LifecycleCallback<Connector> callback) throws MuleException
 65  
     {
 66  0
         checkPhase(Stoppable.PHASE_NAME);
 67  0
         if (logger.isInfoEnabled())
 68  
 
 69  
         {
 70  0
             logger.info("Stopping connector: " + getLifecycleObject().getName());
 71  
         }
 72  
 
 73  
         // No pre notification
 74  0
         invokePhase(Stoppable.PHASE_NAME, getLifecycleObject(), callback);
 75  
         // No post notification
 76  0
     }
 77  
 
 78  
     @Override
 79  
     public void fireDisposePhase(LifecycleCallback<Connector> callback) throws MuleException
 80  
     {
 81  0
         checkPhase(Disposable.PHASE_NAME);
 82  
 
 83  0
         if (logger.isInfoEnabled())
 84  
         {
 85  0
             logger.info("Disposing connector: " + getLifecycleObject().getName());
 86  
         }
 87  
 
 88  
         // No pre notification
 89  0
         invokePhase(Disposable.PHASE_NAME, getLifecycleObject(), callback);
 90  
         // No post notification
 91  0
     }
 92  
 
 93  
     protected void fireNotification(int action)
 94  
     {
 95  0
         getLifecycleObject().getMuleContext().fireNotification(
 96  
             new ConnectionNotification(getLifecycleObject(), getLifecycleObject().getName(), action));
 97  0
     }
 98  
 }