alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

/*
 *                 Sun Public License Notice
 * 
 * The contents of this file are subject to the Sun Public License
 * Version 1.0 (the "License"). You may not use this file except in
 * compliance with the License. A copy of the License is available at
 * http://www.sun.com/
 * 
 * The Original Code is NetBeans. The Initial Developer of the Original
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
 * Microsystems, Inc. All Rights Reserved.
 */

package org.openide;

import org.openide.util.Lookup;

/** Manages major aspects of the NetBeans lifecycle - currently saving all objects and exiting.
 * @author Jesse Glick
 * @since 3.14
 */
public abstract class LifecycleManager {

    /**
     * Get the default lifecycle manager.
     * Normally this is found in {@link Lookup#getDefault} but if no instance is
     * found there, a fallback instance is returned which behaves as follows:
     * 
    *
  1. {@link #saveAll} does nothing *
  2. {@link #exit} calls {@link System#exit} with an exit code of 0 *
* This is useful for unit tests and perhaps standalone library usage. * @return the default instance (never null) */ public static LifecycleManager getDefault() { LifecycleManager lm = (LifecycleManager) Lookup.getDefault().lookup(LifecycleManager.class); if (lm == null) { lm = new Trivial(); } return lm; } /** Subclass constructor. */ protected LifecycleManager() {} /** Save all opened objects. */ public abstract void saveAll(); /** Exit NetBeans. * This method will return only if {@link java.lang.System#exit} fails, or if at least one component of the * system refuses to exit (because it cannot be properly shut down). */ public abstract void exit(); /** Fallback instance. */ private static final class Trivial extends LifecycleManager { public Trivial() {} public void exit() { System.exit(0); } public void saveAll() {} } }
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.