org.eclipse.jetty.server.Server.getURI()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中org.eclipse.jetty.server.Server.getURI()方法的一些代码示例,展示了Server.getURI()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.getURI()方法的具体详情如下:
包路径:org.eclipse.jetty.server.Server
类名称:Server
方法名:getURI

Server.getURI介绍

暂无

代码示例

代码示例来源:origin: loklak/loklak_server

public static String getServerURI() {
  return server.getURI().toASCIIString();
}

代码示例来源:origin: SonarSource/sonarqube

private Response call(String path) throws Exception {
 OkHttpClient client = new OkHttpClient();
 Request request = new Request.Builder()
  .url(jetty.getURI().resolve(path).toString())
  .build();
 return client.newCall(request).execute();
}

代码示例来源:origin: apache/incubator-druid

@Test
 public void testBindOnHost() throws Exception
 {
  Assert.assertEquals("localhost", server.getURI().getHost());

  final URL url = new URL("http://localhost:" + port + "/default");
  final HttpURLConnection get = (HttpURLConnection) url.openConnection();
  Assert.assertEquals(DEFAULT_RESPONSE_CONTENT, IOUtils.toString(get.getInputStream(), StandardCharsets.UTF_8));

  final HttpURLConnection post = (HttpURLConnection) url.openConnection();
  post.setRequestMethod("POST");
  Assert.assertEquals(DEFAULT_RESPONSE_CONTENT, IOUtils.toString(post.getInputStream(), StandardCharsets.UTF_8));
 }
}

代码示例来源:origin: allure-framework/allure1

@Override
protected void runUnsafe() throws Exception {
  Path reportDirectory = getReportDirectoryPath();
  if (Files.notExists(reportDirectory)) {
    throw new AllureCommandException(String.format(
        "Can't open report: directory <%s> doesn't exist.", reportDirectory
    ));
  }
  LOGGER.info("Starting web server for report directory <{}>", reportDirectory);
  Server server = setUpServer();
  server.start();
  openBrowser(server.getURI());
  LOGGER.info("Server started at <{}>. Press <Ctrl+C> to exit ...", server.getURI());
  server.join();
}

代码示例来源:origin: confluentinc/kafka-streams-examples

@SuppressWarnings("unchecked")
@Override
public void start(final String bootstrapServers, final String stateDir) {
 jettyServer = startJetty(port, this);
 port = jettyServer.getURI().getPort(); // update port, in case port was zero
 producer = startProducer(bootstrapServers, ORDERS);
 streams = startKStreams(bootstrapServers);
 log.info("Started Service " + getClass().getSimpleName());
}

代码示例来源:origin: confluentinc/kafka-streams-examples

public static Server startJetty(int port, Object binding) {
 ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
 context.setContextPath("/");
 Server jettyServer = new Server(port);
 jettyServer.setHandler(context);
 ResourceConfig rc = new ResourceConfig();
 rc.register(binding);
 rc.register(JacksonFeature.class);
 ServletContainer sc = new ServletContainer(rc);
 ServletHolder holder = new ServletHolder(sc);
 context.addServlet(holder, "/*");
 try {
  jettyServer.start();
 } catch (Exception e) {
  throw new RuntimeException(e);
 }
 log.info("Listening on " + jettyServer.getURI());
 return jettyServer;
}

代码示例来源:origin: com.yahoo.pulsar/pulsar-discovery-service

public URI getServiceUri() {
  return this.server.getURI();
}

代码示例来源:origin: apache/knox

public URI getURI() {
 return jetty.getURI();
}

代码示例来源:origin: twosigma/webtau

public URI getUri() {
  return server.getURI();
}

代码示例来源:origin: zanata/zanata-platform

public URI getServerBaseUri() {
    return server.getURI();
  }
}

代码示例来源:origin: org.apache.knox/gateway-server

public URI getURI() {
 return jetty.getURI();
}

代码示例来源:origin: net.jangaroo/jangaroo-maven-plugin

public URI getUri() {
 return server.getURI();
}

代码示例来源:origin: com.hortonworks.registries/schema-registry-webservice

public String getLocalURL() {
  return registryApplication.localServer.getURI().toString();
}

代码示例来源:origin: org.apache.knox/gateway-test-utils

public int getPort() {
 return jetty.getURI().getPort();
}

代码示例来源:origin: mesosphere/dcos-commons

/**
 * Returns the server endpoint. Mainly used for testing.
 *
 * @throws IllegalStateException if the server is not running
 */
@VisibleForTesting
URI getURI() {
 if (!server.isRunning()) {
  throw new IllegalStateException("Server is not running");
 }
 return server.getURI();
}

代码示例来源:origin: com.github.mjeanroy/junit-servers-jetty

@Override
public String getScheme() {
  return isStarted() ? server.getURI().getScheme() : super.getScheme();
}

代码示例来源:origin: org.apache.hadoop/hadoop-yarn-server-web-proxy

private String startHttpServer() throws Exception {
 Server server = new Server(0);
 ((QueuedThreadPool)server.getThreadPool()).setMaxThreads(10);
 ServletContextHandler context = new ServletContextHandler();
 context.setContextPath("/foo");
 server.setHandler(context);
 String servletPath = "/bar";
 context.addServlet(new ServletHolder(TestHttpServer.EchoServlet.class),
   servletPath);
 ((ServerConnector)server.getConnectors()[0]).setHost("localhost");
 server.start();
 System.setProperty("sun.net.http.allowRestrictedHeaders", "true");
 return server.getURI().toString() + servletPath;
}

代码示例来源:origin: Netflix/spectator

@BeforeAll
public static void init() throws Exception {
 server = new Server(new InetSocketAddress("localhost", 0));
 ServletContextHandler handler = new ServletContextHandler(server, "/");
 handler.addEventListener(new TestListener());
 handler.addFilter(GuiceFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
 server.setHandler(handler);
 server.start();
 baseUri = server.getURI();
}

代码示例来源:origin: org.rapidpm/testbench-ng-m-container-init-addon-tserver

@Override
public void afterEach(Method testMethod, ExtensionContext context) throws Exception {
 cleanUpPort(context);
 cleanUpIP(context);
 store().apply(context).get(TSERVER_SERVER, Result.class)
   .flatMap((CheckedFunction<Server, String>) server -> {
    URI serverURI = server.getURI();
    server.stop();
    return serverURI.toASCIIString();
   }).ifPresentOrElse(serverURI -> logger().info("Stopped server on : " + serverURI),
     failed -> logger().warning("no active server available to stop " + failed));
 store().apply(context).remove(TSERVER_SERVER);
}

代码示例来源:origin: apache/activemq-artemis

private void deployAndconfigureRESTService(String warFileName) throws Exception {
 jmsServer.createTopic(false, "ordersTopic", (String[]) null);
 File warFile = getResourceFile("/rest/" + warFileName, warFileName);
 deployWebApp("/restapp", warFile);
 server.start();
 String uri = server.getURI().toASCIIString();
 System.out.println("Sever started with uri: " + uri);
 restConnection = new RestAMQConnection(uri);
}

相关文章