当前位置: 首页>>代码示例>>Java>>正文


Java Server.getState方法代码示例

本文整理汇总了Java中org.apache.catalina.Server.getState方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getState方法的具体用法?Java Server.getState怎么用?Java Server.getState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.Server的用法示例。


在下文中一共展示了Server.getState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stop

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Stop an existing server instance.
 */
public void stop() {

    try {
        // Remove the ShutdownHook first so that server.stop()
        // doesn't get invoked twice
        if (useShutdownHook) {
            Runtime.getRuntime().removeShutdownHook(shutdownHook);

            // If JULI is being used, re-enable JULI's shutdown to ensure
            // log messages are not lost
            LogManager logManager = LogManager.getLogManager();
            if (logManager instanceof ClassLoaderLogManager) {
                ((ClassLoaderLogManager) logManager).setUseShutdownHook(
                        true);
            }
        }
    } catch (Throwable t) {
        ExceptionUtils.handleThrowable(t);
        // This will fail on JDK 1.2. Ignoring, as Tomcat can run
        // fine without the shutdown hook.
    }

    // Shut down the server
    try {
        Server s = getServer();
        LifecycleState state = s.getState();
        if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0
                && LifecycleState.DESTROYED.compareTo(state) >= 0) {
            // Nothing to do. stop() was already called
        } else {
            s.stop();
            s.destroy();
        }
    } catch (LifecycleException e) {
        log.error("Catalina.stop", e);
    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:Catalina.java

示例2: stop

import org.apache.catalina.Server; //导入方法依赖的package包/类
/**
 * Stop an existing server instance.
 */
public void stop() {

	try {
		// Remove the ShutdownHook first so that server.stop()
		// doesn't get invoked twice
		if (useShutdownHook) {
			Runtime.getRuntime().removeShutdownHook(shutdownHook);

			// If JULI is being used, re-enable JULI's shutdown to ensure
			// log messages are not lost
			LogManager logManager = LogManager.getLogManager();
			if (logManager instanceof ClassLoaderLogManager) {
				((ClassLoaderLogManager) logManager).setUseShutdownHook(true);
			}
		}
	} catch (Throwable t) {
		ExceptionUtils.handleThrowable(t);
		// This will fail on JDK 1.2. Ignoring, as Tomcat can run
		// fine without the shutdown hook.
	}

	// Shut down the server
	try {
		Server s = getServer();
		LifecycleState state = s.getState();
		if (LifecycleState.STOPPING_PREP.compareTo(state) <= 0 && LifecycleState.DESTROYED.compareTo(state) >= 0) {
			// Nothing to do. stop() was already called
		} else {
			s.stop();
			s.destroy();
		}
	} catch (LifecycleException e) {
		log.error("Catalina.stop", e);
	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:40,代码来源:Catalina.java


注:本文中的org.apache.catalina.Server.getState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。