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


Java DefaultHandler类代码示例

本文整理汇总了Java中org.eclipse.jetty.server.handler.DefaultHandler的典型用法代码示例。如果您正苦于以下问题:Java DefaultHandler类的具体用法?Java DefaultHandler怎么用?Java DefaultHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: startWebSocket

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
/**
 * start server
 * 
 * @param port
 * @param path
 * @param handlerClass
 */
public static void startWebSocket(int port, String path, String handlerClass) {
	try {
		Server server = new Server(port);
		HandlerList handlerList = new HandlerList();
		ServletContextHandler context = new ServletContextHandler(
				ServletContextHandler.SESSIONS);
		context.setContextPath("/");
		context.addServlet(new ServletHolder(new Jwservlet(handlerClass)),
				path);
		handlerList.addHandler(context);
		handlerList.addHandler(new DefaultHandler());
		server.setHandler(handlerList);
		server.start();
		server.join();
	} catch (Exception e) {
		e.printStackTrace();
		LogUtil.LOG("start websocket server error:" + e.getMessage(),
				LogLev.ERROR, WebSocketServer.class);
		System.exit(1);
	}
}
 
开发者ID:Sunature,项目名称:websocket,代码行数:29,代码来源:WebSocketServer.java

示例2: main

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的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

示例3: prepare

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的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

示例4: start

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public void start() throws Exception {
    RequestLogHandler requestLogHandler = new RequestLogHandler();
    Slf4jRequestLog requestLog = new Slf4jRequestLog();
    requestLog.setExtended(true);
    requestLog.setLogTimeZone(TimeZone.getDefault().getID());
    requestLog.setLogLatency(true);
    requestLogHandler.setRequestLog(requestLog);
    handlers.add(0, new ContextHandlerCollection());
    handlers.add(requestLogHandler);

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));

    HandlerCollection handlerCollection = new HandlerCollection();
    handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
    server.setHandler(handlerCollection);

    server.start();

    log.info("Server started at end point {}", getServiceUri());
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:22,代码来源:ServerManager.java

