📄 wrappermanager.java
字号:
package org.tanukisoftware.wrapper;
/*
* Copyright (c) 1999, 2006 Tanuki Software Inc.
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of the Java Service Wrapper and associated
* documentation files (the "Software"), to deal in the Software
* without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sub-license,
* and/or sell copies of the Software, and to permit persons to
* whom the Software is furnished to do so, subject to the
* following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*
* Portions of the Software have been derived from source code
* developed by Silver Egg Technology under the following license:
*
* Copyright (c) 2001 Silver Egg Technology
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sub-license, and/or
* sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*/
// $Log: WrapperManager.java,v $
// Revision 1.78 2006/06/28 05:05:18 mortenson
// Removed the custom thread counting used to keep track of when the wrapped
// Java application has completed.
//
// Revision 1.77 2006/06/23 05:30:16 mortenson
// Simplify the code used to load a native library by using the
// System.mapLibraryName method rather than doing the same thing manually.
//
// Revision 1.76 2006/06/23 04:23:32 mortenson
// Correct 2 more locations where the 32-bit HP-UX extension was .so rather than .sl
//
// Revision 1.75 2006/06/19 14:45:46 mortenson
// Make it more obvious when the user code is calling System.exit from within the
// WrapperListener.stop method.
//
// Revision 1.74 2006/05/19 01:39:31 mortenson
// Add 'athlon' to the list of supported architectures.
//
// Revision 1.73 2006/05/17 07:35:59 mortenson
// Add support for debuggers and avoiding shutdowns caused by the wrapper.
// Fix some problems with disabled timers so they are now actually disabled.
//
// Revision 1.72 2006/05/17 03:11:47 mortenson
// Add support for registering the WrapperManager MBean with the
// PlatformMBeanServer when run on a 1.5+ JVM.
//
// Revision 1.71 2006/03/29 01:15:42 mortenson
// Modify the message shown when a native library fails to load so the
// exception message text is now shown in the log without having to enable
// debug log output.
//
// Revision 1.70 2006/02/28 15:52:48 mortenson
// Add support for MacOSX Universal Binary distributions.
//
// Revision 1.69 2006/02/24 05:45:57 mortenson
// Update the copyright.
//
// Revision 1.68 2006/02/15 06:04:51 mortenson
// Fix a problem where the Wrapper would show the following error message
// if user code called System.exit from within the WrapperListener.stop
// callback method.
//
// Revision 1.67 2006/02/03 06:40:07 mortenson
// Add support for Linux 64-bit PPC and Solaris 32-bit x86 versions.
//
// Revision 1.66 2006/02/03 06:18:50 mortenson
// More work getting things working for the 64-bit GNU gcj java implementation.
// When the bit depth of the JVM can not be determined, try both 32 and 64 bit
// libraries attempting to load one. This will work even if they both exist.
//
// Revision 1.65 2006/02/03 05:36:06 mortenson
// Add support for the GNU libjcj JVM. Like JRocket, it requires slightly
// different thread counting.
//
// Revision 1.64 2006/01/09 00:51:53 mortenson
// Fix a compiler problem with the last FreeBSD commit.
//
// Revision 1.63 2006/01/09 00:44:21 mortenson
// Fix a problem with the opening of the backend socket. FreeBSD uses a different
// exception to indicate that a port is in use.
//
// Revision 1.62 2006/01/07 03:27:11 mortenson
// Add a new wrapper.thread_count_delay property which will force the
// WrapperManager to wait the specified number of seconds before it begins
// to check the number of running threads.
//
// Revision 1.61 2005/12/21 07:15:17 mortenson
// Make it possible to have platform specific native libraries on the library path and
// then have them loaded correctly.
//
// Revision 1.60 2005/12/07 03:25:51 mortenson
// Fix a problem where the Windows ServiceManager was not correctly reporting
// a startup error if a service failed on startup. The service was being
// reported as having started even though it failed to start.
//
// Revision 1.59 2005/12/07 02:42:57 mortenson
// Display the Wrapper banner in the JVM earlier so that it is displayed
// even where there are startup errors.
//
// Revision 1.58 2005/11/24 03:22:03 mortenson
// Add a new wrapper.monitor_thread_count property which makes it possible to
// disable the Wrapper's counting of non-daemon threads and thus the shutting
// down of the JVM when they have all completed.
//
// Revision 1.57 2005/11/18 08:07:48 mortenson
// Improve the message when the native library can not be loaded to make mention
// of the possibility of a 32/64 bit mismatch.
//
// Revision 1.56 2005/10/13 06:10:51 mortenson
// Implement the ability to catch control events using the WrapperEventLisener.
// Make it possible to configure the port used by the Java end of the back end
// socket.
//
// Revision 1.55 2005/08/24 06:53:39 mortenson
// Add stopAndReturn and restartAndReturn methods.
//
// Revision 1.54 2005/06/24 16:00:39 mortenson
// Add a security model to protect the Wrapper and many of its calls when a
// ServiceManager has been registered with the JVM.
//
// Revision 1.53 2005/05/07 01:34:42 mortenson
// Add a new wrapper.commandfile property which can be used by external
// applications to control the Wrapper and its JVM.
//
// Revision 1.52 2005/03/24 06:26:52 mortenson
// Avoid displaying the packets used to transmit the wrapper properties in the log
// file as it is very large and distracting.
// Add a new WrapperSystemPropertyUtil class to avoid code duplication.
//
// Revision 1.51 2004/12/16 14:13:47 mortenson
// Fix a problem where TERM signals were not being correctly ignored by the JVM
// process on UNIX platforms even if wrapper.ignore_signals was set.
//
// Revision 1.50 2004/12/08 04:54:33 mortenson
// Make it possible to access the contents of the Wrapper configuration file from
// within the JVM.
//
// Revision 1.49 2004/11/29 14:26:52 mortenson
// Add javadocs.
//
// Revision 1.48 2004/11/29 13:15:39 mortenson
// Fix some javadocs problems.
//
// Revision 1.47 2004/11/26 08:41:25 mortenson
// Implement reading from System.in
//
// Revision 1.46 2004/11/22 09:35:47 mortenson
// Add methods for controlling other services.
//
// Revision 1.45 2004/11/22 04:06:44 mortenson
// Add an event model to make it possible to communicate with user applications in
// a more flexible way.
//
// Revision 1.44 2004/11/19 03:39:43 mortenson
// Be more consistent with synchronization in the WrapperManager class.
//
// Revision 1.43 2004/11/15 08:15:50 mortenson
// Make it possible for users to access the Wrapper and JVM PIDs from within the JVM.
//
// Revision 1.42 2004/08/31 14:34:28 mortenson
// Fix a problem where the JVM would restart at certain times when using the
// system time based timer due to an overflow error.
//
// Revision 1.41 2004/08/18 08:36:04 mortenson
// Change the DEFAULT_CPU_TIMEOUT constant to an int so the declaration in the
// jni header file is the same on all platforms. It was causing headaches with cvs
// merges. No functional change.
//
// Revision 1.40 2004/08/06 07:26:09 mortenson
// Modify the way boolean system properties are resolved by the WrapperManager
// so it is now possible to set them to true or false rather than assuming they
// are true if set.
//
// Revision 1.39 2004/06/30 09:02:33 mortenson
// Remove unused imports.
//
// Revision 1.38 2004/06/15 07:09:44 mortenson
// Fix a problem where the tick age was not being calculated correctly when the
// age was negative.
//
// Revision 1.37 2004/06/15 05:26:57 mortenson
// Fix a problem where the Wrapper would sometimes hang on shutdown if
// another thread called System.exit while the Wrapper was shutting down.
// Bug #955248.
//
// Revision 1.36 2004/05/24 09:24:34 mortenson
// Fix a problem introduced in 3.1.0 where the JVM would not be restarted
// correctly if it quit after a ping timeout to let the Wrapper resynch and
// restart it.
//
// Revision 1.35 2004/03/29 02:42:10 mortenson
// Modify the way calls to System.in.read() are handled so that they now block
// rather than throwing an exception.
//
// Revision 1.34 2004/03/20 16:55:50 mortenson
// Add an adviser feature to help cut down on support requests from new users.
//
// Revision 1.33 2004/03/18 07:40:43 mortenson
// Fix a problem where unwanted read timeout messages were being displayed when
// the ping interval was set to a large value.
//
// Revision 1.32 2004/03/10 14:06:52 mortenson
// Add some additional debug output to make it easier to debug startup,
// shutdown and restart problems.
//
// Revision 1.31 2004/01/24 17:46:30 mortenson
// The addition of the getInteractiveUser placed a dependency on Windows NT
// version 5.0. Work around this so the Wrapper can still be used on NT 4.0.
//
// Revision 1.30 2004/01/16 04:42:00 mortenson
// The license was revised for this version to include a copyright omission.
// This change is to be retroactively applied to all versions of the Java
// Service Wrapper starting with version 3.0.0.
//
// Revision 1.29 2004/01/10 16:45:30 mortenson
// Add a way to get information about the currently logged in user.
//
// Revision 1.28 2004/01/09 05:15:11 mortenson
// Implement a tick timer and convert the system time over to be compatible.
//
// Revision 1.27 2004/01/01 12:51:54 mortenson
// Requesting the groups of a user is a fairly heavy operation on Windows, so make
// the requesting of a users groups optional.
//
// Revision 1.26 2003/11/05 16:45:43 mortenson
// The WrapperManager class now checks to make sure that its current version
// matches the version of the native library and Wrapper.
//
// Revision 1.25 2003/11/02 20:55:05 mortenson
// Add some javadocs.
// Remove code that was just checked in so it can be used later if ever needed.
//
// Revision 1.24 2003/11/02 20:29:30 mortenson
// Add the ability to get information about the user account which is running the
// Wrapper as well as the user account with which the Wrapper is interacting.
//
// Revision 1.23 2003/10/31 17:30:52 mortenson
// Add some additional debug output to help identify the cause of problems
// loading the native library.
//
// Revision 1.22 2003/10/31 10:57:53 mortenson
// Fix a problem where CTRL-C was being ignored by the WrapperManager if a
// WrapperListener is never registered.
//
// Revision 1.21 2003/10/31 05:59:34 mortenson
// Added a new method, setConsoleTitle, to the WrapperManager class which
// enables the application to dynamically set the console title.
//
// Revision 1.20 2003/10/18 08:11:16 mortenson
// Modify the WrapperManager class so it now stores references to System.out
// and System.err on initialization and always writes to those stored streams.
//
// Revision 1.19 2003/10/12 18:59:06 mortenson
// Add a new property, wrapper.native_library, which can be used to specify
// the base name of the native library.
//
// Revision 1.18 2003/10/12 18:01:52 mortenson
// Back out some changes which made the WrapperManager look for the native
// library by using the OS/arch as keys. I want to solve that problem a different
// way.
//
// Revision 1.17 2003/09/12 04:03:52 mortenson
// Make it possible to load the native library using files named after the platform
// and architecture.
//
// Revision 1.16 2003/09/04 05:40:08 mortenson
// Added a new wrapper.ping.interval property which lets users control the
// frequency that the Wrapper pings the JVM.
//
// Revision 1.15 2003/09/03 14:39:58 mortenson
// Added a pair of MBean interfaces which allow the Wrapper to be controlled
// using JMX. See the new JMX section in the documentation for details.
//
// Revision 1.14 2003/09/03 09:26:26 mortenson
// Modify the WrapperManager.isLaunchedAsService() method on UNIX systems so it
// now returns true if the Wrapper was launched with the wrapper.daemonize flag
// set.
//
// Revision 1.13 2003/09/03 02:33:38 mortenson
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -