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


Java ContextHandlerCollection.addHandler方法代码示例

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


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

示例1: applyHandle

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
private void applyHandle(final String contextPath, final String warPath) {
    final ContextHandlerCollection handler = new ContextHandlerCollection();
    final WebAppContext webapp = new WebAppContext();
    webapp.setContextPath(contextPath);
    webapp.setDefaultsDescriptor(WEB_DEFAULT);
    if (StringUtils.isEmpty(warPath)) {
        webapp.setResourceBase(DEFAULT_RESOURCE_BASE);
        webapp.setDescriptor(DEFAULT_WEB_XML_PATH);
    } else {
        webapp.setWar(warPath);
    }
    
    applySessionHandler(webapp);
    
    handler.addHandler(webapp);
    super.setHandler(handler);
}
 
开发者ID:nano-projects,项目名称:nano-framework,代码行数:18,代码来源:JettyCustomServer.java

示例2: createHandlers

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
private static ContextHandlerCollection createHandlers( final String baseURL, final Map< String, String > dataSet, final String thumbnailsDirectoryName ) throws SpimDataException, IOException
{
	final ContextHandlerCollection handlers = new ContextHandlerCollection();

	for ( final Entry< String, String > entry : dataSet.entrySet() )
	{
		final String name = entry.getKey();
		final String xmlpath = entry.getValue();
		final String context = "/" + name;
		final CellHandler ctx = new CellHandler( baseURL + context + "/", xmlpath, name, thumbnailsDirectoryName );
		ctx.setContextPath( context );
		handlers.addHandler( ctx );
	}

	return handlers;
}
 
开发者ID:bigdataviewer,项目名称:bigdataviewer-server,代码行数:17,代码来源:BigDataServer.java

示例3: execute1

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
protected void execute1(String component) throws Exception {
	System.out.println("Starting codeine "+component+" at version " + CodeineVersion.get());
	injector = Guice.createInjector(getModules(component));
	FilterHolder guiceFilter = new FilterHolder(injector.getInstance(GuiceFilter.class));
	ServletContextHandler handler = createServletContextHandler();
	handler.setContextPath("/");
	FilterHolder crossHolder = new FilterHolder(new CrossOriginFilter());
	crossHolder.setInitParameter(CrossOriginFilter.ALLOWED_METHODS_PARAM, "GET, POST, PUT, DELETE");
	crossHolder.setInitParameter(CrossOriginFilter.ALLOWED_HEADERS_PARAM, "X-Requested-With,Origin,Content-Type,Accept,api_token");
	handler.addFilter(crossHolder, "/api/*", EnumSet.allOf(DispatcherType.class));
	handler.addFilter(crossHolder, "/api-with-token/*", EnumSet.allOf(DispatcherType.class));
	handler.addFilter(guiceFilter, "/*", EnumSet.allOf(DispatcherType.class));
	createAdditionalServlets(handler);
	ContextHandlerCollection contexts = createFileServerContexts();
	contexts.addHandler(handler);
	int port = startServer(contexts);
	log.info("jetty started on port " + port);
	injector.getInstance(CodeineRuntimeInfo.class).setPort(port);
	execute();
}
 
开发者ID:codeine-cd,项目名称:codeine,代码行数:21,代码来源:AbstractCodeineBootstrap.java

示例4: addModulesToJetty

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
/**
 * Configure the web application(s).
 * @param handlers
 * @throws Exception
 */
