當前位置: 首頁>>代碼示例>>Java>>正文


Java Server.destroy方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.server.Server.destroy方法的典型用法代碼示例。如果您正苦於以下問題:Java Server.destroy方法的具體用法?Java Server.destroy怎麽用?Java Server.destroy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.server.Server的用法示例。


在下文中一共展示了Server.destroy方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {

        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");

        Server jettyServer = new Server(8067);
        jettyServer.setHandler(context);

        ServletHolder jerseyServlet = context.addServlet(
                org.glassfish.jersey.servlet.ServletContainer.class, "/*");
        jerseyServlet.setInitOrder(0);

        // Tells the Jersey Servlet which REST service/class to load.
        jerseyServlet.setInitParameter(
                "jersey.config.server.provider.classnames",
                EntryPointTestHandler.class.getCanonicalName());

        try {
            jettyServer.start();
            jettyServer.join();
        } finally {
            jettyServer.destroy();
        }
    }
 
開發者ID:warlock-china,項目名稱:wisp,代碼行數:25,代碼來源:ServerMain.java

示例2: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
/**
 * Start expose storr rest API via jetty server
 *
 * The following parameters are allowed:
 * - port (default port is 9998)
 * - store path
 *
 * Example:
 * port=9998 path=~/storr/
 *
 * @param args
 * @throws Exception if the server or storr could not be launched successfully
 */
public static void main(String[] args) throws Exception {

    HashMap<String, String> map = makeMap(args);
    if (map.containsKey("port")) {
        serverPort = Integer.parseInt(map.get("port"));
    }

    Path store_path;
    if (map.containsKey("path")) {
        store_path = Paths.get(map.get("path").replaceFirst("^~",System.getProperty("user.home")));
        File path = new File(store_path.toString());
        path.mkdirs();
    } else {
        store_path = Files.createTempDirectory(null);
    }

    System.out.println("Store will be created in path " + store_path);
    System.out.println("REST API documentation available at localhost:" + serverPort +
            "/swagger.json OR localhost:" + serverPort + "/swagger.yaml");

    IStore store = new Store(store_path);

    final Server server = StartServer(store);

    try {
        server.start();
        server.join();
    } finally {
        server.destroy();
    }

}
 
開發者ID:stacs-srg,項目名稱:storr,代碼行數:46,代碼來源:JettyApp.java

示例3: startJetty

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void startJetty() throws Exception {
        // Jetty 起動
        HandlerList handlers = new HandlerList();

        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        ServletHolder servletHolder = context.addServlet(ServletContainer.class, "/*");
        servletHolder.setInitOrder(0);
        servletHolder.setInitParameter(
                "com.sun.jersey.spi.container.ContainerResponseFilters",
                "com.sun.jersey.api.container.filter.GZIPContentEncodingFilter");

        // Pasaran API
        RestAPIs.installRestApi(servletHolder,
                CORSResponseFilter.class,
                KeseranApi.class);

        // 靜的コンテンツ
        ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setResourceBase("web");
        handlers.addHandler(resourceHandler);
        handlers.addHandler(context);

        String port = System.getProperty("jetty-port", "2510");
        Server jetty = new Server(Integer.parseInt(port));
        jetty.setHandler(handlers);
        try {
//            RolloverFileOutputStream os = new RolloverFileOutputStream("logs/yyyy_mm_dd_jetty.log", true);
//            PrintStream logStream = new PrintStream(os);
//            System.setOut(logStream);
//            System.setErr(logStream);
//            Log.getRootLogger().info("JCG Embedded Jetty logging started.", new Object[]{});

            jetty.start();
            jetty.join();
        } finally {
            jetty.destroy();
        }
    }
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:40,代碼來源:App.java

示例4: main

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    int port = getPort(args);
    Path configDir = getConfigDir(args);
    System.out.println("Configuring MNP storage from config directory: "+configDir);

    Builder builder = Builder.builder();
    storage = builder.
            add(new RossvyazMasksParser(configDir.resolve("rossvyaz/Kody_DEF-9kh.csv"))).
            add(new CustomMasksParser(configDir.resolve("mnos.xml"))).
            //add(new ZniisMnpParser(configDir.resolve("zniis/"))).
            idTitle(configDir.resolve("filters/titles.xml")).
            idRegion(configDir.resolve("filters/areas.xml")).
            build();
    System.out.println("Starting server on port: "+port);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.setContextPath("/");
    Server jettyServer = new Server(port);

    jettyServer.setHandler(context);
    ServletHolder jerseyServlet = context.addServlet(
            org.glassfish.jersey.servlet.ServletContainer.class, "/*");
    jerseyServlet.setInitOrder(0);
    jerseyServlet.setInitParameter(
            "jersey.config.server.provider.classnames",
            MnpApi.class.getCanonicalName());
    try {
        jettyServer.start();
        System.out.println("Server started. Example request: http://localhost:"+port+"/mnp?subscriber=79139367911");
        jettyServer.join();
    } finally {
        jettyServer.destroy();
    }
}
 
