org.mortbay.jetty.Server.addConnector()方法的使用及代码示例

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

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

Server.addConnector介绍

暂无

代码示例

代码示例来源:origin: azkaban/azkaban

@Override
public Server get() {
 requireNonNull(this.props);
 final int maxThreads = this.props
   .getInt("jetty.maxThreads", Constants.DEFAULT_JETTY_MAX_THREAD_COUNT);
 final boolean useSsl = this.props.getBoolean("jetty.use.ssl", true);
 final int port;
 final Server server = new Server();
 if (useSsl) {
  final int sslPortNumber = this.props
    .getInt("jetty.ssl.port", Constants.DEFAULT_SSL_PORT_NUMBER);
  port = sslPortNumber;
  server.addConnector(getSslSocketConnector(sslPortNumber));
 } else {
  port = this.props.getInt("jetty.port", Constants.DEFAULT_PORT_NUMBER);
  server.addConnector(getSocketConnector(port));
 }
 // setting stats configuration for connectors
 setStatsOnConnectors(server);
 logger.info(String.format(
   "Starting %sserver on port: %d # Max threads: %d", useSsl ? "SSL " : "", port, maxThreads));
 return server;
}

代码示例来源:origin: testcontainers/testcontainers-java

@Before
public void setupLocalServer() throws Exception {
  // Set up a local Jetty HTTP server
  Server server = new Server();
  server.addConnector(new SocketConnector());
  ResourceHandler resourceHandler = new ResourceHandler();
  resourceHandler.setResourceBase("src/test/resources/server");
  server.addHandler(resourceHandler);
  server.start();
  // The server will have a random port assigned, so capture that
  localPort = server.getConnectors()[0].getLocalPort();
}

代码示例来源:origin: soabase/exhibitor

public ExhibitorMain(BackupProvider backupProvider, ConfigProvider configProvider, ExhibitorArguments.Builder builder, int httpPort, String listenAddress, SecurityHandler security, SecurityArguments securityArguments) throws Exception
{
  HashUserRealm realm = makeRealm(securityArguments);
  if ( securityArguments.getRemoteAuthSpec() != null )
  {
    addRemoteAuth(builder, securityArguments.getRemoteAuthSpec());
  }
  builder.shutdownProc(makeShutdownProc(this));
  exhibitor = new Exhibitor(configProvider, null, backupProvider, builder.build());
  exhibitor.start();
  DefaultResourceConfig   application = JerseySupport.newApplicationConfig(new UIContext(exhibitor));
  ServletContainer        container = new ServletContainer(application);
  server = new Server();
  SocketConnector http = new SocketConnector();
  http.setHost(listenAddress);
  http.setPort(httpPort);
  server.addConnector(http);
  Context root = new Context(server, "/", Context.SESSIONS);
  root.addFilter(ExhibitorServletFilter.class, "/", Handler.ALL);
  root.addServlet(new ServletHolder(container), "/*");
  if ( security != null )
  {
    root.setSecurityHandler(security);
  }
  else if ( securityArguments.getSecurityFile() != null )
  {
    addSecurityFile(realm, securityArguments.getSecurityFile(), root);
  }
}

代码示例来源:origin: io.hops/hadoop-common

private void loadListeners() {
 for (ListenerInfo li : listeners) {
  webServer.addConnector(li.listener);
 }
}

代码示例来源:origin: io.hops/hadoop-common

