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


Java HandlerList.setHandlers方法代码示例

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


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

示例1: main

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        // Create a basic Jetty server object that will listen on port 8080
        Server server = new Server(8080);

        // Create the ResourceHandler. It is the object that will actually
        // handle the request for a given file. It is a Jetty Handler object
        // so it is suitable for chaining with other handlers as you will see
        // in other examples
        ResourceHandler resource_handler = new ResourceHandler();

        // Configure the ResourceHandler. Setting the resource base indicates
        // where the files should be served out of
        resource_handler.setDirectoriesListed(true);
        resource_handler.setWelcomeFiles(new String[]{ "index.html" });
        resource_handler.setResourceBase("src/main/webapp/");

        // Add the ResourceHandler to the server
        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[] { resource_handler, new DefaultHandler() });
        server.setHandler(handlers);

        // Start server
        server.start();
        server.join();
    }
 
开发者ID:biblelamp,项目名称:JavaEE,代码行数:27,代码来源:Main.java

示例2: prepare

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public void prepare() {
    try {
        Tools.verifyLocalPort("DBServer ", port());
        server = new Server();
        DefaultHandler webHandler = new DefaultHandler();
        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{getResourceHandler(),
            getUIWSHandler(), webHandler});

        ServerConnector connector = new ServerConnector(server);
        connector.setPort(port());
        server.setConnectors(new Connector[]{connector});
        server.setHandler(handlers);

        LOG.log(Level.INFO, "DB Server on : http://{0}:{1}",
                new Object[]{Tools.IP(), port() + ""});

    } catch (Exception ex) {
        LOG.log(Level.SEVERE, ex.getMessage(), ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:DashBoardServer.java

示例3: getAllServices

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
private HandlerList getAllServices() throws Exception{
    // File server & Context Handler for root, also setting the index.html
    // to be the "welcome file", i.e, autolink on root addresses.
    ContextHandler rootContext = new ContextHandler();
    rootContext.setContextPath("/*");
    rootContext.setHandler(getResourceHandlers());

    // Possible servlet lists, for all servlets or custom services you want to access later.
    // Warning, it might become a little bit nested if you add to many classes.
    ServletHandler questionHandler = new ServletHandler();
    questionHandler.addServletWithMapping(QuestionHandler.class, "/question");

    // Add the ResourceHandler to the server.
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {
            rootContext ,
            questionHandler,
    });

    return handlers;
}
 
开发者ID:Rebstorm,项目名称:paul0-application-server,代码行数:22,代码来源:HomeServerConfig.java

示例4: start

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
/**
 * Start the file server (blocking).
 *
 * @throws Exception If server cannot start
 */
public final void start() throws Exception {
    LOGGER.info("Starting web interface at http://localhost:8000");

    Server server = new Server(8000);

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(true);
    resource_handler.setWelcomeFiles(new String[]{"index.html"});
    resource_handler.setResourceBase("../website");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(
            new Handler[]{
                resource_handler,
                new DefaultHandler()});
    server.setHandler(handlers);

    server.start();
}
 
开发者ID:RUCD,项目名称:apt-graph,代码行数:25,代码来源:FileServer.java

示例5: run

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public void run(int port) throws Exception {
    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(true);
    resource_handler.setWelcomeFiles(new String[] { "index.html" });

    resource_handler.setResourceBase("./performance/site/");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { resource_handler,
            new DefaultHandler() });
    server.setHandler(handlers);

    server.start();
    System.out.println("Started performance file server at port: " + port);
    server.join();
}
 
开发者ID:wxyzZ,项目名称:little_mitm,代码行数:22,代码来源:PerformanceServer.java

示例6: main

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    AccountService accountService = new AccountService();

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.addServlet(new ServletHolder(new SingUpServlet(accountService)), "/signup");
    context.addServlet(new ServletHolder(new SignInServlet(accountService)), "/signin");

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setResourceBase("public_html");

    HandlerList handlers = new HandlerList();
    final Handler[] handler = {resource_handler, context};
    handlers.setHandlers(handler);

    Server server = new Server(8080);
    server.setHandler(handlers);

    server.start();
    System.out.println("Server started");
    server.join();
}
 
开发者ID:SvichkarevAnatoly,项目名称:stepic-java-web-service,代码行数:22,代码来源:Main.java

示例7: ConfigServer

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
@Inject
public ConfigServer(HBaseFrameworkConfig hbaseFrameworkConfig,
    IPersistentStateStore persistenceStore) {
  this.hbaseFrameworkConfig = hbaseFrameworkConfig;
  this.persistenceStore = persistenceStore;
  engine = new Engine();
  server = new Server(hbaseFrameworkConfig.getConfigServerPort());
  ResourceHandler resourceHandler = new ResourceHandler();
  resourceHandler.setResourceBase(hbaseFrameworkConfig.getExecutorPath());
  HandlerList handlers = new HandlerList();
  handlers.setHandlers(new Handler[]{
      resourceHandler, new ServeHbaseConfigHandler()});
  server.setHandler(handlers);

  try {
    server.start();

  } catch (Exception e) {
    final String msg = "Unable to start jetty server";
    log.error(msg, e);
    throw new ConfigServerException(msg, e);
  }
}
 
开发者ID:jan-zajic,项目名称:mesos-hbase,代码行数:24,代码来源:ConfigServer.java

示例8: main

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Server server = new Server(8080);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

    context.addServlet(new ServletHolder(new WebSocketChatServlet()), "/chat");

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(true);
    resource_handler.setResourceBase("public_html");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[]{resource_handler, context});
    server.setHandler(handlers);

    server.start();
    System.out.println("Server started!");
    server.join();
}
 
开发者ID:vitaly-chibrikov,项目名称:homework_tester,代码行数:19,代码来源:Main.java

