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


Java ContextHandlerCollection.setHandlers方法代码示例

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


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

示例1: beforeClass

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
@BeforeClass
public static void beforeClass() throws Exception {
	ccowServer = new Server(serverPort);

	final CCOWContextListener c = new CCOWContextListener(commonContext, new InlinedContextAgentRepositoryModule());

	final MBeanContainer mbContainer = new MBeanContainer(ManagementFactory.getPlatformMBeanServer());
	ccowServer.addBean(mbContainer);

	final ServletContextHandler webSocketServletContextHandler = new ServletContextHandler(ccowServer, "/ws",
			ServletContextHandler.SESSIONS);
	webSocketServletContextHandler.addEventListener(c);
	WebSocketServerContainerInitializer.configureContext(webSocketServletContextHandler);

	final ServletContextHandler restServletContextHandler = new ServletContextHandler(ccowServer, "/");
	restServletContextHandler.addEventListener(c);
	restServletContextHandler.addFilter(AppGuiceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));

	 final ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler[] { webSocketServletContextHandler, restServletContextHandler});
        
	ccowServer.setHandler(contexts);
	ccowServer.start();

}
 
开发者ID:jkiddo,项目名称:ccow,代码行数:26,代码来源:WebSocketsTestSuite.java

示例2: start

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

示例3: start

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

示例4: start

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

示例5: initializeServer

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
private void initializeServer() {
	ResourceConfig resourceConfig = new ResourceConfig();
	resourceConfig.packages(GridServices.class.getPackage().getName());
	resourceConfig.register(JacksonJaxbJsonProvider.class);
	final Grid grid = this;
	
	resourceConfig.register(new AbstractBinder() {	
		@Override
		protected void configure() {
			bind(grid).to(Grid.class);
			bind(fileManager).to(FileProvider.class);
		}
	});
	ServletContainer servletContainer = new ServletContainer(resourceConfig);
			
	ServletHolder sh = new ServletHolder(servletContainer);
	ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
	context.setContextPath("/");
	context.addServlet(sh, "/*");

	server = new Server(port);
	
	ContextHandlerCollection contexts = new ContextHandlerCollection();
       contexts.setHandlers(new Handler[] { context});
	server.setHandler(contexts);
}
 
开发者ID:denkbar,项目名称:step,代码行数:27,代码来源:Grid.java

示例6: doPreStart

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
@Override
protected void doPreStart() {
    ContextHandler welcomeContext = new ContextHandler("/");
    welcomeContext.setContextPath("/");
    welcomeContext.setHandler(new WelcomeHandler(gpapProjectsFolder));

    ContextHandler projectsListContext = new ContextHandler("/stage_gplist_download");
    projectsListContext.setHandler(new ProjectListHandler(gpapProjectsFolder));

    ContextHandler projectDownloadContext = new ContextHandler("/stage_gpproject_download");
    projectDownloadContext.setHandler(new ProjectDownloadHandler(gpapProjectsFolder));

    ContextHandler projectUploadContext = new ContextHandler("/stage_gpproject_upload");
    projectUploadContext.setHandler(new ProjectUploadHandler(gpapProjectsFolder));

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(new Handler[]{welcomeContext, projectDownloadContext, projectUploadContext, projectsListContext});

    _server.setHandler(contexts);

}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:22,代码来源:GeopaparazziServer.java

示例7: start

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
public synchronized void start() throws WebServerException {
  if (server.isStarted()) {
    return;
  }

  // Package up all of the handlers into a ContextHandlerCollection to serve as the handler for
  // the server.
  List<? extends Handler> handlers = createHandlers();
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  contexts.setHandlers(handlers.toArray(new Handler[0]));
  server.setHandler(contexts);

  try {
    server.start();
  } catch (Exception e) {
    throw new WebServerException("Cannot start Websocket server.", e);
  }
}
 
开发者ID:saleehk,项目名称:buck-cutom,代码行数:19,代码来源:WebServer.java

示例8: postDeploy

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
/**
 * Post deploy
 * @exception Throwable Thrown if an error occurs
 */
public void postDeploy() throws Throwable
{
   if (server != null &&
       !server.isRunning() &&
       handlers != null && handlers.getHandlers() != null && handlers.getHandlers().length > 0)
   {
      try
      {
         ContextHandlerCollection chc = new ContextHandlerCollection();
         chc.setHandlers(handlers.getHandlers());

         server.setHandler(chc);
   
         server.start();
      }
      catch (Exception e)
      {
         log.error("Could not start Jetty webserver", e);
      }
   }
}
 
开发者ID:ironjacamar,项目名称:ironjacamar,代码行数:26,代码来源:WebServer.java

示例9: updateAndStartIfNeeded

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
/**
 * Update state and start the server if necessary.
 *
 * @param artifactCache cache to serve.
 * @throws WebServerException
 */
public synchronized void updateAndStartIfNeeded(Optional<ArtifactCache> artifactCache)
    throws WebServerException {
  artifactCacheHandler.setArtifactCache(artifactCache);

  if (server.isStarted()) {
    return;
  }

  // Package up all of the handlers into a ContextHandlerCollection to serve as the handler for
  // the server.
  ImmutableList<? extends Handler> handlers = createHandlers();
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  contexts.setHandlers(handlers.toArray(new Handler[0]));
  server.setHandler(contexts);

  try {
    server.start();
  } catch (Exception e) {
    throw new WebServerException("Cannot start Websocket server.", e);
  }
}
 
