CVS: jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends CLIMain.java,1.18,1.19 CLISetup.java,1.7,1.8 Resources.properties,1.3,1.4

Peter Donald <pdonald-yCVjj/[email protected]> Sun, 2 Nov 2003 23:52:15 -0600
Newsgroups gmane.comp.java.jcontainer.cvs
Message-ID <[email protected]>
Update of /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends
In directory hogshead.codehaus.org:/tmp/cvs-serv20695/engine/src/java/org/jcontainer/loom/frontends

Modified Files:
	CLIMain.java CLISetup.java Resources.properties 
Log Message:
Migrate functionality of shutdown hook back into the launcher


Index: CLIMain.java
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends/CLIMain.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- CLIMain.java	3 Nov 2003 05:12:33 -0000	1.18
+++ CLIMain.java	3 Nov 2003 05:52:13 -0000	1.19
@@ -126,7 +126,6 @@
 
     static final String HOME_DIR = File.class.getName() + "/home";
     static final String PERSISTENT = Boolean.class.getName() + "/persistent";
-    static final String DISABLE_HOOK = "disable-hook";
     static final String CONFIGFILE = "loom.configfile";
 
     private static final String DEFAULT_LOG_FILE =
@@ -145,8 +144,6 @@
     ///The code to return to system using exit code
     private int m_exitCode;
 
-    private ShutdownHook m_hook;
-
     private boolean m_shuttingDown;
     private Logger m_logger;
 
@@ -225,14 +222,6 @@
             return;
         }
 
-        final boolean disableHook =
-            properties.getProperty( DISABLE_HOOK, "false" ).equals( "true" );
-        if( false == disableHook )
-        {
-            m_hook = new ShutdownHook( this );
-            Runtime.getRuntime().addShutdownHook( m_hook );
-        }
-
         // If an Observer is present in the data object, then add it as an observer for
         //  m_observable
         Observer observer = (Observer)data.get( Observer.class.getName() );
@@ -265,10 +254,6 @@
         }
         finally
         {
-            if( null != m_hook )
-            {
-                Runtime.getRuntime().removeShutdownHook( m_hook );
-            }
             shutdown();
         }
     }
@@ -350,33 +335,6 @@
 
     /**
      * Shut the embeddor down.
-     * This method is designed to only be called from within the ShutdownHook.
-     * To shutdown Pheonix, call shutdown() below.
-     */
-    protected void forceShutdown()
-    {
-        if( null == m_hook || null == m_embeddor )
-        {
-            //We were shutdown gracefully but the shutdown hook
-            //thread was not removed. This can occur when an earlier
-            //shutdown hook caused a shutdown() request to be processed
-            return;
-        }
-
-        final String message = REZ.getString( "main.abnormal-exit.notice" );
-        if( null != m_logger )
-        {
-            m_logger.info( message );
-        }
-        System.out.print( message );
-        System.out.print( " " );
-        System.out.flush();
-
-        shutdown();
-    }
-
-    /**
-     * Shut the embeddor down.
      *
      * Note must be public so that the Frontend can
      * shut it down via reflection.
@@ -390,11 +348,6 @@
         {
             m_shuttingDown = true;
 
-            //Null hook so it is not tried to be removed
-            //when we are shutting down. (Attempting to remove
-            //hook during shutdown raises an exception).
-            m_hook = null;
-
             if( null != m_embeddor )
             {
                 final String message = REZ.getString( "main.exit.notice" );
@@ -445,24 +398,5 @@
         System.out.println( REZ.getString( "main.exception.footer" ) );
 
         m_exitCode = 1;
-    }
-}
-
-final class ShutdownHook
-    extends Thread
-{
-    private final CLIMain m_main;
-
-    protected ShutdownHook( final CLIMain main )
-    {
-        m_main = main;
-    }
-
-    /**
-     * Run the shutdown hook.
-     */
-    public void run()
-    {
-        m_main.forceShutdown();
     }
 }