protected void addModulesToJetty(ContextHandlerCollection handlers) throws Exception {
    /* *************
     * Gateway
     * ************* */
    ServletContextHandler server = new ServletContextHandler(ServletContextHandler.SESSIONS);
    server.setContextPath("/");
    server.addEventListener(new WarGatewayBootstrapper());
    ServletHolder servlet = new ServletHolder(new WarGatewayServlet());
    server.addServlet(servlet, "/gateway/*");
    servlet = new ServletHolder(new HttpServletDispatcher());
    servlet.setInitParameter("javax.ws.rs.Application", TestGatewayApplication.class.getName());
    servlet.setInitParameter("resteasy.servlet.mapping.prefix", "/api");
    servlet.setInitOrder(1);
    server.addServlet(servlet, "/api/*");

    // Add the web contexts to jetty
    handlers.addHandler(server);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:24,代码来源:GatewayServer.java

示例5: 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

示例6: start

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
public void start() throws Exception {
    pidFileLocker.lock();

    ServerConfiguration config = new ServerConfiguration(this.configuration);

    server = new Server(config);
    server.start();

    boolean httpEnabled = config.getBoolean("http.enable", true);
    if (httpEnabled) {
        String httphost = config.getString("http.host", server.getNetworkServer().getHost());
        String httpadvertisedhost = config.getString("http.advertised.host", server.getServerHostData().getHost());
        int httpport = config.getInt("http.port", 9845);
        int httpadvertisedport = config.getInt("http.advertised.port", 9845);

        httpserver = new org.eclipse.jetty.server.Server(new InetSocketAddress(httphost, httpport));
        ContextHandlerCollection contexts = new ContextHandlerCollection();
        httpserver.setHandler(contexts);
        File webUi = new File("web/ui");
        if (webUi.isDirectory()) {
            WebAppContext webApp = new WebAppContext(new File("web/ui").getAbsolutePath(), "/ui");
            contexts.addHandler(webApp);
        } else {
            System.out.println("Cannot find " + webUi.getAbsolutePath() + " directory. Web UI will not be deployed");
        }
        uiurl = "http://" + httpadvertisedhost + ":" + httpadvertisedport + "/ui/#/login?url=" + server.getJdbcUrl();
        System.out.println("Listening for client (http) connections on " + httphost + ":" + httpport);
        httpserver.start();
    }

    System.out.println("HerdDB server starter. Node id " + server.getNodeId());
    System.out.println("JDBC URL: " + server.getJdbcUrl());
    System.out.println("Web Interface: " + uiurl);
    started = true;
}
 
开发者ID:diennea,项目名称:herddb,代码行数:36,代码来源:ServerMain.java

示例7: start

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

	ContextHandler homeHandler = new ContextHandler();
	homeHandler.setContextPath("/");
	homeHandler.setHandler(new HomeHandler());

	ContextHandler faviconHandler = new ContextHandler();
	faviconHandler.setContextPath("/favicon.ico");
	faviconHandler.setAllowNullPathInfo(true);
	faviconHandler.setHandler(new FaviconHandler());

	ContextHandler robotsHandler = new ContextHandler();
	robotsHandler.setContextPath("/robots.txt");
	robotsHandler.setAllowNullPathInfo(true);
	robotsHandler.setHandler(new RobotsHandler());

	ContextHandler stylesheetHandler = new ContextHandler();
	stylesheetHandler.setContextPath("/style.css");
	stylesheetHandler.setAllowNullPathInfo(true);
	stylesheetHandler.setHandler(new StylesheetHandler());

	ContextHandlerCollection contexts = new ContextHandlerCollection();
	contexts.addHandler(homeHandler);
	contexts.addHandler(faviconHandler);
	contexts.addHandler(robotsHandler);
	contexts.addHandler(stylesheetHandler);

	server.setHandler(contexts);
	server.start();
}
 
开发者ID:ujmp,项目名称:universal-java-matrix-package,代码行数:32,代码来源:UJMPJettyServer.java

示例8: startHttpServer

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
private Server startHttpServer(String httphost, int httpport, String httppath, Broker broker) throws Exception {
    Server httpserver = new Server(new InetSocketAddress(httphost, httpport));
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    httpserver.setHandler(contexts);
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.GZIP);
    context.setContextPath("/");
    ServletHolder jerseyServlet = new ServletHolder(new StandaloneHttpAPIServlet(broker));
    jerseyServlet.setInitOrder(0);
    context.addServlet(jerseyServlet, httppath);
    contexts.addHandler(context);
    httpserver.start();
    return httpserver;
}
 
开发者ID:diennea,项目名称:majordodo,代码行数:14,代码来源:HttpClientLeaderRecoveryTest.java

