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


Java HandlerCollection.setHandlers方法代码示例

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


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

示例1: initServer

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private static void initServer(Properties properties) throws Exception {
    Integer port = Integer.valueOf(properties.getProperty("server.port"));
    String host = properties.getProperty("server.host");

    Integer clientId = Integer.valueOf(properties.getProperty("client.id"));
    String clientSecret = properties.getProperty("client.secret");

    HandlerCollection handlers = new HandlerCollection();

    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setDirectoriesListed(true);
    resourceHandler.setWelcomeFiles(new String[]{"index.html"});
    resourceHandler.setResourceBase(Application.class.getResource("/static").getPath());

    VkApiClient vk = new VkApiClient(new HttpTransportClient());
    handlers.setHandlers(new Handler[]{resourceHandler, new RequestHandler(vk, clientId, clientSecret, host)});

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

    server.start();
    server.join();
}
 
开发者ID:VKCOM,项目名称:vk-java-sdk,代码行数:24,代码来源:Application.java

示例2: startServer

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public static void startServer(String[] args) throws Exception {
	Server server = new Server(8080);
	
	WebAppContext ctx = new WebAppContext();
	ctx.setContextPath("/");
	ctx.setWar("src/main/webapp/");
	HandlerCollection hc = new HandlerCollection();
	hc.setHandlers(new Handler[] {ctx});
	
	server.setHandler(hc);
	server.setStopAtShutdown(true);
	server.start();
	
	server.join();
	
	// server.removeBean(o);
	// server.addBean(o);
}
 
开发者ID:ForJ-Latech,项目名称:fwm,代码行数:19,代码来源:ScratchPad.java

示例3: start

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

示例4: start

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

示例5: start

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

示例6: main

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

示例7: Olingo2SampleServer

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

示例8: customizeServer

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Override
public void customizeServer(Server server) {
    if(logFile != null) {
    HandlerCollection rootHandler = (HandlerCollection) server.getHandler();

    List<Handler> handlers = new ArrayList<Handler>();

    handlers.addAll(Arrays.asList(rootHandler.getHandlers()));

    RequestLogHandler requestLogHandler = new RequestLogHandler();

    NCSARequestLog requestLog = new NCSARequestLog(logFile.getAbsolutePath());
    requestLog.setRetainDays(0);
    requestLog.setAppend(true);
    requestLog.setExtended(extended);
    requestLog.setLogTimeZone("GMT");
    requestLogHandler.setRequestLog(requestLog);

    handlers.add(requestLogHandler);

    rootHandler.setHandlers(handlers.toArray(new Handler[handlers.size()]));

    }
}
 
开发者ID:eirbjo,项目名称:jetty-console,代码行数:25,代码来源:RequestLogPlugin.java

示例9: main

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

示例10: createHandlers

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private static HandlerCollection createHandlers(
        final GatewayConfig config,
        final GatewayServices services,
        final ContextHandlerCollection contexts) {
    HandlerCollection handlers = new HandlerCollection();
    RequestLogHandler logHandler = new RequestLogHandler();
    logHandler.setRequestLog(new AccessHandler());

    TraceHandler traceHandler = new TraceHandler();
    traceHandler.setHandler(contexts);
    traceHandler.setTracedBodyFilter(System.getProperty("org.apache.knox.gateway.trace.body.status.filter"));

    CorrelationHandler correlationHandler = new CorrelationHandler();
    correlationHandler.setHandler(traceHandler);

    DefaultTopologyHandler defaultTopoHandler = new DefaultTopologyHandler(config, services, contexts);

    handlers.setHandlers(new Handler[]{correlationHandler, defaultTopoHandler, logHandler});
    return handlers;
}
 
开发者ID:sakserv,项目名称:hadoop-mini-clusters,代码行数:21,代码来源:GatewayServer.java

示例11: registerHandlers

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
/**
 * Hook up Jetty handlers.  Do this before start() is called.
 */