示例9: main

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.out.append("Use port as the first argument");
        System.exit(1);
    }

    String portString = args[0];
    int port = Integer.valueOf(portString);
    System.out.append("Starting at port: ").append(portString).append('\n');

    Server server = new Server(port);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.addServlet(new ServletHolder(new AdminPageServlet()), AdminPageServlet.adminPageURL);

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(true);
    resource_handler.setResourceBase("static");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[]{resource_handler, context});
    server.setHandler(handlers);

    server.start();
    server.join();
}
 
开发者ID:vitaly-chibrikov,项目名称:tp_java_2015_02,代码行数:26,代码来源:Main.java

示例10: setup

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
private void setup(int port) {
    if (server == null) {
        server = new Server(port);
        ServletHandler servletHandler = new ServletHandler();
        webSocketServlet = new WebsocketOutboundServlet();
        ServletHolder holder = new ServletHolder(webSocketServlet);
        servletHandler.addServletWithMapping(holder, uri + URI_SUFFIX);

        ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setBaseResource(Resource.newClassPathResource("com/example/docroot/"));

        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{servletHandler, resourceHandler, new DefaultHandler()});
        server.setHandler(handlers);
        try {
            server.start();
            String url = "ws://localhost:" + port + uri;
            System.out.println(ImplMessages.getMessage("WS_SERVER_START_MSG", url));
            // add the shutdown hook
            Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdown()));
        } catch (Exception error) {
            System.out.println(ImplMessages.getMessage("INIT_FAILURE", getClass().getName(), error.getMessage()));
            error.printStackTrace();
        }
    }
}
 
开发者ID:Esri,项目名称:performance-test-harness-for-geoevent,代码行数:27,代码来源:WebsocketServerEventProducer.java

示例11: main

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    AccountService accountService = new AccountService();

    accountService.addNewUser(new UserProfile("admin"));
    accountService.addNewUser(new UserProfile("test"));

    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
    context.addServlet(new ServletHolder(new UsersServlet(accountService)), "/api/v1/users");
    context.addServlet(new ServletHolder(new SessionsServlet(accountService)), "/api/v1/sessions");

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setResourceBase("public_html");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[]{resource_handler, context});

    Server server = new Server(8080);
    server.setHandler(handlers);

    server.start();
    server.join();
}
 
开发者ID:vitaly-chibrikov,项目名称:stepic_java_webserver,代码行数:23,代码来源:Main.java

示例12: main

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Server server = new Server(8080);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);

    context.addServlet(new ServletHolder(new WebSocketChatServlet()), "/chat");

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(true);
    resource_handler.setResourceBase("public_html");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[]{resource_handler, context});
    server.setHandler(handlers);

    server.start();
    server.join();
}
 
开发者ID:vitaly-chibrikov,项目名称:stepic_java_webserver,代码行数:18,代码来源:Main.java

示例13: startServer

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
private static void startServer(String workingDir, List<String> specificWARs) throws Exception
{
    Server server = new Server(port);

    List<ContextHandler> warHandlers = createWarHandlers(workingDir, specificWARs);
    Handler indexHandler = createIndexContext(warHandlers);

    List<Handler> allHandlers = new ArrayList<Handler>();
    allHandlers.addAll(warHandlers);
    allHandlers.add(indexHandler);
    HandlerList handlerList = new HandlerList();
    handlerList.setHandlers(allHandlers.toArray(new Handler[]{}));
    server.setHandler(handlerList);

    server.start();

    info("\n##############################\n# Server up on port " + port + "!\n##############################");

    server.join();
}
 
开发者ID:adamcath,项目名称:nomcat,代码行数:21,代码来源:Main.java

示例14: ready

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
@Override
public void ready() throws Exception {
    server = new Server();

    http = new ServerConnector(server);
    http.setHost(HttpUtil.LOCALHOST);
    http.setPort(0);
    server.addConnector(http);

    BundledResourceHandler resourceHandler = new BundledResourceHandler();
    resourceHandler.setLoadingClass(getClass());
    resourceHandler.setResourceBase(Constants.OAUTH_RESOURCE_BASE);
    resourceHandler.setWelcomeFiles(ArrayUtils.toArray(Constants.OAUTH_DEFAULT_HTML));

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(ArrayUtils.toArray(this, resourceHandler, new DefaultHandler()));
    server.setHandler(handlers);

    server.start();
}
 
开发者ID:LTTPP,项目名称:Eemory,代码行数:21,代码来源:JettyCallback.java

示例15: JettyCrosServer

import org.eclipse.jetty.server.handler.HandlerList; //导入方法依赖的package包/类
public JettyCrosServer() throws Exception {
	server = new Server(80);
	HandlerList handlers = new HandlerList();
       ResourceHandler resource_handler = new ResourceHandler();
       resource_handler.setDirectoriesListed(true);
       resource_handler.setWelcomeFiles(new String[] { "index.html" });
       resource_handler.setBaseResource(Resource.newClassPathResource("web"));
	
       ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
       context.setContextPath("/");
       context.setInitParameter("maxInterval", "1000");
       context.setInitParameter("logLevel", "2");
               
       handlers.setHandlers(new Handler[] { resource_handler, context});
       
       server.setHandler(handlers);
       
       
       FilterHolder filterHolder = new FilterHolder(new CrossOriginFilter());
       filterHolder.getInitParameters().put(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Content-Type,Accept,Origin,Authorization");
       context.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class));
       
       context.addServlet(new ServletHolder(new JsonServlet()), "/t.json");
       context.addServlet(new ServletHolder(new DefaultServlet()), "/*");
       
}
 
开发者ID:y12studio,项目名称:bkbc-tools,代码行数:27,代码来源:JettyCrosServer.java


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