Coverage Report - org.mule.lifecycle.SimpleLifecycleManager
 
Classes in this File Line Coverage Branch Coverage Complexity
SimpleLifecycleManager
0%
0/12
N/A
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.lifecycle;
 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.LifecycleException;
 14  
 import org.mule.api.lifecycle.Startable;
 15  
 import org.mule.api.lifecycle.Stoppable;
 16  
 import org.mule.lifecycle.phases.NotInLifecyclePhase;
 17  
 
 18  
 /**
 19  
  * This {@link org.mule.api.lifecycle.LifecycleManager} implementation is designed to track the lifecycle of objects
 20  
  * that support the {@link org.mule.api.lifecycle.Initialisable#PHASE_NAME}, {@link org.mule.api.lifecycle.Startable#PHASE_NAME},
 21  
  * {@link org.mule.api.lifecycle.Stoppable#PHASE_NAME} and {@link org.mule.api.lifecycle.Disposable#PHASE_NAME} phases and
 22  
  * adds convenience methods for firing these phases by callbacks.  
 23  
  * 
 24  
  * This is an internal class used by Mule for managing state for objects such as {@link org.mule.api.service.Service},
 25  
  * {@link org.mule.api.transport.Connector} and {@link org.mule.api.agent.Agent}, all of which can be controlled externally via JMX
 26  
  * @param <O> the object type being managed by this {@link org.mule.api.lifecycle.LifecycleManager}
 27  
  */
 28  
 public abstract class SimpleLifecycleManager<O> extends AbstractLifecycleManager<O>
 29  
 {
 30  
     public SimpleLifecycleManager(String id, O object)
 31  
     {
 32  0
         super(id, object);
 33  0
     }
 34  
 
 35  
     @Override
 36  
     protected void registerTransitions()
 37  
     {
 38  
         //init dispose
 39  0
         addDirectTransition(NotInLifecyclePhase.PHASE_NAME, Initialisable.PHASE_NAME);
 40  0
         addDirectTransition(NotInLifecyclePhase.PHASE_NAME, Disposable.PHASE_NAME);
 41  0
         addDirectTransition(Initialisable.PHASE_NAME, Startable.PHASE_NAME);
 42  
 
 43  
         //If an object fails to start, the object can be left in an initialise state, but the container can be started
 44  0
         addDirectTransition(Initialisable.PHASE_NAME, Stoppable.PHASE_NAME);
 45  0
         addDirectTransition(Initialisable.PHASE_NAME, Disposable.PHASE_NAME);
 46  
 
 47  
         //start stop
 48  0
         addDirectTransition(Startable.PHASE_NAME, Stoppable.PHASE_NAME);
 49  0
         addDirectTransition(Stoppable.PHASE_NAME, Startable.PHASE_NAME);
 50  0
         addDirectTransition(Stoppable.PHASE_NAME, Disposable.PHASE_NAME);
 51  0
     }
 52  
 
 53  
     public void fireLifecycle(String phase) throws LifecycleException
 54  
     {
 55  0
         throw new UnsupportedOperationException("SimpleLifecycleManager.fireLifecycle");
 56  
     }
 57  
 
 58  
     public abstract void fireInitialisePhase(LifecycleCallback<O> callback) throws MuleException;
 59  
 
 60  
     public abstract void fireStartPhase(LifecycleCallback<O> callback) throws MuleException;
 61  
 
 62  
     public abstract void fireStopPhase(LifecycleCallback<O> callback) throws MuleException;
 63  
 
 64  
     public abstract void fireDisposePhase(LifecycleCallback<O> callback) throws MuleException;
 65  
 }