示例5: start

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public void start() throws PulsarServerException {
    log.info("Starting web socket proxy at port {}", conf.getWebServicePort());
    try {
        RequestLogHandler requestLogHandler = new RequestLogHandler();
        Slf4jRequestLog requestLog = new Slf4jRequestLog();
        requestLog.setExtended(true);
        requestLog.setLogTimeZone(TimeZone.getDefault().getID());
        requestLog.setLogLatency(true);
        requestLogHandler.setRequestLog(requestLog);
        handlers.add(0, new ContextHandlerCollection());
        handlers.add(requestLogHandler);

        ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));

        HandlerCollection handlerCollection = new HandlerCollection();
        handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
        server.setHandler(handlerCollection);

        server.start();
    } catch (Exception e) {
        throw new PulsarServerException(e);
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:25,代码来源:ProxyServer.java

示例6: start

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public void start() throws PulsarServerException {
    try {
        RequestLogHandler requestLogHandler = new RequestLogHandler();
        Slf4jRequestLog requestLog = new Slf4jRequestLog();
        requestLog.setExtended(true);
        requestLog.setLogTimeZone(TimeZone.getDefault().getID());
        requestLog.setLogLatency(true);
        requestLogHandler.setRequestLog(requestLog);
        handlers.add(0, new ContextHandlerCollection());
        handlers.add(requestLogHandler);

        ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(handlers.toArray(new Handler[handlers.size()]));

        HandlerCollection handlerCollection = new HandlerCollection();
        handlerCollection.setHandlers(new Handler[] { contexts, new DefaultHandler(), requestLogHandler });
        server.setHandler(handlerCollection);

        server.start();

        log.info("Web Service started at {}", pulsar.getWebServiceAddress());
    } catch (Exception e) {
        throw new PulsarServerException(e);
    }
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:26,代码来源:WebService.java

示例7: start

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的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

示例8: run

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的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

示例9: main

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

    WebAppContext webappcontext = new WebAppContext( "src/main/webapp", "/jaxrs" );

    ContextHandlerCollection servlet_contexts = new ContextHandlerCollection();
    webappcontext.setClassLoader( Thread.currentThread().getContextClassLoader() );
    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers( new Handler[] { servlet_contexts, webappcontext, new DefaultHandler() } );

    server.setHandler( handlers );


    server.start();
    server.join();
}
 
开发者ID:DistX,项目名称:Learning,代码行数:19,代码来源:EmbeddedServer.java

示例10: Olingo2SampleServer

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
/**
 * 
 * @param port
 * @param resourcePath
 */
public Olingo2SampleServer(int port, String resourcePath) {
    this.port = port;
    server = new org.eclipse.jetty.server.Server(port);

    WebAppContext webappcontext = new WebAppContext();
    String contextPath = null;
    try {
        contextPath = Olingo2SampleServer.class.getResource(resourcePath).toURI().getPath();
    } catch (URISyntaxException e) {
        LOG.error("Unable to read the resource at {}", resourcePath, e);
    }
    webappcontext.setContextPath("/");

    webappcontext.setWar(contextPath);

    HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
    server.setHandler(handlers);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:Olingo2SampleServer.java

示例11: main

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	URI baseUri = UriBuilder.fromUri("http://localhost").port(SERVER_PORT)
			.build();
	ResourceConfig config = new ResourceConfig(Calculator.class);
	Server server = JettyHttpContainerFactory.createServer(baseUri, config,
			false);

	ContextHandler contextHandler = new ContextHandler("/rest");
	contextHandler.setHandler(server.getHandler());
	
	ProtectionDomain protectionDomain = EmbeddedServer.class
			.getProtectionDomain();
	URL location = protectionDomain.getCodeSource().getLocation();
	
	ResourceHandler resourceHandler = new ResourceHandler();
	resourceHandler.setWelcomeFiles(new String[] { "index.html" });
	resourceHandler.setResourceBase(location.toExternalForm());
	System.out.println(location.toExternalForm());
	HandlerCollection handlerCollection = new HandlerCollection();
	handlerCollection.setHandlers(new Handler[] { resourceHandler,
			contextHandler, new DefaultHandler() });
	server.setHandler(handlerCollection);
	server.start();
	server.join();
}
 
开发者ID:AlanHohn,项目名称:jaxrs,代码行数:26,代码来源:EmbeddedServer.java

示例12: setup

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的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

示例13: setup

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
private void setup(int port) {
    if (server == null) {
        server = new Server(port);
        ServletHandler servletHandler = new ServletHandler();
        webSocketServlet = new WebsocketOutboundServlet(message -> receive(message));
        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,代码来源:WebsocketServerEventConsumer.java

示例14: configure

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
@Override
protected void configure(ServerBuilder sb) throws Exception {
    sb.port(0, SessionProtocol.HTTP);
    sb.port(0, SessionProtocol.HTTPS);
    sb.sslContext(SessionProtocol.HTTPS,
                  certificate.certificateFile(),
                  certificate.privateKeyFile());

    sb.serviceUnder(
            "/jsp/",
            new JettyServiceBuilder()
                    .handler(newWebAppContext())
                    .configurator(s -> jettyBeans.addAll(s.getBeans()))
                    .build()
                    .decorate(LoggingService.newDecorator()));

    sb.serviceUnder(
            "/default/",
            new JettyServiceBuilder().handler(new DefaultHandler()).build());

    final ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setResourceBase(webAppRoot().getPath());
    sb.serviceUnder(
            "/resources/",
            new JettyServiceBuilder().handler(resourceHandler).build());
}
 
开发者ID:line,项目名称:armeria,代码行数:27,代码来源:JettyServiceTest.java

示例15: UIWebServer

import org.eclipse.jetty.server.handler.DefaultHandler; //导入依赖的package包/类
/**
 * Constructor that pairs urls with servlets and sets the webapp folder.
 * 
 * @param serverName
 *          Name of the server
 * @param address
 *          Address of the server
 * @param masterInfo
 *          MasterInfo for the tachyon filesystem this UIWebServer supports
 * @return A new UIWebServer
 */
public UIWebServer(String serverName, InetSocketAddress address, MasterInfo masterInfo) {
  mAddress = address;
  mServerName = serverName;
  mServer = new Server(mAddress);

  WebAppContext webappcontext = new WebAppContext();

  webappcontext.setContextPath(Constants.PATH_SEPARATOR);
  File warPath = new File(CommonConf.get().WEB_RESOURCES);
  webappcontext.setWar(warPath.getAbsolutePath());
  HandlerList handlers = new HandlerList();
  webappcontext.addServlet(new ServletHolder(new WebInterfaceGeneralServlet(masterInfo)),
      "/home");
  webappcontext.addServlet(new ServletHolder(new WebInterfaceConfigurationServlet(masterInfo)),
      "/configuration");
  webappcontext.addServlet(new ServletHolder(new WebInterfaceBrowseServlet(masterInfo)),
      "/browse");
  webappcontext.addServlet(new ServletHolder(new WebInterfaceMemoryServlet(masterInfo)),
      "/memory");
  webappcontext.addServlet(new ServletHolder(new WebInterfaceDependencyServlet(masterInfo)),
      "/dependency");

  handlers.setHandlers(new Handler[] { webappcontext, new DefaultHandler() });
  mServer.setHandler(handlers);
}
 
开发者ID:mtunique,项目名称:tachyon-rdma,代码行数:37,代码来源:UIWebServer.java


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