當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。