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