Coverage Report - org.mule.lifecycle.phases.MuleContextStopPhase
 
Classes in this File Line Coverage Branch Coverage Complexity
MuleContextStopPhase
0%
0/15
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.phases;
 8  
 
 9  
 import org.mule.api.MuleContext;
 10  
 import org.mule.api.agent.Agent;
 11  
 import org.mule.api.component.Component;
 12  
 import org.mule.api.construct.FlowConstruct;
 13  
 import org.mule.api.lifecycle.Initialisable;
 14  
 import org.mule.api.lifecycle.Startable;
 15  
 import org.mule.api.lifecycle.Stoppable;
 16  
 import org.mule.api.model.Model;
 17  
 import org.mule.api.registry.Registry;
 18  
 import org.mule.api.routing.OutboundRouter;
 19  
 import org.mule.api.routing.OutboundRouterCollection;
 20  
 import org.mule.api.source.MessageSource;
 21  
 import org.mule.api.transport.Connector;
 22  
 import org.mule.context.notification.MuleContextNotification;
 23  
 import org.mule.lifecycle.LifecycleObject;
 24  
 import org.mule.lifecycle.NotificationLifecycleObject;
 25  
 import org.mule.util.queue.TransactionalQueueManager;
 26  
 
 27  
 import java.util.LinkedHashSet;
 28  
 import java.util.Set;
 29  
 
 30  
 /**
 31  
  * The Stop phase for the Management context LifecycleManager. Calling {@link MuleContext#stop()}
 32  
  * with initiate this phase via the {@link org.mule.api.lifecycle.LifecycleManager}.
 33  
  *
 34  
  *
 35  
  * The MuleContextDisposePhase defines the lifecycle behaviour when the Mule context is stopped.  The MuleContext is associated
 36  
  * with one or more registries that inherit the lifecycle of the MuleContext.
 37  
  *
 38  
  * This phase is responsible for disposing objects. Any object that implements {@link org.mule.api.lifecycle.Stoppable} will
 39  
  * have its {@link org.mule.api.lifecycle.Stoppable#stop()} ()} method called.  Objects are initialised in the order based on type:
 40  
  * {@link org.mule.api.service.Service}, {@link org.mule.api.model.Model}, {@link org.mule.api.agent.Agent}, {@link org.mule.api.transport.Connector}, followed
 41  
  * by any other object that implements {@link org.mule.api.lifecycle.Stoppable}.
 42  
  *
 43  
  * @see org.mule.api.MuleContext
 44  
  * @see org.mule.api.lifecycle.LifecycleManager
 45  
  * @see org.mule.api.lifecycle.Stoppable
 46  
  *
 47  
  * @since 3.0
 48  
  */
 49  
 public class MuleContextStopPhase extends DefaultLifecyclePhase
 50  
 {
 51  
     public MuleContextStopPhase()
 52  
     {
 53  0
         this(new Class[]{Registry.class, MuleContext.class, MessageSource.class, Component.class, OutboundRouterCollection.class, OutboundRouter.class});
 54  0
     }
 55  
 
 56  
     public MuleContextStopPhase(Class<?>[] ignorredObjects)
 57  
     {
 58  0
         super(Stoppable.PHASE_NAME, Stoppable.class, Startable.PHASE_NAME);
 59  
 
 60  0
         Set<LifecycleObject> stopOrderedObjects = new LinkedHashSet<LifecycleObject>();
 61  
         // Stop in the opposite order to start
 62  0
         stopOrderedObjects.add(new NotificationLifecycleObject(FlowConstruct.class));
 63  0
         stopOrderedObjects.add(new NotificationLifecycleObject(Model.class, MuleContextNotification.class));
 64  0
         stopOrderedObjects.add(new NotificationLifecycleObject(Agent.class));
 65  0
         stopOrderedObjects.add(new NotificationLifecycleObject(Connector.class));
 66  0
         stopOrderedObjects.add(new NotificationLifecycleObject(TransactionalQueueManager.class));
 67  0
         stopOrderedObjects.add(new NotificationLifecycleObject(Stoppable.class));
 68  
 
 69  0
         setIgnoredObjectTypes(ignorredObjects);
 70  0
         setOrderedLifecycleObjects(stopOrderedObjects);
 71  
         //Yuo can initialise and stop
 72  0
         registerSupportedPhase(Initialisable.PHASE_NAME);
 73  
         //Stop/Start/Stop
 74  0
         registerSupportedPhase(Startable.PHASE_NAME);
 75  0
     }
 76  
 }