开发者ID:facebook,项目名称:buck,代码行数:28,代码来源:WebServer.java

示例10: run

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
@Override
public void run() {
	System.out.println("Creating ContextHandler");
	ContextHandlerCollection contexts = new ContextHandlerCollection();
	System.out.println("Building Web Application Context");
	contexts.setHandlers(new Handler[] { new AppContextBuilder().buildWebAppContext()});
	System.out.println("Setting Handler");
	jettyServer.setHandler(contexts);
	try {
		System.out.println("Starting jetty");
		jettyServer.start();
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(0);
	}
}
 
开发者ID:Meijinfr,项目名称:Run4WinTournamentManager,代码行数:17,代码来源:Launcher.java

示例11: startControlledBounceproxy

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
public static Server startControlledBounceproxy(String bpId) throws Exception {

        final int port = ServletUtil.findFreePort();
        final String bpUrl = "http://localhost:" + port + "/bounceproxy/";

        System.setProperty("joynr.bounceproxy.id", bpId);
        System.setProperty("joynr.bounceproxy.controller.baseurl",
                           System.getProperty(MessagingPropertyKeys.BOUNCE_PROXY_URL));
        System.setProperty("joynr.bounceproxy.url4cc", bpUrl);
        System.setProperty("joynr.bounceproxy.url4bpc", bpUrl);

        ContextHandlerCollection contexts = new ContextHandlerCollection();
        contexts.setHandlers(new Handler[]{ createControlledBounceproxyWebApp("", null) });
        Server server = startServer(contexts, port);

        System.clearProperty("joynr.bounceproxy.id");
        System.clearProperty("joynr.bounceproxy.controller.baseurl");
        System.clearProperty("joynr.bounceproxy.url4cc");
        System.clearProperty("joynr.bounceproxy.url4bpc");

        return server;
    }
 
开发者ID:bmwcarit,项目名称:joynr,代码行数:23,代码来源:ServersUtil.java

示例12: main

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Server server = new Server(8085);
    
    ContextHandler context = new ContextHandler("/");
    context.setContextPath("/");
    
    context.setHandler(new HandlerGUI("Root Hello"));
    
    ContextHandler contextFR = new ContextHandler("/fr");
    contextFR.setHandler(new HandlerGUI("Bonjoir"));
    
    ContextHandler contextIT = new ContextHandler("/it");
    contextIT.setHandler(new HandlerGUI("Bongiorno"));
    
    ContextHandler contextV = new ContextHandler("/");
    contextV.setVirtualHosts(new String[] { "127.0.0.2" });
    contextV.setHandler(new HandlerGUI("Virtual Hello"));
    
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    
    contexts.setHandlers(new Handler[] { context, contextFR, contextIT, contextV });
    
    server.setHandler(contexts);
    server.start();
    server.join();
}
 
开发者ID:jimjonesbr,项目名称:lod4wfs,代码行数:27,代码来源:ManyContexts.java

示例13: run

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
public void run()  {
try {
    System.out.println("Listening on Reqs...");

  Server server = new Server(Config.PORT);

  // Handler for the voting API
  ContextHandler votingContext = new ContextHandler();
  votingContext.setContextPath("/vote");
  votingContext.setHandler(new VoteHandler());
  // Handler for the stats API
  ContextHandler statContext = new ContextHandler();
  statContext.setContextPath("/stats");
  statContext.setHandler(new StatsHandler());

  // summing all the Handlers up to one
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  contexts.setHandlers(new Handler[] { votingContext, statContext});
  server.setHandler(contexts);
  server.start();
  server.join();

  } catch (Exception e) {
    e.printStackTrace();
  }

}
 
开发者ID:Sigma-News,项目名称:Backend,代码行数:28,代码来源:RequestManager.java

示例14: startServerWithHandlers

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
/**
 * init and start a jetty server, remember to call server.stop when the task is finished
 * @param handlers
 * @throws Exception
 */
protected Server startServerWithHandlers(ContextHandler... handlers) throws Exception {
  server = new Server(PORT);

  ContextHandlerCollection contexts = new ContextHandlerCollection();
  contexts.setHandlers(handlers);
  contexts.addHandler(mockMetaServerHandler());

  server.setHandler(contexts);
  server.start();

  return server;
}
 
开发者ID:dewey-its,项目名称:apollo-custom,代码行数:18,代码来源:BaseIntegrationTest.java

示例15: main

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

    ContextHandler context = new ContextHandler("/");
    context.setContextPath("/");
    context.setHandler(new HelloHandler("Root Hello"));

    ContextHandler contextFR = new ContextHandler("/fr");
    contextFR.setHandler(new HelloHandler("Bonjoir"));

    ContextHandler contextIT = new ContextHandler("/it");
    contextIT.setHandler(new HelloHandler("Bongiorno"));

    ContextHandler contextV = new ContextHandler("/");
    contextV.setVirtualHosts(new String[] { "127.0.0.2" });
    contextV.setHandler(new HelloHandler("Virtual Hello"));

    ContextHandlerCollection contexts = new ContextHandlerCollection();
    contexts.setHandlers(new Handler[] { context, contextFR, contextIT,
            contextV });

    server.setHandler(contexts);

    server.start();
    server.join();
}
 
开发者ID:lrtdc,项目名称:book_ldrtc,代码行数:28,代码来源:ManyContexts.java


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