001/* Perform cleanup.
002 * 
003 * Copyright (c) 2011 The Regents of the University of California.
004 * All rights reserved.
005 *
006 * '$Author: crawl $'
007 * '$Date: 2011-06-29 01:49:52 +0000 (Wed, 29 Jun 2011) $' 
008 * '$Revision: 27769 $'
009 * 
010 * Permission is hereby granted, without written agreement and without
011 * license or royalty fees, to use, copy, modify, and distribute this
012 * software and its documentation for any purpose, provided that the above
013 * copyright notice and the following two paragraphs appear in all copies
014 * of this software.
015 *
016 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
017 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
018 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
019 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
020 * SUCH DAMAGE.
021 *
022 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
023 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
024 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
025 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
026 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
027 * ENHANCEMENTS, OR MODIFICATIONS.
028 *
029 */
030package org.kepler.module.workflowrunmanager;
031
032import org.kepler.module.ModuleShutdownable;
033import org.kepler.util.ProvenanceStore;
034import org.kepler.workflowrunmanager.WRMDefaults;
035import org.kepler.workflowrunmanager.WorkflowRunManager;
036import org.kepler.workflowrunmanager.WorkflowRunManagerManager;
037
038import ptolemy.util.MessageHandler;
039
040/** A class to perform cleanup for the workflow run manager module.
041 * 
042 * @author Daniel Crawl
043 * @version $Id: Shutdown.java 27769 2011-06-29 01:49:52Z crawl $
044 */
045public class Shutdown implements ModuleShutdownable
046{
047    
048    /** Returns true if shutdownModule has been called. */
049    public static boolean haveShutdown()
050    {
051        return _haveShutdown;
052    }
053
054    /** Perform any module-specific cleanup. */
055    public void shutdownModule()
056    {
057        _haveShutdown = true;
058        
059        // disconnect from the workflowRunManager that was initialized
060        // in Initialize.
061        WorkflowRunManagerManager wrmm = WorkflowRunManagerManager.getInstance();
062        ProvenanceStore provenanceStore = new ProvenanceStore(WRMDefaults.provenanceDefaultsProperty);
063        WorkflowRunManager workflowRunManager = wrmm.getWRM(null, provenanceStore);
064        try {
065            workflowRunManager.disconnect();
066        } catch (Exception e) {
067            MessageHandler.error("Error disconnecting workflow run manager.", e);
068        }
069    }
070    
071    /** Set to true after shutdownModule is called. */
072    private static boolean _haveShutdown = false;
073}