1 /* 2 * $Id: MuleContextDisposePhase.java 10489 2008-01-23 17:53:38Z 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.MuleException; 13 import org.mule.api.MuleContext; 14 import org.mule.api.lifecycle.Disposable; 15 import org.mule.api.lifecycle.Initialisable; 16 import org.mule.lifecycle.DefaultLifecyclePhase; 17 18 /** 19 * Objects are disposed of via the Registry since the Registry manages the creation/initialisation of the objects 20 * it must also take care of disposing them. However, a user may want to initiate a dispose via the 21 * {@link org.mule.DefaultMuleContext} so the dispose Lifecycle phase for the {@link org.mule.DefaultMuleContext} 22 * needs to call dispose on the Registry. 23 */ 24 public class MuleContextDisposePhase extends DefaultLifecyclePhase 25 { 26 public MuleContextDisposePhase() 27 { 28 super(Disposable.PHASE_NAME, Disposable.class, Initialisable.PHASE_NAME); 29 } 30 31 public void fireLifecycle(MuleContext muleContext, String currentPhase) throws MuleException 32 { 33 //Delegate this to the Registry 34 if (muleContext.getRegistry() != null) 35 { 36 muleContext.getRegistry().dispose(); 37 } 38 } 39 }