01: /*
02: * $Id: MuleContextStopPhase.java 11181 2008-03-05 17:31:34Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
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: public MuleContextStopPhase() {
39: this (new Class[] { Registry.class, MuleContext.class });
40: }
41:
42: public MuleContextStopPhase(Class[] ignorredObjects) {
43: super (Stoppable.PHASE_NAME, Stoppable.class,
44: Startable.PHASE_NAME);
45:
46: Set stopOrderedObjects = new LinkedHashSet();
47: stopOrderedObjects.add(new NotificationLifecycleObject(
48: Connector.class));
49: stopOrderedObjects.add(new NotificationLifecycleObject(
50: Agent.class));
51: stopOrderedObjects.add(new NotificationLifecycleObject(
52: Model.class, MuleContextNotification.class,
53: MuleContextNotification.CONTEXT_STOPPING_MODELS,
54: MuleContextNotification.CONTEXT_STOPPED_MODELS));
55: stopOrderedObjects.add(new NotificationLifecycleObject(
56: Service.class));
57: stopOrderedObjects.add(new NotificationLifecycleObject(
58: Stoppable.class));
59:
60: setIgnoredObjectTypes(ignorredObjects);
61: setOrderedLifecycleObjects(stopOrderedObjects);
62: registerSupportedPhase(Startable.PHASE_NAME);
63: registerSupportedPhase(Initialisable.PHASE_NAME);
64: }
65: }
|