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


Java HttpServer.shutdownNow方法代码示例

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


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

示例1: main

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
public static void main(String[] args) throws IllegalArgumentException,
		NullPointerException, IOException {
	HttpServer server = getServer();
	Connection.init();
	try {
		StringBuffer sb = new StringBuffer();
		sb.append("Server started\n");
		sb.append("WADL at " + BASE_URI + "application.wadl\n");
		sb.append("Press enter to stop the server...\n");
		System.out.println(sb);
		System.in.read();
	} finally {
		Connection.shutdown();
		server.shutdownNow();
	}
}
 
开发者ID:markusstocker,项目名称:emrooz,代码行数:17,代码来源:EmroozServer.java

示例2: main

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {

	final UserRepository users = UserRepository.getInstance(true);
	
	/* wait for shutdown ... */
	HttpServer httpServer = createServer();
	System.out.println(String.format(
		"Jersey app started with WADL available at "
		+ "%sapplication.wadl\nHit enter to stop it...",BASE_URI));

	// System.out.println("Hit <return> to stop server...");
	System.in.read();
	httpServer.shutdownNow();

	/* save state */
	users.freeze();
}
 
开发者ID:thenewcircle,项目名称:class_3647,代码行数:18,代码来源:Server.java

示例3: main

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
/**
 * Main method.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
	    	
	// Start server and wait for user input to stop
    final HttpServer server = startServer();
    
    try {
        server.start();
        System.out.println(String.format("Jersey app started with WADL available at " + "%sapplication.wadl\n", BASE_URI));
        // Wait forever (i.e. until the JVM instance is terminated externally)
        Thread.currentThread().join();
    } catch (Exception ioe) {
        System.out.println("Error running Luzzu Communications service: " + ioe.toString());
    } finally {
    	if(server != null && server.isStarted()) {
    		server.shutdownNow();
    	}
    }
}
 
开发者ID:EIS-Bonn,项目名称:Luzzu,代码行数:24,代码来源:Main.java

示例4: start

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
public void start() throws Exception {
    HttpServer server = GrizzlyWebContainerFactory.create(URI.create(url));
    WebappContext webapp = new WebappContext("GrizzlyContext", context);
    if (servlet == null) {
        servlet = DummyServlet.class;
    }
    if (servlet != null) {
        registerServlet(webapp);
    }
    if (filter != null) {
        registerFilter(webapp);
    }
    if (listener != null) {
        registerListener(webapp);
    }
    webapp.deploy(server);
    
    System.out.println(String.format("Jersey application started at %s\nHit enter to stop it...", url));
    System.in.read();
    server.shutdownNow();
}
 
开发者ID:trautonen,项目名称:jersey-mustache,代码行数:22,代码来源:GrizzlyServerBuilder.java

示例5: testSimple

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
@Test
public void testSimple()
{
    try
    {
        System.out.println("\"Hello World\" Jersey Example App");

        final ResourceConfig resourceConfig = new ResourceConfig(HiApp.class);
        final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig);

        System.out.println(String.format("Application started.\nTry out %s%s\nHit enter to stop it...",
                BASE_URI, ROOT_PATH));
        System.in.read();
        server.shutdownNow();
    } catch (IOException ex)
    {
        Logger.getLogger(TelletsLauncher.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
开发者ID:wenerme,项目名称:tellets,代码行数:21,代码来源:TelletsLauncher.java

示例6: main

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
/**
 * Starts a standalone conversion server. Detailed documentation can be retrieved by invoking
 * the application via the command line with the {@code -?} option.
 *
 * @param args The parameters for configuring this server.
 */
