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


Java Server.stop方法代码示例

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


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

示例1: main

import org.apache.catalina.Server; //导入方法依赖的package包/类
public static void main(String[] args) {
	Connector connector = new Connector();
	connector.setPort(80);
	Tomcat tomcat = new Tomcat();
	tomcat.setPort(80);
	tomcat.getService().addConnector(connector);
	tomcat.setConnector(connector);
	try {
		Context ctx = tomcat.addWebapp("", Conf.getAbsolutePath("../src/main/webapp"));
		WebResourceRoot resources = new StandardRoot(ctx);
		resources.addPreResources(new DirResourceSet(resources,
				"/WEB-INF/classes", Conf.getAbsolutePath("classes"), "/"));
		ctx.setResources(resources);

		Server server = tomcat.getServer();
		server.start();
		server.setPort(8005);
		server.await();
		server.stop();
	} catch (ServletException | LifecycleException e) {
		Log.e(e);
	}
}
 
开发者ID:xqbase,项目名称:metric,代码行数:24,代码来源:Startup.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:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:Catalina.java

示例3: 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

示例4: main

import org.apache.catalina.Server; //导入方法依赖的package包/类
public static void main(String[] args) {
	Connector connector = new Connector();
	connector.setPort(80);
	Tomcat tomcat = new Tomcat();
	tomcat.setPort(80);
	tomcat.getService().addConnector(connector);
	tomcat.setConnector(connector);
	try {
		Context ctx = tomcat.addWebapp("", Conf.getAbsolutePath("../src/main/webapp"));
		// Ensure to Load All Classes in the Same Class Loader
		ctx.setLoader(new WebappLoader(Startup.class.getClassLoader()) {
			@Override
			public ClassLoader getClassLoader() {
				return Startup.class.getClassLoader();
			}
		});
		WebResourceRoot resources = new StandardRoot(ctx);
		resources.addPreResources(new DirResourceSet(resources,
				"/WEB-INF/classes", Conf.getAbsolutePath("classes"), "/"));
		ctx.setResources(resources);

		Server server = tomcat.getServer();
		server.start();
		server.setPort(8005);
		server.await();
		server.stop();
	} catch (ServletException | LifecycleException e) {
		Log.e(e);
	}
}
 
开发者ID:xqbase,项目名称:metric,代码行数:31,代码来源:Startup.java


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