Java 类org.eclipse.jetty.servlet.ServletHandler 实例源码

项目:vertx-maven-service-factory    文件:FactoryTest.java   
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();
}
项目:cf-java-client-sap    文件:CloudFoundryClientTest.java   
/**
 * 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();
}
项目:distributed-task-scheduler    文件:TaskTrackerHandler.java   
/** {@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
    }
}
项目:Wechat-Group    文件:WxCpDemoServer.java   
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();
}
项目:Wechat-Group    文件:WxMpDemoServer.java   
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();
}
项目:paul0-application-server    文件:HomeServerConfig.java   
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;
}
项目:reactive-components    文件:TestRs.java   
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;
}
项目:kasije    文件:KasijeServer.java   
@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));
        }
    }
}
项目:weixin-java-tools    文件:WxCpDemoServer.java   
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();
}
项目:weixin-java-tools    文件:WxMpDemoServer.java   
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();
}
项目:weixin-java-tools-for-JDK6    文件:WxCpDemoServer.java   
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();
}
项目:weixin-java-tools-for-JDK6    文件:WxMpDemoServer.java   
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();
}
项目:git-lfs-azureblob    文件:LfsServer.java   
/**
 * 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)
    );
}
项目:berrysys-ussdgw    文件:DialogListener.java   
/**
 * 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();
}
项目:Blitz-2015    文件:ReferenceMain.java   
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) {
        }
    });
}
项目:Blitz-2015    文件:ThriftHttpTest.java   
@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();
}
项目:live-chat-engine    文件:FrontAndChats_IntegrationTest.java   
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;
}
项目:performance-test-harness-for-geoevent    文件:WebsocketServerEventProducer.java   
private void setup(int port) {
    if (server == null) {
        server = new Server(port);
        ServletHandler servletHandler = new ServletHandler();
        webSocketServlet = new WebsocketOutboundServlet();
        ServletHolder holder = new ServletHolder(webSocketServlet);
        servletHandler.addServletWithMapping(holder, uri + URI_SUFFIX);

        ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setBaseResource(Resource.newClassPathResource("com/example/docroot/"));

        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{servletHandler, resourceHandler, new DefaultHandler()});
        server.setHandler(handlers);
        try {
            server.start();
            String url = "ws://localhost:" + port + uri;
            System.out.println(ImplMessages.getMessage("WS_SERVER_START_MSG", url));
            // add the shutdown hook
            Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdown()));
        } catch (Exception error) {
            System.out.println(ImplMessages.getMessage("INIT_FAILURE", getClass().getName(), error.getMessage()));
            error.printStackTrace();
        }
    }
}
项目:performance-test-harness-for-geoevent    文件:WebsocketServerEventConsumer.java   
private void setup(int port) {
    if (server == null) {
        server = new Server(port);
        ServletHandler servletHandler = new ServletHandler();
        webSocketServlet = new WebsocketOutboundServlet(message -> receive(message));
        ServletHolder holder = new ServletHolder(webSocketServlet);
        servletHandler.addServletWithMapping(holder, uri + URI_SUFFIX);

        ResourceHandler resourceHandler = new ResourceHandler();
        resourceHandler.setBaseResource(Resource.newClassPathResource("com/example/docroot/"));

        HandlerList handlers = new HandlerList();
        handlers.setHandlers(new Handler[]{servletHandler, resourceHandler, new DefaultHandler()});
        server.setHandler(handlers);
        try {
            server.start();
            String url = "ws://localhost:" + port + uri;
            System.out.println(ImplMessages.getMessage("WS_SERVER_START_MSG", url));
            // add the shutdown hook
            Runtime.getRuntime().addShutdownHook(new Thread(() -> shutdown()));
        } catch (Exception error) {
            System.out.println(ImplMessages.getMessage("INIT_FAILURE", getClass().getName(), error.getMessage()));
            error.printStackTrace();
        }
    }
}
项目:CrococryptFile    文件:JettyStart.java   
public static boolean startup(int port) {
    Server server = new Server(port);

       ServletHandler handler = new ServletHandler();
       handler.addServletWithMapping(CrocoWebDecryptor.class, "/*");

    for(Connector y : server.getConnectors()) {
        for(ConnectionFactory x  : y.getConnectionFactories()) {
            if(x instanceof HttpConnectionFactory) {
                ((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(false);
            }
        }
    }

    server.setHandler(handler);
    try {
        server.start();
        return true;
    } catch (Exception e) {
        try {
            server.stop();
        } catch (Exception e2) {}
    }

    return false;
}
项目:armeria    文件:ThriftOverHttpClientTServletIntegrationTest.java   
private static Server startHttp1() throws Exception {
    Server server = new Server(0);

    ServletHandler handler = new ServletHandler();
    handler.addServletWithMapping(newServletHolder(thriftServlet), TSERVLET_PATH);
    handler.addServletWithMapping(newServletHolder(rootServlet), "/");
    handler.addFilterWithMapping(new FilterHolder(new ConnectionCloseFilter()), "/*",
                                 EnumSet.of(DispatcherType.REQUEST));

    server.setHandler(handler);

    for (Connector c : server.getConnectors()) {
        for (ConnectionFactory f : c.getConnectionFactories()) {
            for (String p : f.getProtocols()) {
                if (p.startsWith("h2c")) {
                    fail("Attempted to create a Jetty server without HTTP/2 support, but failed: " +
                         f.getProtocols());
                }
            }
        }
    }

    server.start();
    return server;
}
项目:armeria    文件:ThriftOverHttpClientTServletIntegrationTest.java   
private static Server startHttp2() throws Exception {
    Server server = new Server();
    // Common HTTP configuration.
    HttpConfiguration config = new HttpConfiguration();

    // HTTP/1.1 support.
    HttpConnectionFactory http1 = new HttpConnectionFactory(config);

    // HTTP/2 cleartext support.
    HTTP2CServerConnectionFactory http2c = new HTTP2CServerConnectionFactory(config);

    // Add the connector.
    ServerConnector connector = new ServerConnector(server, http1, http2c);
    connector.setPort(0);
    server.addConnector(connector);

    // Add the servlet.
    ServletHandler handler = new ServletHandler();
    handler.addServletWithMapping(newServletHolder(thriftServlet), TSERVLET_PATH);
    server.setHandler(handler);

    // Start the server.
    server.start();
    return server;
}
项目:CrococryptQuerl    文件:JettyLaunch.java   
public static boolean startup(int port) {
    Server server = new Server(port);

       ServletHandler handler = new ServletHandler();
       handler.addServletWithMapping(Querler.class, "/*");

    for(Connector y : server.getConnectors()) {
        for(ConnectionFactory x  : y.getConnectionFactories()) {
            if(x instanceof HttpConnectionFactory) {
                ((HttpConnectionFactory)x).getHttpConfiguration().setSendServerVersion(false);
            }
        }
    }

    server.setHandler(handler);
    try {
        server.start();
        return true;
    } catch (Exception e) {
        try {
            server.stop();
        } catch (Exception e2) {}
    }

    return false;
}
项目:mmp    文件:WxCpDemoServer.java   
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();
}
项目:mmp    文件:WxMpDemoServer.java   
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();
}
项目:FHIR-Server    文件:LoggingInterceptorTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyProvider patientProvider = new DummyProvider();

    ServletHandler proxyHandler = new ServletHandler();
    RestfulServer servlet = new RestfulServer();
    ourCtx = servlet.getFhirContext();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    ourCtx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
}
项目:FHIR-Server    文件:IncludeTest.java   
@BeforeClass
public static void beforeClass() throws Exception {

    ourCtx = new FhirContext();
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    RestfulServer servlet = new RestfulServer();
    servlet.setFhirContext(ourCtx);
       servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
    servlet.setResourceProviders(patientProvider, new DummyDiagnosticReportResourceProvider());
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:CustomTypeTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    ourServlet = new RestfulServer();
    ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());

    ourServlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(ourServlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

    FhirContext fhirContext = ourServlet.getFhirContext();
    fhirContext.getResourceDefinition(ExtendedPatient.class);

}
项目:FHIR-Server    文件:SortTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    RestfulServer servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:ExceptionInterceptorMethodTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:LoggingInterceptorTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:ExceptionHandlingInterceptorTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

    myInterceptor = new ExceptionHandlingInterceptor();
    servlet.registerInterceptor(myInterceptor);
}
项目:FHIR-Server    文件:AuditingInterceptorTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:DefaultEncodingTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    ServletHandler proxyHandler = new ServletHandler();
    ourRestfulServer = new RestfulServer();
    ourCtx = ourRestfulServer.getFhirContext();
    ourRestfulServer.setResourceProviders(new PatientProvider());
    ServletHolder servletHolder = new ServletHolder(ourRestfulServer);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:ResourceProviderWithNoMethodsTest.java   
@Test
public void testNoAnnotatedMethods() throws Exception {
    int port = PortUtil.findFreePort();
    ourServer = new Server(port);

    ResourceProvider patientProvider = new ResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    RestfulServer servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);

    try {
        ourServer.start();
        fail();
    } catch (ServletException e) {
        assertEquals(e.getCause().getClass(), ConfigurationException.class);
    }
}
项目:FHIR-Server    文件:ResourceProviderWithNoMethodsTest.java   
@Test
public void testNonPublicMethod() throws Exception {
    int port = PortUtil.findFreePort();
    ourServer = new Server(port);

    NonPublicMethodProvider patientProvider = new NonPublicMethodProvider();

    ServletHandler proxyHandler = new ServletHandler();
    RestfulServer servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);

    try {
        ourServer.start();
        fail();
    } catch (ServletException e) {
        assertEquals(e.getCause().getClass(), ConfigurationException.class);
    }
}
项目:FHIR-Server    文件:CreateTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    PatientProvider patientProvider = new PatientProvider();

    ourReportProvider = new DiagnosticReportProvider();

    ServletHandler proxyHandler = new ServletHandler();
    RestfulServer servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider, ourReportProvider, new DummyAdverseReactionResourceProvider(), new CustomObservationProvider());
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:MethodPriorityTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    ServletHandler proxyHandler = new ServletHandler();
    ourServlet = new RestfulServer();
    ourServlet.setFhirContext(ourCtx);
    ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());

    ServletHolder servletHolder = new ServletHolder(ourServlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:TagsServerTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);
    ourCtx = new FhirContext(Patient.class);

    ourProvider = new DummyProvider();

    ServletHandler proxyHandler = new ServletHandler();
    RestfulServer servlet = new RestfulServer();
    servlet.setPlainProviders(ourProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}
项目:FHIR-Server    文件:ExceptionTest.java   
@BeforeClass
public static void beforeClass() throws Exception {
    ourPort = PortUtil.findFreePort();
    ourServer = new Server(ourPort);

    DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();

    ServletHandler proxyHandler = new ServletHandler();
    servlet = new RestfulServer();
    servlet.setResourceProviders(patientProvider);
    ServletHolder servletHolder = new ServletHolder(servlet);
    proxyHandler.addServletWithMapping(servletHolder, "/*");
    ourServer.setHandler(proxyHandler);
    ourServer.start();

    PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
    HttpClientBuilder builder = HttpClientBuilder.create();
    builder.setConnectionManager(connectionManager);
    ourClient = builder.build();

}