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


Java ServletHandler类代码示例

本文整理汇总了Java中org.eclipse.jetty.servlet.ServletHandler的典型用法代码示例。如果您正苦于以下问题:Java ServletHandler类的具体用法?Java ServletHandler怎么用?Java ServletHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: main

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  initWeixin();

  Server server = new Server(8080);

  ServletHandler servletHandler = new ServletHandler();
  server.setHandler(servletHandler);

  ServletHolder endpointServletHolder = new ServletHolder(new WxCpEndpointServlet(wxCpConfigStorage, wxCpService, wxCpMessageRouter));
  servletHandler.addServletWithMapping(endpointServletHolder, "/*");

  ServletHolder oauthServletHolder = new ServletHolder(new WxCpOAuth2Servlet(wxCpService));
  servletHandler.addServletWithMapping(oauthServletHolder, "/oauth2/*");

  server.start();
  server.join();
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:18,代码来源:WxCpDemoServer.java

示例2: testConfiguredHttpsProxy

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
public void testConfiguredHttpsProxy() throws Exception {
  File testRepo = createMyModuleRepository("testConfiguredHttpsProxy");
  File emptyRepo = Files.createTempDirectory("vertx").toFile();
  emptyRepo.deleteOnExit();
  startRemoteServer(configureTls(createRemoteServer(testRepo)));
  Server server = new Server(8081);
  ServletHandler handler = new ServletHandler();
  server.setHandler(handler);
  handler.addServletWithMapping(ProxyServlet.class, "/").setInitParameter("maxThreads", "10");
  UrlCollectorFilter urlCollector = new UrlCollectorFilter();
  handler.addFilterWithMapping(new FilterHolder(urlCollector), "/*", 0);
  server.start();
  servers.add(server);
  System.setProperty(MavenVerticleFactory.HTTP_PROXY_SYS_PROP, "http://localhost:8081");
  configureRepos(emptyRepo, "https://localhost:8443/");
  URL expectedHost = new URL("http://localhost:8443/");
  vertx.deployVerticle("maven:my:module:1.0::my.serviceA", new DeploymentOptions(), onSuccess(id -> {
    assertTrue("Was expecting " + urlCollector.requestedHosts + " to contain " + expectedHost, urlCollector.requestedHosts.contains(expectedHost));
    testComplete();
  }));
  await();
}
 
开发者ID:vert-x3,项目名称:vertx-maven-service-factory,代码行数:23,代码来源:FactoryTest.java

示例3: startInJvmProxy

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的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

示例4: run

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void run() {
	try {
		this.server = new Server(this.serverPort);

		ServletHandler servletHandler = new ServletHandler();
		servletHandler.addServletWithMapping(TaskTrackerServlet.class, "/tracker");
		this.server.setHandler(servletHandler);

		this.server.start();
		this.server.join();
	} catch (Exception ex) {
		// suppress
	}
}
 
开发者ID:ran-jit,项目名称:distributed-task-scheduler,代码行数:17,代码来源:TaskTrackerHandler.java

示例5: main

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  initWeixin();

  Server server = new Server(8080);

  ServletHandler servletHandler = new ServletHandler();
  server.setHandler(servletHandler);

  ServletHolder endpointServletHolder = new ServletHolder(
    new WxMpEndpointServlet(wxMpConfigStorage, wxMpService,
      wxMpMessageRouter));
  servletHandler.addServletWithMapping(endpointServletHolder, "/*");

  ServletHolder oauthServletHolder = new ServletHolder(
    new WxMpOAuth2Servlet(wxMpService));
  servletHandler.addServletWithMapping(oauthServletHolder, "/oauth2/*");

  server.start();
  server.join();
}
 
开发者ID:11590692,项目名称:Wechat-Group,代码行数:21,代码来源:WxMpDemoServer.java

示例6: getAllServices

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
private HandlerList getAllServices() throws Exception{
    // File server & Context Handler for root, also setting the index.html
    // to be the "welcome file", i.e, autolink on root addresses.
    ContextHandler rootContext = new ContextHandler();
    rootContext.setContextPath("/*");
    rootContext.setHandler(getResourceHandlers());

    // Possible servlet lists, for all servlets or custom services you want to access later.
    // Warning, it might become a little bit nested if you add to many classes.
    ServletHandler questionHandler = new ServletHandler();
    questionHandler.addServletWithMapping(QuestionHandler.class, "/question");

    // Add the ResourceHandler to the server.
    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] {
            rootContext ,
            questionHandler,
    });

    return handlers;
}
 