示例9: setupWebAppContext

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
private static WebAppContext setupWebAppContext(ContextHandlerCollection contexts,
                                                ZeppelinConfiguration conf) {

  WebAppContext webApp = new WebAppContext();
  webApp.setContextPath(conf.getServerContextPath());
  File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR));
  if (warPath.isDirectory()) {
    // Development mode, read from FS
    // webApp.setDescriptor(warPath+"/WEB-INF/web.xml");
    webApp.setResourceBase(warPath.getPath());
    webApp.setParentLoaderPriority(true);
  } else {
    // use packaged WAR
    webApp.setWar(warPath.getAbsolutePath());
    File warTempDirectory = new File(conf.getRelativeDir(ConfVars.ZEPPELIN_WAR_TEMPDIR));
    warTempDirectory.mkdir();
    LOG.info("ZeppelinServer Webapp path: {}", warTempDirectory.getPath());
    webApp.setTempDirectory(warTempDirectory);
  }
  // Explicit bind to root
  webApp.addServlet(new ServletHolder(new DefaultServlet()), "/*");
  contexts.addHandler(webApp);

  webApp.addFilter(new FilterHolder(CorsFilter.class), "/*",
      EnumSet.allOf(DispatcherType.class));

  webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed",
          Boolean.toString(conf.getBoolean(ConfVars.ZEPPELIN_SERVER_DEFAULT_DIR_ALLOWED)));

  return webApp;

}
 
开发者ID:apache,项目名称:zeppelin,代码行数:33,代码来源:ZeppelinServer.java

示例10: addContextHandlers

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
private void addContextHandlers(ContextHandlerCollection parentHandler,
    Collection<? extends ContextHandler> childContexts) {
  if (!childContexts.isEmpty()) {
    for (ContextHandler h : childContexts) {
      parentHandler.addHandler(h);
    }
  }
}
 
开发者ID:sdl,项目名称:embedded-rest-server,代码行数:9,代码来源:HandlerCollectionLoader.java

示例11: start

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
/**
 * Start the server with a http port and optional javamelody parameters.
 * @param port Http port
 * @param parameters Optional javamelody parameters
 * @throws Exception e
 */