public static void main(String[] args) {
    try {
        ConverterServerBuilder builder = asBuilder(args);
        HttpServer httpServer = builder.build();
        Logger logger = LoggerFactory.getLogger(StandaloneServer.class);
        try {
            sayHello(builder, logger);
            System.out.println("The documents4j server is up and running. Hit the enter key to shut it down...");
            if (System.in.read() == -1) {
                logger.warn("Console read terminated without receiving user input");
            }
            sayGoodbye(builder, logger);
        } finally {
            httpServer.shutdownNow();
        }
        System.out.println("Shut down successful. Goodbye!");
    } catch (Exception e) {
        LoggerFactory.getLogger(StandaloneServer.class).error("The documents4j server terminated with an unexpected error", e);
        System.err.println(String.format("Error: %s", e.getMessage()));
        System.err.println("Use option -? to display a list of legal commands.");
        System.exit(-1);
    }
}
 
开发者ID:documents4j,项目名称:documents4j,代码行数:30,代码来源:StandaloneServer.java

示例7: main

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
/**
 * Main method.
 * @param args command line arguments
 * @throws IOException Stops if I/O problem
 */
public static void main(String[] args) throws IOException {
    if (Connexion.getInstance().getDbConnection() != null) {

        final HttpServer server = startServer();
        System.out.println(String.format("Jersey app started with WADL available at "
                + "%sapplication.wadl\nHit enter to stop it...", getBaseUri()));
        System.in.read();
        server.shutdownNow();
    } else {
        System.err.println("Unable to connect to DB");
    }
}
 
开发者ID:javathought,项目名称:devoxx-2017,代码行数:18,代码来源:Main.java

示例8: main

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
    final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, new JerseyApplication());

    System.out.println("Press any key to close");
    System.in.read();
    server.shutdownNow();
}
 
开发者ID:katharsis-project,项目名称:katharsis-framework,代码行数:8,代码来源:App.java

示例9: main

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
/**
 * Main method.
 * @param args
 * @throws IOException
 */
public static void main(String[] args) throws IOException {
    String port = "8080";
    if(args.length > 0 ){
        port = args[0];
    }

    final HttpServer server = startServer(port);
    System.out.println(String.format("Jersey app started with WADL available at "
            + "%sapplication.wadl\nHit enter to stop it...", uri));
    System.in.read();
    server.shutdownNow();
}
 
开发者ID:qa82,项目名称:analyzer,代码行数:18,代码来源:Main.java

示例10: main

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
public static void main(String[] args) {
    try {

        final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, false);

        // Creating a webapp context for the resources / DI container
        final WebappContext webappContext = new WebappContext("Widow analyze");

        webappContext.addListener(new WidowAnalyzeServletContextListener());

        ServletRegistration servletRegistration = webappContext.addServlet("ServletContainer", ServletContainer.class);
        servletRegistration.addMapping("/REST/*");
        servletRegistration.setInitParameter("javax.ws.rs.Application",
                "com.widowcrawler.analyze.startup.WidowAnalyzeResourceConfig");

        final FilterRegistration registration = webappContext.addFilter("GuiceFilter", GuiceFilter.class);
        registration.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), "/REST/*");

        webappContext.deploy(server);

        // static assets
        CLStaticHttpHandler clStaticHttpHandler = new CLStaticHttpHandler(
                Main.class.getClassLoader(),
                "/", "/lib/", "/js/", "/css/", "/templates/");
        server.getServerConfiguration().addHttpHandler(clStaticHttpHandler);

        server.start();

        System.out.println(String.format("Application started.\nTry out %s%s\nHit enter to stop it...",
                BASE_URI, ROOT_PATH));

        while(System.in.read() != 32);

        server.shutdownNow();
    } catch (Exception ex) {
        logger.error("Error: " + ex.getMessage(), ex);
    }
}
 
开发者ID:ScottMansfield,项目名称:widow,代码行数:39,代码来源:Main.java

示例11: testStartup

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
@Test(timeout = TIMEOUT)
public void testStartup() throws Exception {
    PortAssert.assertPortFree(port);
    HttpServer httpServer = ConverterServerBuilder.builder()
            .disable(MicrosoftWordBridge.class)
            .disable(MicrosoftExcelBridge.class)
            .enable(PseudoConverter.class)
            .baseUri(String.format("http://localhost:%d", port))
            .build();
    PortAssert.assertPortBusy(port);
    httpServer.shutdownNow();
    PortAssert.assertPortFree(port);
}
 