开发者ID:Rebstorm,项目名称:paul0-application-server,代码行数:22,代码来源:HomeServerConfig.java

示例7: createServer

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
private Server createServer() {
    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(8384);
    server.addConnector(connector);

    ServletHandler handler = new ServletHandler();
    Servlet servlet = new HttpServlet() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
            String path = req.getServletPath().substring(1);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
            resp.getWriter().append(path);
        }
        
    };
    handler.addServletWithMapping(new ServletHolder(servlet), "/");
    server.setHandler(handler);
    return server;
}
 
开发者ID:cschneider,项目名称:reactive-components,代码行数:27,代码来源:TestRs.java

示例8: init

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
@PostConstruct
private void init()
{
    internal = new Server();

    ServletHandler servletHandler = new ServletHandler();
    KasijeServlet servlet = context.find(KasijeServlet.class);
    ServletHolder servletHolder = new ServletHolder("kasije", servlet);
    servletHandler.addServletWithMapping(servletHolder, "/*");
    internal.setHandler(servletHandler);

    ConfigProvider configProv = context.find(ConfigProvider.class);
    ServerConfig config = configProv.getServerConfig();
    if (null == config || null == config.getConnectors() || config.getConnectors().isEmpty())
    {
        internal.addConnector(createConnector(null));
    }
    else
    {
        for (Connector connectorConfig : config.getConnectors())
        {
            internal.addConnector(createConnector(connectorConfig));
        }
    }
}
 
开发者ID:touwolf,项目名称:kasije,代码行数:26,代码来源:KasijeServer.java

示例9: createReverseProxy

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
private ServletHandler createReverseProxy(ProxyMap proxyMap) {
    AsyncProxyServlet servlet = new ReverseProxy(proxyMap);
    ServletHolder proxyServletHolder = new ServletHolder(servlet);
    proxyServletHolder.setAsyncSupported(true);
    proxyServletHolder.setInitParameter("maxThreads", "256");
    proxyServletHolder.setInitParameter("idleTimeout", String.valueOf(idleTimeout));
    proxyServletHolder.setInitParameter("timeout", String.valueOf(totalTimeout));
    ServletHandler proxyHandler = new ServletHandler();
    proxyHandler.addServletWithMapping(proxyServletHolder, "/*");
    return proxyHandler;
}
 
开发者ID:danielflower,项目名称:app-runner,代码行数:12,代码来源:WebServer.java

示例10: main

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  initWeixin();

  Server server = new Server(8080);

  ServletHandler servletHandler = new ServletHandler();
  server.setHandler(servletHandler);

  ServletHolder endpointServletHolder = new ServletHolder(
      new WxMpEndpointServlet(wxMpConfigStorage, wxMpService,
          wxMpMessageRouter));
  servletHandler.addServletWithMapping(endpointServletHolder, "/*");

  ServletHolder oauthServletHolder = new ServletHolder(
      new WxMpOAuth2Servlet(wxMpService));
  servletHandler.addServletWithMapping(oauthServletHolder, "/oauth2/*");

  server.start();
  server.join();
}
 
开发者ID:binarywang,项目名称:weixin-java-tools-for-JDK6,代码行数:21,代码来源:WxMpDemoServer.java

示例11: LfsServer

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
/**
 * Ctor.
 * @param path Server path.
 * @param storage Storage container.
 * @param port Server port
 */
LfsServer(final String path, final ContentManager storage,
    final int port) {
    this.server = new Server();
    this.http =
        new ServerConnector(this.server, new HttpConnectionFactory());
    this.http.setPort(port);
    // @checkstyle MagicNumber (1 line)
    this.http.setIdleTimeout(30000);
    this.server.addConnector(this.http);
    final ServletHandler handler = new ServletHandler();
    this.server.setHandler(handler);
    handler.addServletWithMapping(
        new ServletHolder(
            new PointerServlet(
                storage, String.format("%s/info/lfs/storage/", path)
            )
        ),
        String.format("%s/info/lfs/objects/*", path)
    );
    handler.addServletWithMapping(
        new ServletHolder(new ContentServlet(storage)),
        String.format("%s/info/lfs/storage/*", path)
    );
}
 