Index: CLISetup.java
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends/CLISetup.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- CLISetup.java	29 Oct 2003 22:46:17 -0000	1.7
+++ CLISetup.java	3 Nov 2003 05:52:13 -0000	1.8
@@ -111,7 +111,6 @@
     private static final int LOG_FILE_OPT = 'l';
     private static final int PERSISTENT_OPT = 'p';
     private static final int CONFIGFILE_OPT = 'f';
-    private static final int DISABLE_HOOK_OPT = 2;
 
     ///Parameters created by parsing CLI options
     private final Properties m_parameters = new Properties();
@@ -139,7 +138,7 @@
      */
     private CLOptionDescriptor[] createCLOptions()
     {
-        final CLOptionDescriptor options[] = new CLOptionDescriptor[ 6 ];
+        final CLOptionDescriptor options[] = new CLOptionDescriptor[ 5 ];
         options[ 0 ] =
             new CLOptionDescriptor( "help",
                                     CLOptionDescriptor.ARGUMENT_DISALLOWED,
@@ -156,16 +155,11 @@
                                     DEBUG_LOG_OPT,
                                     REZ.getString( "cli.opt.debug-init.desc" ) );
         options[ 3 ] =
-            new CLOptionDescriptor( "disable-hook",
-                                    CLOptionDescriptor.ARGUMENT_DISALLOWED,
-                                    DISABLE_HOOK_OPT,
-                                    REZ.getString( "cli.opt.disable-hook.desc" ) );
-        options[ 4 ] =
             new CLOptionDescriptor( "persistent",
                                     CLOptionDescriptor.ARGUMENT_DISALLOWED,
                                     PERSISTENT_OPT,
                                     REZ.getString( "cli.opt.persistent.desc" ) );
-        options[ 5 ] =
+        options[ 4 ] =
             new CLOptionDescriptor( "configfile",
                                     CLOptionDescriptor.ARGUMENT_REQUIRED,
                                     CONFIGFILE_OPT,
@@ -221,10 +215,6 @@
 
                 case PERSISTENT_OPT:
                     m_parameters.setProperty( CLIMain.PERSISTENT, "true" );
-                    break;
-
-                case DISABLE_HOOK_OPT:
-                    m_parameters.setProperty( CLIMain.DISABLE_HOOK, "true" );
                     break;
 
                 case CONFIGFILE_OPT:

Index: Resources.properties
===================================================================
RCS file: /cvsroot/jcontainer/jcontainer/loom/engine/src/java/org/jcontainer/loom/frontends/Resources.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Resources.properties	24 Jul 2003 09:35:17 -0000	1.3
+++ Resources.properties	3 Nov 2003 05:52:13 -0000	1.4
@@ -1,10 +1,6 @@
 cli.opt.help.desc=Display this help.
 cli.opt.log-file.desc=The name of log file.
-cli.opt.apps-path.desc=The path to the apps/ directory that contains .sar files.
 cli.opt.debug-init.desc=Use this option to specify enable debug initialisation logs.
-cli.opt.remote-manager.desc=Start the Remote Manager Agent.
-cli.opt.application.desc=Start the Application specified by path.
-cli.opt.disable-hook.desc=Disable the Shutdown hook for JVM. Disabling this may mean that your application is not shutdown cleanly.
 cli.opt.persistent.desc=If specified the Embeddor will persist even after all applications have been removed from the kernel.
 cli.opt.configfile.desc=If specified Loom will use this configfile.
 
@@ -13,10 +9,6 @@
 cli.error.unknown.arg=Error: Unknown argument ({0}).
 cli.error.parser=Error: {0}.
 
-servlet.error.execute=Fail to execute Embeddor.
-servlet.error.load=Embeddor not loaded.
-
 main.exception.header=There was an uncaught exception:
 main.exception.footer=The log file may contain further details of error.\nPlease check the configuration files and restart Loom.\nIf the problem persists, contact the JContainer project.  See\nhttp://loom.jcontainer.org/ for more information.
-main.abnormal-exit.notice=JVM exiting abnormally.
 main.exit.notice=Shutting down Loom.