View Javadoc

1   /*
2    * $Id: MuleContextStopPhase.java 11181 2008-03-05 17:31:34Z dfeist $
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  package org.mule.lifecycle.phases;
11  
12  import org.mule.api.MuleContext;
13  import org.mule.api.agent.Agent;
14  import org.mule.api.lifecycle.Initialisable;
15  import org.mule.api.lifecycle.Startable;
16  import org.mule.api.lifecycle.Stoppable;
17  import org.mule.api.model.Model;
18  import org.mule.api.registry.Registry;
19  import org.mule.api.service.Service;
20  import org.mule.api.transport.Connector;
21  import org.mule.context.notification.MuleContextNotification;
22  import org.mule.lifecycle.DefaultLifecyclePhase;
23  import org.mule.lifecycle.NotificationLifecycleObject;
24  
25  import java.util.LinkedHashSet;
26  import java.util.Set;
27  
28  /**
29   * The Stop phase for the Management context LifecycleManager. Calling {@link org.mule.api.UMOManagementContext#stop()}
30   * with initiate this phase via the {@link org.mule.api.lifecycle.LifecycleManager}.
31   * This phase controls the order in which objects should be stopped.
32   *
33   * @see org.mule.api.UMOManagementContext
34   * @see org.mule.api.lifecycle.LifecycleManager
35   * @see org.mule.api.lifecycle.Stoppable
36   */
37  public class MuleContextStopPhase extends DefaultLifecyclePhase
38  {
39      public MuleContextStopPhase()
40      {
41          this(new Class[]{Registry.class, MuleContext.class});
42      }
43  
44      public MuleContextStopPhase(Class[] ignorredObjects)
45      {
46          super(Stoppable.PHASE_NAME, Stoppable.class, Startable.PHASE_NAME);
47  
48          Set stopOrderedObjects = new LinkedHashSet();
49          stopOrderedObjects.add(new NotificationLifecycleObject(Connector.class));
50          stopOrderedObjects.add(new NotificationLifecycleObject(Agent.class));
51          stopOrderedObjects.add(new NotificationLifecycleObject(Model.class, MuleContextNotification.class,
52                  MuleContextNotification.CONTEXT_STOPPING_MODELS,MuleContextNotification.CONTEXT_STOPPED_MODELS));
53          stopOrderedObjects.add(new NotificationLifecycleObject(Service.class));
54          stopOrderedObjects.add(new NotificationLifecycleObject(Stoppable.class));
55  
56          setIgnoredObjectTypes(ignorredObjects);
57          setOrderedLifecycleObjects(stopOrderedObjects);
58          registerSupportedPhase(Startable.PHASE_NAME);
59          registerSupportedPhase(Initialisable.PHASE_NAME);
60      }
61  }