開發者ID:chukanov,項目名稱:mnp,代碼行數:34,代碼來源:RestServer.java

示例5: startTheControllerServer

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
/**
 * Start the controller as a RESTful server.
 * Use the setters of this class to change the default
 * port and host.
 * <br>
 * This method is blocking until the server is initialized.
 */
public final boolean startTheControllerServer() {

    //Jersey
    ResourceConfig config = new ResourceConfig();
    config.register(JacksonFeature.class);
    config.register(new EMController(this));
    config.register(LoggingFeature.class);

    //Jetty
    controllerServer = new Server(InetSocketAddress.createUnresolved(
            getControllerHost(), getControllerPort()));

    ErrorHandler errorHandler = new ErrorHandler();
    errorHandler.setShowStacks(true);
    controllerServer.setErrorHandler(errorHandler);

    ServletHolder servlet = new ServletHolder(new ServletContainer(config));

    ServletContextHandler context = new ServletContextHandler(controllerServer,
            ControllerConstants.BASE_PATH + "/*");
    context.addServlet(servlet, "/*");


    try {
        controllerServer.start();
    } catch (Exception e) {
        SimpleLogger.error("Failed to start Jetty: " + e.getMessage());
        controllerServer.destroy();
    }

    //just make sure we start from a clean state
    newSearch();

    SimpleLogger.info("Started controller server on: " + controllerServer.getURI());

    return true;
}
 
開發者ID:EMResearch,項目名稱:EvoMaster,代碼行數:45,代碼來源:SutController.java

示例6: startJetty

import org.eclipse.jetty.server.Server; //導入方法依賴的package包/類
/**
 * Naef Rest API を起動する
 */
public static void startJetty() {
    HandlerList handlers = new HandlerList();

    // naef api
    ServletContextHandler naefApiHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
    naefApiHandler.setContextPath(NaefRestApi.APPLICATION_PATH);
    ServletHolder naefServletHolder = naefApiHandler.addServlet(ServletContainer.class, "/*");
    naefServletHolder.setInitOrder(0);
    naefServletHolder.setInitParameter(PARAMETER_NAME, NaefRestApi.class.getName());
    handlers.addHandler(naefApiHandler);

    // swagger
    ResourceHandler swagger = new ResourceHandler();
    swagger.setResourceBase("swagger-ui");
    swagger.setDirectoriesListed(false);
    ContextHandler swaggerHandler = new ContextHandler("/swagger");
    swaggerHandler.setHandler(swagger);
    handlers.addHandler(swaggerHandler);

    // keseran
    ResourceHandler keseran = new ResourceHandler();
    keseran.setResourceBase("keseran");
    keseran.setDirectoriesListed(false);
    ContextHandler keseranHandler = new ContextHandler("/keseran");
    keseranHandler.setHandler(keseran);
    handlers.addHandler(keseranHandler);

    // pasaran
    ServletContextHandler pasaran = new ServletContextHandler(ServletContextHandler.SESSIONS);
    pasaran.setContextPath("/");
    handlers.addHandler(pasaran);
    ServletHolder servletHolder = pasaran.addServlet(ServletContainer.class, "/*");
    servletHolder.setInitOrder(0);
    RestAPIs.installRestApi(servletHolder,
            CORSResponseFilter.class,
            KeseranApi.class);

    String port = System.getProperty("jetty-port", "2510");
    Server jetty = new Server(Integer.parseInt(port));
    jetty.setHandler(handlers);
    try {
        jetty.start();
        jetty.join();
    } catch (Exception e) {
        log.error("jetty error", e);
        e.printStackTrace();
    } finally {
        jetty.destroy();
    }
}
 
開發者ID:openNaEF,項目名稱:openNaEF,代碼行數:54,代碼來源:App.java


注:本文中的org.eclipse.jetty.server.Server.destroy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。