当前位置: 首页>>代码示例>>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;未经允许,请勿转载。