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


Java HandlerCollection.addHandler方法代码示例

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


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

示例1: startInJvmProxy

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
/**
 * To test that the CF client is able to go through a proxy, we point the CC client to a broken url that can only be resolved by going
 * through an inJVM proxy which rewrites the URI. This method starts this inJvm proxy.
 *
 * @throws Exception
 */
private static void startInJvmProxy() throws Exception {
    inJvmProxyPort = getNextAvailablePort(8080);
    inJvmProxyServer = new Server(new InetSocketAddress("127.0.0.1", inJvmProxyPort)); // forcing use of loopback
    // that will be used both for Httpclient proxy and SocketDestHelper
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setMinThreads(1);
    inJvmProxyServer.setThreadPool(threadPool);

    HandlerCollection handlers = new HandlerCollection();
    inJvmProxyServer.setHandler(handlers);

    ServletHandler servletHandler = new ServletHandler();
    handlers.addHandler(servletHandler);
    nbInJvmProxyRcvReqs = new AtomicInteger();
    ChainedProxyServlet chainedProxyServlet = new ChainedProxyServlet(httpProxyConfiguration, nbInJvmProxyRcvReqs);
    servletHandler.addServletWithMapping(new ServletHolder(chainedProxyServlet), "/*");

    // Setup proxy handler to handle CONNECT methods
    ConnectHandler proxyHandler;
    proxyHandler = new ChainedProxyConnectHandler(httpProxyConfiguration, nbInJvmProxyRcvReqs);
    handlers.addHandler(proxyHandler);

    inJvmProxyServer.start();
}
 
开发者ID:SAP,项目名称:cf-java-client-sap,代码行数:31,代码来源:CloudFoundryClientTest.java

示例2: serverWithStatisticsCollection

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
/**
 * @param registry Prometheus CollectorRegistry to register the default exporters.
 * @param httpPort The port the Server runs on.
 * @return a Jetty Server with Prometheus' default exporters registered.
 */
public static Server serverWithStatisticsCollection(CollectorRegistry registry, int httpPort) {
    Server server = new Server(httpPort);

    new StandardExports().register(registry);
    new MemoryPoolsExports().register(registry);
    new GarbageCollectorExports().register(registry);
    new ThreadExports().register(registry);
    new ClassLoadingExports().register(registry);
    new VersionInfoExports().register(registry);

    HandlerCollection handlers = new HandlerCollection();
    StatisticsHandler statisticsHandler = new StatisticsHandler();
    statisticsHandler.setServer(server);
    handlers.addHandler(statisticsHandler);

    new JettyStatisticsCollector(statisticsHandler).register();
    server.setHandler(handlers);

    return server;
}
 
开发者ID:tjheslin1,项目名称:Patterdale,代码行数:26,代码来源:RegisterExporters.java