开发者ID:carlosmiranda,项目名称:git-lfs-azureblob,代码行数:31,代码来源:LfsServer.java

示例12: initHttpServer

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
/**
 * Inits the http server.
 */
private void initHttpServer() {
  final int httpPort = this.getServerConfig().getHttpPort();
  final DialogListener dialogListener = this;
  Server server = new Server(httpPort);

  ServletHandler handler = new ServletHandler();
  server.setHandler(handler);

  ServletHolder sh = new ServletHolder();
  EmbeddedServlet embeddedServlet = new EmbeddedServlet();

  embeddedServlet.setDialogListener(dialogListener);
  sh.setServlet(embeddedServlet);
  handler.addServletWithMapping(sh, "/ussdgw");

  HttpServerThread httpServerThread = new HttpServerThread();
  httpServerThread.setJettyServer(server);
  httpServerThread.start();
}
 
开发者ID:BerrySys,项目名称:berrysys-ussdgw,代码行数:23,代码来源:DialogListener.java

示例13: startServer1

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
public void startServer1() throws Exception
{
    Server server = new Server(9091);
    ServletHandler handler = new ServletHandler();

    AwesomeService.Processor<AwesomeService.Iface> processor = new AwesomeService.Processor<>(referenceServer);
    ServletHolder holder = new ServletHolder(new TServlet(processor, new TJSONProtocol.Factory()));
    handler.addFilterWithMapping(CORSFilter.class, "/*", 0);
    handler.addServletWithMapping(holder, "/*");
    server.setHandler(handler);
    server.start();
    logger.info("Started JSON interface.");

    joinMethods.add(() -> {
        try {
            server.join();
        } catch (InterruptedException ignored) {
        }
    });
}
 
开发者ID:coveord,项目名称:Blitz-2015,代码行数:21,代码来源:ReferenceMain.java

示例14: spawnServer

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
@Before
public void spawnServer() throws Exception
{
    server = new Server(SERVER_PORT);
    ServletHandler handler = new ServletHandler();

    mockedServer = Mockito.mock(AwesomeService.Iface.class);
    when(mockedServer.getData(any(Request.class))).thenReturn(new Response(Arrays.asList(new DataPoint(),
                                                                                         new DataPoint())));

    AwesomeService.Processor<AwesomeService.Iface> processor = new AwesomeService.Processor<>(mockedServer);
    ServletHolder holder = new ServletHolder(new TServlet(processor, new TJSONProtocol.Factory()));

    handler.addServletWithMapping(holder, "/*");
    server.setHandler(handler);

    server.start();
}
 
开发者ID:coveord,项目名称:Blitz-2015,代码行数:19,代码来源:ThriftHttpTest.java

示例15: createChatsServlets

import org.eclipse.jetty.servlet.ServletHandler; //导入依赖的package包/类
public static ServletHandler createChatsServlets() {
	ServletHandler sh = new ServletHandler();
	addServletWithMapping(sh, CreateAccount.class);
	addServletWithMapping(sh, PutOperator.class);
	addServletWithMapping(sh, RemoveOperator.class);
	addServletWithMapping(sh, InitUserToken.class);
	addServletWithMapping(sh, RemoveUserSession.class);
	addServletWithMapping(sh, UpdateUserSessions.class);
	addServletWithMapping(sh, SetAccsBlocked.class);
	addServletWithMapping(sh, GetUnblockedAccs.class);
	addServletWithMapping(sh, SetAccsPaused.class);
	addServletWithMapping(sh, GetPausedState.class);
	addServletWithMapping(sh, UpdateUserContact.class);
	addServletWithMapping(sh, PutAccConfig.class);
	return sh;
}
 
开发者ID:edolganov,项目名称:live-chat-engine,代码行数:17,代码来源:FrontAndChats_IntegrationTest.java


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