Coverage Report - org.mule.model.ModelLifecycleManager
 
Classes in this File Line Coverage Branch Coverage Complexity
ModelLifecycleManager
0%
0/24
0%
0/8
0
 
 1  
 /*
 2  
  * $Id: ModelLifecycleManager.java 19191 2010-08-25 21:05:23Z tcarlson $
 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  
 package org.mule.model;
 11  
 
 12  
 import org.mule.api.MuleException;
 13  
 import org.mule.api.lifecycle.Disposable;
 14  
 import org.mule.api.lifecycle.Initialisable;
 15  
 import org.mule.api.lifecycle.LifecycleCallback;
 16  
 import org.mule.api.lifecycle.Startable;
 17  
 import org.mule.api.lifecycle.Stoppable;
 18  
 import org.mule.context.notification.ModelNotification;
 19  
 import org.mule.lifecycle.SimpleLifecycleManager;
 20  
 
 21  
 /**
 22  
  * Handles Lifecycle transitions for {@link org.mule.api.model.Model} implementations
 23  
  */
 24  
 public class ModelLifecycleManager extends SimpleLifecycleManager<AbstractModel>
 25  
 {
 26  
     public ModelLifecycleManager(AbstractModel model)
 27  
     {
 28  0
         super(model.getName(), model);
 29  0
     }
 30  
 
 31  
     @Override
 32  
     public void fireInitialisePhase(LifecycleCallback<AbstractModel> callback) throws MuleException
 33  
     {
 34  0
         checkPhase(Initialisable.PHASE_NAME);
 35  
         //TODO No pre notification
 36  0
         if(logger.isInfoEnabled()) logger.info("Initialising model: " + getLifecycleObject().getName());
 37  0
         invokePhase(Initialisable.PHASE_NAME, getLifecycleObject(), callback);
 38  0
         fireNotification(ModelNotification.MODEL_INITIALISED);
 39  0
     }
 40  
 
 41  
     @Override
 42  
     public void fireStartPhase(LifecycleCallback<AbstractModel> callback) throws MuleException
 43  
     {
 44  0
         checkPhase(Startable.PHASE_NAME);
 45  
         //TODO No pre notification
 46  0
         if(logger.isInfoEnabled()) logger.info("Starting model: " + getLifecycleObject().getName());
 47  0
         invokePhase(Startable.PHASE_NAME, getLifecycleObject(), callback);
 48  0
         fireNotification(ModelNotification.MODEL_STARTED);
 49  0
     }
 50  
 
 51  
     @Override
 52  
     public void fireStopPhase(LifecycleCallback<AbstractModel> callback) throws MuleException
 53  
     {
 54  0
         checkPhase(Stoppable.PHASE_NAME);
 55  
         //TODO No pre notification
 56  0
         if(logger.isInfoEnabled()) logger.info("Stopping model: " + getLifecycleObject().getName());
 57  0
         invokePhase(Stoppable.PHASE_NAME, getLifecycleObject(), callback);
 58  0
         fireNotification(ModelNotification.MODEL_STOPPED);
 59  0
     }
 60  
 
 61  
     @Override
 62  
     public void fireDisposePhase(LifecycleCallback<AbstractModel> callback) throws MuleException
 63  
     {
 64  0
         checkPhase(Disposable.PHASE_NAME);
 65  
         //TODO No pre notification
 66  0
         if(logger.isInfoEnabled()) logger.info("Disposing model: " + getLifecycleObject().getName());
 67  0
         invokePhase(Disposable.PHASE_NAME, getLifecycleObject(), callback);
 68  0
         fireNotification(ModelNotification.MODEL_DISPOSED);
 69  0
     }
 70  
 
 71  
     void fireNotification(int action)
 72  
     {
 73  0
         getLifecycleObject().getMuleContext().fireNotification(new ModelNotification(getLifecycleObject(), action));
 74  0
     }
 75  
 }