public static void start(int port, Map<Parameter, String> parameters) throws Exception {
	// Init jetty
	final Server server = new Server(port);
	final ContextHandlerCollection contexts = new ContextHandlerCollection();
	final ServletContextHandler context = new ServletContextHandler(contexts, "/",
			ServletContextHandler.SESSIONS);

	final net.bull.javamelody.MonitoringFilter monitoringFilter = new net.bull.javamelody.MonitoringFilter();
	monitoringFilter.setApplicationType("Standalone");
	final FilterHolder filterHolder = new FilterHolder(monitoringFilter);
	if (parameters != null) {
		for (final Map.Entry<Parameter, String> entry : parameters.entrySet()) {
			final net.bull.javamelody.Parameter parameter = entry.getKey();
			final String value = entry.getValue();
			filterHolder.setInitParameter(parameter.getCode(), value);
		}
	}
	context.addFilter(filterHolder, "/*",
			EnumSet.of(DispatcherType.INCLUDE, DispatcherType.REQUEST));

	final RequestLogHandler requestLogHandler = new RequestLogHandler();
	contexts.addHandler(requestLogHandler);

	final HandlerCollection handlers = new HandlerCollection();
	handlers.setHandlers(new Handler[] { contexts });
	server.setHandler(handlers);

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

示例12: startJetty

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
public static void startJetty(IProject project, JasperReportsConfiguration jContext) {
	try {
		if (server == null) {
			Integer p = jContext.getPropertyInteger(GlobalPreferencePage.JSS_JETTY_PORT);
			if (p == null || p.intValue() <= 0)
				port = SocketUtil.findFreePort();
			else
				port = p;

			if (port == -1)
				port = 8888;
			server = new Server(port);
			HandlerCollection hc = new HandlerCollection();
			contextHandlerCollection = new ContextHandlerCollection();
			hc.setHandlers(new Handler[] { contextHandlerCollection });
			server.setHandler(hc);

			server.start();

		}
		if (hmap.get(project) == null) {

			// server.stop();

			List<Handler> handlers = createContext(project, jContext);
			hmap.put(project, handlers);
			for (Handler h : handlers) {
				contextHandlerCollection.addHandler(h);
				h.start();
			}
		}
	} catch (Exception e) {
		throw new JRRuntimeException(e);
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:36,代码来源:JettyUtil.java

示例13: createFileServerContexts

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
private ContextHandlerCollection createFileServerContexts(){
	ContextHandlerCollection contexts = new ContextHandlerCollection();
	addHandler(Constants.RESOURCESS_CONTEXT, Constants.getResourcesDir(), contexts);
       contexts.addHandler(createStaticContextHandler("/favicon.ico", Constants.getAngularDir() + "/favicon.ico"));
	specificCreateFileServer(contexts);
	return contexts;
}
 
开发者ID:codeine-cd,项目名称:codeine,代码行数:8,代码来源:AbstractCodeineBootstrap.java

示例14: run

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
@Override
public void run() throws Exception {
    // Create an embedded jetty instance
    final Server server = new Server(new InetSocketAddress(this.config.getString("host", "127.0.0.1"),
            this.config.getInt("port", 8000)));
    
    
    ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();
    
    // custom handling for requisitions
    RequisitionProviderHandler requisitionProviderHandler = new RequisitionProviderHandler();
    ContextHandler contextHandlerRequisitions = new ContextHandler("/requisitions");
    contextHandlerRequisitions.setHandler(requisitionProviderHandler);
    contextHandlerCollection.addHandler(contextHandlerRequisitions);
    
    // provide the documentation
    ResourceHandler docuResourceHandler = new ResourceHandler();
    docuResourceHandler.setDirectoriesListed(true);
    docuResourceHandler.setWelcomeFiles(new String[]{"index.html"});
    docuResourceHandler.setResourceBase("./documentation/");

    // redirecting http://ip:port/ to the docu

    ContextHandler rootContext = new ContextHandler("/");
    rootContext.setHandler(docuResourceHandler);
    contextHandlerCollection.addHandler(rootContext);
    
    server.setHandler(contextHandlerCollection);

    server.start();
    server.join();
}
 
开发者ID:OpenNMS,项目名称:opennms-provisioning-integration-server,代码行数:33,代码来源:HttpServerDriver.java

示例15: addModulesToJetty

import org.eclipse.jetty.server.handler.ContextHandlerCollection; //导入方法依赖的package包/类
/**
 * Configure the web application(s).
 * @param handlers
 * @throws Exception
 */
protected void addModulesToJetty(ContextHandlerCollection handlers) throws Exception {
	/* *************
     * Gateway API
     * ************* */
    ServletContextHandler gatewayApiServer = new ServletContextHandler(ServletContextHandler.SESSIONS);
    addSecurityHandler(gatewayApiServer);
    gatewayApiServer.setContextPath("/api");
    gatewayApiServer.addEventListener(new ResteasyBootstrap());
    gatewayApiServer.addEventListener(new WarGatewayBootstrapper());
    gatewayApiServer.addFilter(HttpRequestThreadLocalFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    gatewayApiServer.addFilter(LocaleFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    gatewayApiServer.addFilter(ApimanCorsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    gatewayApiServer.addFilter(DisableCachingFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    addApiAuthFilter(gatewayApiServer);
    gatewayApiServer.addFilter(RootResourceFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
    ServletHolder resteasyServlet = new ServletHolder(new HttpServletDispatcher());
    resteasyServlet.setInitParameter("javax.ws.rs.Application", GatewayMicroServiceApplication.class.getName());
    gatewayApiServer.addServlet(resteasyServlet, "/*");
    gatewayApiServer.setInitParameter("resteasy.servlet.mapping.prefix", "");

    handlers.addHandler(gatewayApiServer);


    /* *************
     * Gateway
     * ************* */
    ServletContextHandler gatewayServer = new ServletContextHandler(ServletContextHandler.SESSIONS);
    addSecurityHandler(gatewayServer);
    gatewayServer.setContextPath("/gateway");
    ServletHolder servlet = new ServletHolder(new WarGatewayServlet());
    gatewayServer.addServlet(servlet, "/*");

    handlers.addHandler(gatewayServer);
}
 
开发者ID:apiman,项目名称:apiman,代码行数:40,代码来源:GatewayMicroService.java


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