private void loadListeners() {
 for (Connector c : listeners) {
  webServer.addConnector(c);
 }
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

private void loadListeners() {
 for (Connector c : listeners) {
  webServer.addConnector(c);
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

private void loadListeners() {
 for (Connector c : listeners) {
  webServer.addConnector(c);
 }
}

代码示例来源:origin: org.apache.avro/avro-ipc

public void addConnector(Connector connector) {
 server.addConnector(connector);
}

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

public void start() {
 try {
  server.addConnector(sock);
  server.setHandler(handler);
  server.start();
 } catch (Exception e) {
  stop();
  throw new RuntimeException(e);
 }
}

代码示例来源:origin: feroult/yawp

protected void startServer() {
  try {
    server = new Server();
    server.addConnector(createConnector());
    server.setHandler(helper.createWebApp());
    server.start();
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.apache.reef/reef-webserver

private Server tryPort(final int portNumber) throws Exception {
 Server srv = new Server();
 final Connector connector = new SocketConnector();
 connector.setHost(addressProvider.getLocalAddress());
 connector.setPort(portNumber);
 srv.addConnector(connector);
 try {
  srv.start();
  LOG.log(Level.INFO, "Jetty Server started with port: {0}", portNumber);
 } catch (final BindException ex) {
  srv = null;
  LOG.log(Level.FINEST, "Cannot use port: {0}. Will try another", portNumber);
 }
 return srv;
}

代码示例来源:origin: org.apache.avro/avro-ipc

/** Constructs a server to run with the given connector. */
public HttpServer(ResponderServlet servlet, Connector connector) throws IOException {
 this.server = new org.mortbay.jetty.Server();
 server.addConnector(connector);
 new Context(server, "/").addServlet(new ServletHolder(servlet), "/*");
}

代码示例来源:origin: info.aduna.commons/aduna-commons-net-http-server-embedded

public EmbeddedServer(String host, int port, String contextPath, String warPath) {
  System.clearProperty("DEBUG");
  jetty = new Server();
  Connector conn = new BlockingChannelConnector();
  conn.setHost(host);
  conn.setPort(port);
  jetty.addConnector(conn);
  WebAppContext webapp = new WebAppContext();
  webapp.setContextPath(contextPath);
  webapp.setWar(warPath);
  jetty.addHandler(webapp);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-test-framework

public JavaNetReverseProxy(File cacheFolder) throws Exception {
  this.cacheFolder = cacheFolder;
  cacheFolder.mkdirs();
  server = new Server();
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  server.setHandler(contexts);
  Context root = new Context(contexts, "/", Context.SESSIONS);
  root.addServlet(new ServletHolder(this), "/");
  SocketConnector connector = new SocketConnector();
  server.addConnector(connector);
  server.start();
  localPort = connector.getLocalPort();
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-test-harness

public JavaNetReverseProxy(File cacheFolder) throws Exception {
  this.cacheFolder = cacheFolder;
  cacheFolder.mkdirs();
  server = new Server();
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  server.setHandler(contexts);
  Context root = new Context(contexts, "/", Context.SESSIONS);
  root.addServlet(new ServletHolder(this), "/");
  SocketConnector connector = new SocketConnector();
  server.addConnector(connector);
  server.start();
  localPort = connector.getLocalPort();
}

代码示例来源:origin: org.eclipse.hudson/hudson-test-framework

public JavaNetReverseProxy(File cacheFolder) throws Exception {
  this.cacheFolder = cacheFolder;
  cacheFolder.mkdirs();
  server = new Server();
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  server.setHandler(contexts);
  Context root = new Context(contexts, "/", Context.SESSIONS);
  root.addServlet(new ServletHolder(this), "/");
  SocketConnector connector = new SocketConnector();
  server.addConnector(connector);
  server.start();
  localPort = connector.getLocalPort();
}

代码示例来源:origin: org.restlet/org.restlet.ext.jetty

@Override
public void start() throws Exception {
  if (this.connector == null) {
    this.connector = createConnector();
    configure(this.connector);
    getWrappedServer().addConnector(this.connector);
  }
  getWrappedServer().start();
  setEphemeralPort(this.connector.getLocalPort());
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-test-harness

/**
 * Prepares a webapp hosting environment to get {@link ServletContext} implementation
 * that we need for testing.
 */
protected ServletContext createWebServer() throws Exception {
  server = new Server();
  WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
  context.setClassLoader(getClass().getClassLoader());
  context.setConfigurations(new Configuration[]{new WebXmlConfiguration(),new NoListenerConfiguration()});
  server.setHandler(context);
  context.setMimeTypes(MIME_TYPES);
  SocketConnector connector = new SocketConnector();
  server.addConnector(connector);
  server.addUserRealm(configureUserRealm());
  server.start();
  localPort = connector.getLocalPort();
  return context.getServletContext();
}

代码示例来源:origin: org.apache.avro/avro-ipc

/** Constructs a server to run on the named port on the specified address. */
public HttpServer(ResponderServlet servlet, String bindAddress, int port) throws IOException {
 this.server = new org.mortbay.jetty.Server();
 SelectChannelConnector connector = new SelectChannelConnector();
 connector.setLowResourceMaxIdleTime(10000);
 connector.setAcceptQueueSize(128);
 connector.setResolveNames(false);
 connector.setUseDirectBuffers(false);
 if (bindAddress != null) {
  connector.setHost(bindAddress);
 }
 connector.setPort(port);
 server.addConnector(connector);
 new Context(server, "/").addServlet(new ServletHolder(servlet), "/*");
}

代码示例来源:origin: stapler/stapler

@Override
protected void setUp() throws Exception {
  super.setUp();
  server = new Server();
  server.setHandler(new WebAppContext("/noroot", ""));
  final Context context = new Context(server, getContextPath(), Context.SESSIONS);
  configure(context);
  server.setHandler(context);
  SocketConnector connector = new SocketConnector();
  server.addConnector(connector);
  server.start();
  url = new URL("http://localhost:"+connector.getLocalPort()+getContextPath()+"/");
  servletContext = context.getServletContext();
  webApp = WebApp.get(servletContext);
  // export the test object as the root as a reasonable default.
  webApp.setApp(this);
}

相关文章