public void registerHandlers(HandlerWrapper s) {
  GateHandler gh = new GateHandler();
  AddCommonResponseHeadersHandler rhh = new AddCommonResponseHeadersHandler();
  ExtensionHandler1 eh1 = new ExtensionHandler1();

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

  context.addServlet(H2oNpsBinServlet.class,   "/3/NodePersistentStorage.bin/*");
  context.addServlet(H2oPostFileServlet.class, "/3/PostFile.bin");
  context.addServlet(H2oPostFileServlet.class, "/3/PostFile");
  context.addServlet(H2oDatasetServlet.class,   "/3/DownloadDataset");
  context.addServlet(H2oDatasetServlet.class,   "/3/DownloadDataset.bin");
  context.addServlet(H2oDefaultServlet.class,  "/");

  Handler[] handlers = {gh, rhh, eh1, context};
  HandlerCollection hc = new HandlerCollection();
  hc.setHandlers(handlers);
  s.setHandler(hc);
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:26,代码来源:JettyHTTPD.java

示例12: configureRedirectionRules

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private Handler configureRedirectionRules(Handler appHandler) {
  RewriteHandler handler = new RewriteHandler();
  handler.setRewriteRequestURI(false);
  handler.setRewritePathInfo(false);
  handler.setOriginalPathAttribute("requestedPath");

  RewriteRegexRule uiRewriteRule = new RewriteRegexRule();
  uiRewriteRule.setRegex("^/collector/.*");
  uiRewriteRule.setReplacement("/");
  handler.addRule(uiRewriteRule);
  handler.setHandler(appHandler);

  HandlerCollection handlerCollection = new HandlerCollection();
  handlerCollection.setHandlers(new Handler[] {handler, appHandler});
  return handlerCollection;
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:17,代码来源:WebServerTask.java

示例13: registerHandlers

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Override
protected void registerHandlers(HandlerWrapper handlerWrapper, ServletContextHandler context) {
  // setup authenticating proxy servlet (each request is forwarded with BASIC AUTH)
  ServletHolder proxyServlet = new ServletHolder(Transparent.class);
  proxyServlet.setInitParameter("ProxyTo", _proxyTo);
  proxyServlet.setInitParameter("Prefix", "/");
  proxyServlet.setInitParameter("BasicAuth", _credentials.toBasicAuth());
  context.addServlet(proxyServlet, "/*");
  // authHandlers assume the user is already authenticated
  HandlerCollection authHandlers = new HandlerCollection();
  authHandlers.setHandlers(new Handler[]{
          new AuthenticationHandler(),
          context,
  });
  // handles requests of login form and delegates the rest to the authHandlers
  LoginHandler loginHandler = new LoginHandler("/login", "/loginError");
  loginHandler.setHandler(authHandlers);
  // login handler is the root handler
  handlerWrapper.setHandler(loginHandler);
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:21,代码来源:JettyProxy.java

示例14: startServer

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

  WebAppContext pentahoContext = new WebAppContext();
  pentahoContext.setClassLoader(getClass().getClassLoader());
  pentahoContext.setContextPath("/pentaho"); //$NON-NLS-1$
  pentahoContext.setWar(webappsFolder + "/pentaho"); //$NON-NLS-1$
  
  pentahoContext.setParentLoaderPriority(true);
  
  HandlerCollection handlers= new HandlerCollection();
  handlers.setHandlers(new Handler[]{pentahoContext, new DefaultHandler()});

  server.setHandler(handlers);

  // Start execution
  createListeners();

  server.start();
}
 
开发者ID:pentaho,项目名称:pdi-agile-bi-plugin,代码行数:21,代码来源:JettyServer.java

示例15: startServer

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
public void startServer() throws Exception {
    Server server = new Server(this.port);
    final HandlerCollection handlers = new HandlerCollection();
    handlers.setHandlers(new Handler[] {
        new SideloadHandler(
            this.imageStore,
            this.store,
            this.fingerprintSizeLarge,
            this.fingerprintSizeSmall),
        new ImageHandler(
            this.imageStore,
            this.cacheDir
        )
    });
    server.setHandler(handlers);
    server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", -1);
    server.start();
    server.join();
}
 
开发者ID:metric-collective,项目名称:imagine,代码行数:20,代码来源:ImageServer.java


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