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