开发者ID:documents4j,项目名称:documents4j,代码行数:14,代码来源:ConverterServerBuilderTest.java

示例12: startEmbeddedServer

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
static void startEmbeddedServer() throws IOException {

		// Create test web application context.
		WebappContext webappContext = new WebappContext("Test Context");
		webappContext
		.addContextInitParameter("contextClass",
				"org.springframework.web.context.support.XmlWebApplicationContext");
		webappContext.addContextInitParameter("contextConfigLocation",
				"classpath*:spring-context.xml");
		webappContext
		.addListener("org.springframework.web.context.ContextLoaderListener");

		// Create a servlet registration for the web application in order to wire up Spring managed collaborators to Jersey resources.
		ServletRegistration servletRegistration = webappContext.addServlet(
				"jersey-servlet", ServletContainer.class);

		// The logging filters for server logging.
		servletRegistration
		.setInitParameter(
				"com.sun.jersey.spi.container.ContainerResponseFilters",
				"com.sun.jersey.api.container.filter.LoggingFilter");
		servletRegistration.setInitParameter(
				"com.sun.jersey.spi.container.ContainerRequestFilters",
				"com.sun.jersey.api.container.filter.LoggingFilter");

		servletRegistration.setInitParameter("javax.ws.rs.Application",
				"com.test.MyDemoApplication");

		servletRegistration.setInitParameter(
				"com.sun.jersey.config.property.packages", "com.test");
		servletRegistration.setInitParameter(
				"com.sun.jersey.api.json.POJOMappingFeature", "true");
		servletRegistration.addMapping("/*");

		HttpServer server = new HttpServer();
		NetworkListener listener = new NetworkListener("grizzly2", "localhost",
				3388);
		server.addListener(listener);

		webappContext.deploy(server);

		try {
			server.start();
			System.out.println("Press enter to stop the server...");
			System.in.read();
		} finally {
			server.shutdownNow();
		}
	}
 
开发者ID:janusdn,项目名称:jersey2-spring4-grizzly2,代码行数:50,代码来源:Start.java

示例13: loadMasterList

import org.glassfish.grizzly.http.server.HttpServer; //导入方法依赖的package包/类
@Test
public void loadMasterList() {
    System.setProperty(CONFIG_PATH, CONFIG_DIR);
    System.setProperty(DDS_CONFIG_FILE_ARGNAME, DEFAULT_DDS_FILE);

    // Initialize the Spring context to load our dependencies.
    SpringContext sc = SpringContext.getInstance();
    ApplicationContext context = sc.initContext("src/test/resources/config/AgoleManifestReaderTest.xml");
    AgoleManifestReader reader = (AgoleManifestReader) context.getBean("agoleManifestReader");
    reader.setTarget("http://localhost:8401/www/master.xml");

    HttpServer server = GrizzlyHttpServerFactory.createHttpServer(URI.create("http://localhost:8401"));
    StaticHttpHandler staticHttpHandler = new StaticHttpHandler("src/test/resources/config/www/");
    server.getServerConfiguration().addHttpHandler(staticHttpHandler, "/www");

    try {
        server.start();

        // Retrieve a copy of the centralized master topology list.
        TopologyManifest master = reader.getManifest();

        assertTrue(master != null);

        System.out.println("Master id: " + master.getId() + ", version=" + master.getVersion());

        // Test to see if the Netherlight entry is present.
        assertTrue(master.getTopologyURL("urn:ogf:network:netherlight.net:2013:topology:a-gole:testbed") != null);

        // We should not see a change in version.
        master = reader.getManifestIfModified();

        assertTrue(master == null);
    }
    catch (IOException | NotFoundException | JAXBException ex) {
        System.err.println("Failed to load master topology list from: " + reader.getTarget());
        ex.printStackTrace();
        fail();
    }
    finally {
        server.shutdownNow();
    }
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:43,代码来源:AgoleManifestReaderTest.java


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