View Javadoc

1   /*
2    * $Id: TransientRegistryInitialisePhase.java 10808 2008-02-14 20:36:57Z acooke $
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.endpoint.ImmutableEndpoint;
15  import org.mule.api.lifecycle.Disposable;
16  import org.mule.api.lifecycle.Initialisable;
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.transformer.Transformer;
21  import org.mule.api.transport.Connector;
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 Initialise phase for the TransientRegistry LifecycleManager. Calling {@link org.mule.registry.TransientRegistry#initialise()}
30   * with initiate this phase via the {@link org.mule.api.lifecycle.LifecycleManager}.
31   * This phase controls the order in which objects should be initialised.
32   *
33   * @see org.mule.api.MuleContext
34   * @see org.mule.api.lifecycle.LifecycleManager
35   * @see org.mule.registry.TransientRegistry
36   * @see org.mule.api.lifecycle.Initialisable
37   */
38  public class TransientRegistryInitialisePhase extends DefaultLifecyclePhase
39  {
40      public TransientRegistryInitialisePhase()
41      {
42          this(new Class[]{Registry.class});
43      }
44  
45      public TransientRegistryInitialisePhase(Class[] ignorredObjects)
46      {
47          super(Initialisable.PHASE_NAME, Initialisable.class, Disposable.PHASE_NAME);
48  
49          setIgnoredObjectTypes(ignorredObjects);
50          Set initOrderedObjects = new LinkedHashSet();
51          initOrderedObjects.add(new NotificationLifecycleObject(MuleContext.class));
52          initOrderedObjects.add(new NotificationLifecycleObject(Connector.class));
53          initOrderedObjects.add(new NotificationLifecycleObject(Transformer.class));
54          initOrderedObjects.add(new NotificationLifecycleObject(ImmutableEndpoint.class));
55          initOrderedObjects.add(new NotificationLifecycleObject(Agent.class));
56          initOrderedObjects.add(new NotificationLifecycleObject(Service.class));
57          initOrderedObjects.add(new NotificationLifecycleObject(Model.class));
58  
59          initOrderedObjects.add(new NotificationLifecycleObject(Initialisable.class));
60  
61          setOrderedLifecycleObjects(initOrderedObjects);
62          registerSupportedPhase(NotInLifecyclePhase.PHASE_NAME);
63      }
64  }