示例3: addJettyHandlers

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
protected void addJettyHandlers(Server server, List<Handler> handlers) {
    if (handlers != null && !handlers.isEmpty()) {
        for (Handler handler : handlers) {
            if (handler instanceof HandlerWrapper) {
                // avoid setting the security handler more than once
                if (!handler.equals(server.getHandler())) {
                    ((HandlerWrapper) handler).setHandler(server.getHandler());
                    server.setHandler(handler);
                }
            } else {
                HandlerCollection handlerCollection = new HandlerCollection();
                handlerCollection.addHandler(server.getHandler());
                handlerCollection.addHandler(handler);
                server.setHandler(handlerCollection);
            }
        }
    }
    
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:JettyHttpComponent.java

示例4: addJettyHandlers

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
protected void addJettyHandlers(Server server, List<Handler> handlers) {
    if (handlers != null && !handlers.isEmpty()) {
        for (Handler handler : handlers) {
            if (handler instanceof HandlerWrapper) {
                // avoid setting the security handler more than once
                if (!handler.equals(server.getHandler())) {
                    ((HandlerWrapper) handler).setHandler(server.getHandler());
                    server.setHandler(handler);
                }
            } else {
                HandlerCollection handlerCollection = new HandlerCollection();
                handlerCollection.addHandler(server.getHandler());
                handlerCollection.addHandler(handler);
                server.setHandler(handlerCollection);
            }
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:JettyHttpComponent.java

示例5: createContext

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
protected ServletContextHandler createContext(Server server, Connector connector, List<Handler> handlers) throws Exception {
    ServletContextHandler context = new ServletContextHandler(server, "/", ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
    server.addConnector(connector);

    if (handlers != null && !handlers.isEmpty()) {
        for (Handler handler : handlers) {
            if (handler instanceof HandlerWrapper) {
                ((HandlerWrapper) handler).setHandler(server.getHandler());
                server.setHandler(handler);
            } else {
                HandlerCollection handlerCollection = new HandlerCollection();
                handlerCollection.addHandler(server.getHandler());
                handlerCollection.addHandler(handler);
                server.setHandler(handlerCollection);
            }
        }
    }

    return context;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:WebsocketComponent.java

示例6: initJettyServer

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private Server initJettyServer(ComponentRepository repo) {
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setPort(getPort());
  connector.setConfidentialPort(getSecurePort());
  connector.setRequestHeaderSize(16384);

  Server jettyServer = new Server();
  jettyServer.setConnectors(new Connector[] {connector});
  
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  HandlerCollection handlers = new HandlerCollection();
  handlers.addHandler(contexts);
  addHandlers(repo, jettyServer, contexts);
  
  jettyServer.setHandler(handlers);
  jettyServer.setStopAtShutdown(true);
  jettyServer.setGracefulShutdown(2000);
  jettyServer.setSendDateHeader(true);
  jettyServer.setSendServerVersion(true);
  
  ComponentInfo info = new ComponentInfo(Server.class, "jetty");
  repo.registerComponent(info, jettyServer);
  repo.registerLifecycle(new ServerLifecycle(jettyServer));
  return jettyServer;
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:EmbeddedJettyComponentFactory.java

示例7: startServer

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@BeforeClass
public void startServer() throws Exception {
  int port = 49152 + RandomUtils.nextInt(65535 - 49152);
  String serverUrl = "http://localhost:" + port + "/jax";
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setPort(port);
  _jettyServer = new Server();
  _jettyServer.setConnectors(new Connector[]{connector});
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  HandlerCollection handlers = new HandlerCollection();
  handlers.addHandler(contexts);
  WebAppContext ogWebAppContext = new WebAppContext("RemoteViewRunnerTest", "/");
  org.springframework.core.io.Resource resource = new ClassPathResource("web-engine");
  ogWebAppContext.setBaseResource(Resource.newResource(resource.getFile()));
  DataViewRunnerResource viewRunnerResource = new DataViewRunnerResource(new TestViewRunner());
  ComponentRepository repo = new ComponentRepository(ComponentLogger.Console.VERBOSE);
  repo.getRestComponents().publishResource(viewRunnerResource);
  repo.getRestComponents().publishHelper(new FudgeObjectBinaryConsumer());
  repo.getRestComponents().publishHelper(new FudgeObjectBinaryProducer());
  ogWebAppContext.setEventListeners(new EventListener[]{new ComponentRepositoryServletContextListener(repo)});
  handlers.addHandler(ogWebAppContext);
  _jettyServer.setHandler(handlers);
  _jettyServer.start();
  _remoteViewRunner = new RemoteViewRunner(URI.create(serverUrl));
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:26,代码来源:RemoteViewRunnerTest.java

示例8: servletInit

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
/**
 * Add all the servlets to the server
 * including resource handler serving static files
 */
private void servletInit() {
    mainLog.info("Initializing servlets");
    HandlerCollection handlers = new HandlerCollection();
    Iterable<Handler> servletHandler = Iterables.transform(Configuration.getInstance().getServlets(),
            new Function<ServletConfig, Handler>() {

                @Override
                public Handler apply(ServletConfig servletConfig) {
                    return buildServletHandler(servletConfig);
                }
    });
    servletHandler.forEach((handler) -> {
        handlers.addHandler(handler);
    });
    handlers.addHandler(buildResourceHandler());
    server.setHandler(handlers);
}
 
开发者ID:victor-guoyu,项目名称:Review-It,代码行数:22,代码来源:App.java

示例9: main

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

ResourceHandler rh = new ResourceHandler();
rh.setBaseResource(Resource.newClassPathResource("/com/frinika/web/content/"));
rh.setDirectoriesListed(true);
hc.addHandler(rh);
server.setHandler(hc);
server.start();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                initAndShowGUI();
            }
        });
    }
 
开发者ID:petersalomonsen,项目名称:frinika,代码行数:18,代码来源:SwingJavaFXTest.java

示例10: main

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

		Server server = new Server(8080);

        // add web applications
        HandlerCollection handlers = new HandlerCollection();
        Preconditions.checkArgument(args != null && args.length > 0, "Missing args: web project. Please pass a list of web projects, e.g.: JettyServer helloworld");
        for (String arg : args) {
            Iterator<String> it = Splitter.on(":").split(arg).iterator();
            String domain = it.next();
            String projectName = it.hasNext() ? it.next() : domain;
            WebAppContext webappContext = createContext(domain, projectName);
            handlers.addHandler(webappContext);
        }
        server.setHandler(handlers);

        // enable web 3.0 annotations
        Configuration.ClassList classList = Configuration.ClassList.setServerDefault(server);
        classList.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());

        server.start();
        server.join();
    }
 
开发者ID:extrema,项目名称:jetty-embedded,代码行数:24,代码来源:JettyServer.java

示例11: startInJvmProxy

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
/**
 * To test that the CF client is able to go through a proxy, we point the CC client to a broken url
 * that can only be resolved by going through an inJVM proxy which rewrites the URI.
 * This method starts this inJvm proxy.
 * @throws Exception
 */
private static void startInJvmProxy() throws Exception {
	inJvmProxyPort = getNextAvailablePort(8080);
	inJvmProxyServer = new Server(new InetSocketAddress("127.0.0.1", inJvmProxyPort)); //forcing use of loopback that will be used both for Httpclient proxy and SocketDestHelper
	QueuedThreadPool threadPool = new QueuedThreadPool();
	threadPool.setMinThreads(1);
	inJvmProxyServer.setThreadPool(threadPool);

	HandlerCollection handlers = new HandlerCollection();
	inJvmProxyServer.setHandler(handlers);

	ServletHandler servletHandler = new ServletHandler();
	handlers.addHandler(servletHandler);
	nbInJvmProxyRcvReqs = new AtomicInteger();
	//		ChainedProxyServlet chainedProxyServlet = new ChainedProxyServlet(httpProxyConfiguration, nbInJvmProxyRcvReqs);
	//		servletHandler.addServletWithMapping(new ServletHolder(chainedProxyServlet), "/*");

	// Setup proxy handler to handle CONNECT methods
	ConnectHandler proxyHandler;
	//		proxyHandler = new ChainedProxyConnectHandler(httpProxyConfiguration, nbInJvmProxyRcvReqs);
	//		handlers.addHandler(proxyHandler);

	inJvmProxyServer.start();
}
 
开发者ID:stephen-kruger,项目名称:cloudfoundry-liteclient-lib,代码行数:30,代码来源:CloudFoundryClientTest.java

示例12: configure

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
@Override
public void configure() throws Exception {
    server.addEventListener(mbeans());
    server.addConnector(plainConnector());
    server.addConnector(sslConnector());
    HandlerCollection handlers = new HandlerCollection();
    handlers.addHandler(welcomeFileHandler());
    createWebAppContext();
    addResourceHandler(handlers, webAppContext);
    handlers.addHandler(webAppContext);
    JettyCustomErrorPageHandler errorHandler = new JettyCustomErrorPageHandler();
    webAppContext.setErrorHandler(errorHandler);
    server.addBean(errorHandler);
    server.setHandler(handlers);
    performCustomConfiguration();
    server.setStopAtShutdown(true);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:18,代码来源:Jetty9Server.java

示例13: configureJetty

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
protected Server configureJetty(War war) throws IOException {
    System.setProperty("org.eclipse.jetty.xml.XmlParser.NotValidating", "true");

    final Server server = createServer();

    HandlerCollection handlerCollection = new HandlerCollection();
    handlerCollection.addHandler(configureExternal(server, war));
    if (this.configuration.getHttpConfiguration().hasAdminPort()) {
        handlerCollection.addHandler(configureInternal(server));
    }
    if (this.configuration.isRequestLoggingEnabled()) {
        RequestLoggingFactory requestLoggingFactory = new RequestLoggingFactory(this.configuration);
        handlerCollection.addHandler(requestLoggingFactory.configure());
    }
    server.setHandler(handlerCollection);

    if (this.configuration.isJmxEnabled()) {
        JmxServer jmxServer = new JmxServer(this.configuration.getJmxConfiguration());
        jmxServer.start();
    }

    return server;
}
 
开发者ID:wotifgroup,项目名称:grails-lightweight-deploy,代码行数:24,代码来源:Launcher.java

示例14: createWebsocketHandler

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private void createWebsocketHandler(final HandlerCollection handlerCollection) {
    // https://github.com/jetty-project/embedded-jetty-websocket-examples/blob/master/javax.websocket-example/src/main/java/org/eclipse/jetty/demo/EventServer.java
    try {
        final Set<Class<?>> managedClasses = collectAnnotated(WEBSOCKET_MANAGED_CLASSES);
        final ServletContextHandler context = initContext("/websockets", managedClasses);
        handlerCollection.addHandler(context);
        final ServerContainer wscontainer = WebSocketServerContainerInitializer.configureContext(context);
        managedClasses.forEach(c -> registerEndpoint(wscontainer, c));
    } catch (final ServletException e) {
        throw new TestEEfiException("Failed to initialize websockets", e);
    }
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:13,代码来源:RestServerImpl.java

示例15: createJerseyHandler

import org.eclipse.jetty.server.handler.HandlerCollection; //导入方法依赖的package包/类
private ServletContextHandler createJerseyHandler(final HandlerCollection handlerCollection) {
    // http://nikgrozev.com/2014/10/16/rest-with-embedded-jetty-and-jersey-in-a-single-jar-step-by-step/
    final Set<Class<?>> managedClasses = collectAnnotated(JAX_RS_MANAGED_CLASSES);
    final ServletContextHandler context = initContext("/rest", managedClasses);
    handlerCollection.addHandler(context);
    final ResourceConfig config = initConfig(managedClasses);
    annotationScanner.scanFor(ApplicationPath.class).forEach(appClass -> {
        final String path = appClass.getAnnotation(ApplicationPath.class).value();
        final String pathSpec = (path.startsWith("/") ? "" : "/") + path + "/*";
        LOG.debug("Mapping rest application {} to {}", appClass.getName(), pathSpec);
        context.addServlet(new ServletHolder(new JerseyServlet(config)), pathSpec);
    });
    return context;
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:15,代码来源:RestServerImpl.java


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