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

x33g5p2x  于2022-01-18 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(126)

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

Connector.setHost介绍

暂无

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

public String getRedirectUri() throws IOException {
 if ( this.port == -1 ) {
  this.port = getUnusedPort();
 }
 this.server = new Server( this.port );
 Connector[] arr$ = this.server.getConnectors();
 int len$ = arr$.length;
 for ( int i$ = 0; i$ < len$; ++i$ ) {
  Connector c = arr$[i$];
  c.setHost( this.host );
 }
 this.server.addHandler( new CustomLocalServerReceiver.CallbackHandler() );
 try {
  this.server.start();
 } catch ( Exception var5 ) {
  Throwables.propagateIfPossible( var5 );
  throw new IOException( var5 );
 }
 return "http://" + this.host + ":" + this.port + "/Callback/success.html";
}

代码示例来源:origin: tjake/Solandra

public JettySolandraRunner( String context, int port, String host)
{

 this.context = context;
 server = new Server( port );   
 server.getConnectors()[0].setHost(host);

 server.setStopAtShutdown( true );
 // Initialize the servlets
 Context root = new Context( server, context, Context.SESSIONS );
 
 // for some reason, there must be a servlet for this to get applied
 root.addServlet( Servlet404.class, "/*" );
 dispatchFilter = root.addFilter( SolandraDispatchFilter.class, "*", Handler.REQUEST );
}

代码示例来源:origin: rhuss/jolokia

private Server getServer(MuleAgentConfig pConfig) {
  Server newServer = new Server();
  Connector connector = new SelectChannelConnector();
  if (pConfig.getHost() != null) {
    connector.setHost(pConfig.getHost());
  }
  connector.setPort(pConfig.getPort());
  newServer.setConnectors(new Connector[]{connector});
  return newServer;
}

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-standalone

private void prepareConnector() {
  String port = command.getOptionValue("port", "8080");
  connector.setPort(Integer.parseInt(port));
  String host = command.getOptionValue("host");
  if (host != null) {
    connector.setHost(host);
  }
}

代码示例来源:origin: jetoile/hadoop-unit

/**
 * Start the servlet container. The container starts on a free port.
 *
 * @throws Exception thrown if the container could not start.
 */
public void start() throws Exception {
  if (StringUtils.isEmpty(host)) {
    host = InetAddress.getLocalHost().getHostName();
  }
  ServerSocket ss = new ServerSocket(0);
  if (this.port == 0) {
    port = ss.getLocalPort();
  }
  ss.close();
  server.getConnectors()[0].setHost(host);
  server.getConnectors()[0].setPort(port);
  server.start();
  System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
}

代码示例来源:origin: org.apache.commons/commons-vfs2

private void prepareConnector() {
  final String port = command.getOptionValue("port", "8080");
  connector.setPort(Integer.parseInt(port));
  final String host = command.getOptionValue("host");
  if (host != null) {
    connector.setHost(host);
  }
}

代码示例来源:origin: apache/commons-vfs

private void prepareConnector() {
  final String port = command.getOptionValue("port", "8080");
  connector.setPort(Integer.parseInt(port));
  final String host = command.getOptionValue("host");
  if (host != null) {
    connector.setHost(host);
  }
}

代码示例来源:origin: opoo/opoopress

/**
 *
 * @param host localhost, 127.0.0.1 or 0.0.0.0.
 * @param port port
 * @return jetty connector
 */
protected Connector createConnector(String host, int port){
  Connector connector = new SelectChannelConnector();
  if(host != null){
    connector.setHost(host);
  }
  connector.setPort( port );
  connector.setMaxIdleTime(MAX_IDLE_TIME);
  return connector;
}

代码示例来源: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: com.github.jiayuhan-it/hadoop-common

protected Server createJettyServer() {
 try {
  InetAddress localhost = InetAddress.getLocalHost();
  ServerSocket ss = new ServerSocket(0, 50, localhost);
  int port = ss.getLocalPort();
  ss.close();
  jetty = new Server(0);
  jetty.getConnectors()[0].setHost("localhost");
  jetty.getConnectors()[0].setPort(port);
  return jetty;
 } catch (Exception ex) {
  throw new RuntimeException("Could not setup Jetty: " + ex.getMessage(),
    ex);
 }
}

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

protected Server createJettyServer() {
 try {
  InetAddress localhost = InetAddress.getLocalHost();
  ServerSocket ss = new ServerSocket(0, 50, localhost);
  int port = ss.getLocalPort();
  ss.close();
  jetty = new Server(0);
  jetty.getConnectors()[0].setHost("localhost");
  jetty.getConnectors()[0].setPort(port);
  return jetty;
 } catch (Exception ex) {
  throw new RuntimeException("Could not setup Jetty: " + ex.getMessage(),
    ex);
 }
}

代码示例来源:origin: jpotts/alfresco-api-java-examples

@Override
public String getRedirectUri() throws Exception {
 server = new Server(PORT);
 for (Connector c : server.getConnectors()) {
  c.setHost(LOCALHOST);
 }
 server.addHandler(new CallbackHandler());
 server.start();
 return "http://" + LOCALHOST + ":" + PORT + CALLBACK_PATH;
}

代码示例来源:origin: jpotts/alfresco-api-java-examples

@Override
public String getRedirectUri() throws Exception {
 server = new Server(PORT);
 for (Connector c : server.getConnectors()) {
  c.setHost(LOCALHOST);
 }
 server.addHandler(new CallbackHandler());
 server.start();
 return "http://" + LOCALHOST + ":" + PORT + CALLBACK_PATH;
}

代码示例来源: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.jolokia/jolokia-mule

private Server getServer(MuleAgentConfig pConfig) {
  Server newServer = new Server();
  Connector connector = new SelectChannelConnector();
  if (pConfig.getHost() != null) {
    connector.setHost(pConfig.getHost());
  }
  connector.setPort(pConfig.getPort());
  newServer.setConnectors(new Connector[]{connector});
  return newServer;
}

代码示例来源:origin: apache/hadoop-common

protected void start() throws Exception {
 server = new Server(0);
 context = new Context();
 context.setContextPath("/foo");
 server.setHandler(context);
 context.addFilter(new FilterHolder(TestFilter.class), "/*", 0);
 context.addServlet(new ServletHolder(TestServlet.class), "/bar");
 host = "localhost";
 ServerSocket ss = new ServerSocket(0);
 port = ss.getLocalPort();
 ss.close();
 server.getConnectors()[0].setHost(host);
 server.getConnectors()[0].setPort(port);
 server.start();
 System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
}

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

/**
 * Simple http server. Server should send answer with status 200
 */
@BeforeClass
public static void start() throws Exception {
 server = new Server(0);
 Context context = new Context();
 context.setContextPath("/foo");
 server.setHandler(context);
 context.addServlet(new ServletHolder(TestServlet.class), "/bar");
 server.getConnectors()[0].setHost("localhost");
 server.start();
 originalPort = server.getConnectors()[0].getLocalPort();
 LOG.info("Running embedded servlet container at: http://localhost:"
   + originalPort);
}

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

protected void startJetty() throws Exception {
 server = new Server(0);
 context = new Context();
 context.setContextPath("/foo");
 server.setHandler(context);
 context.addFilter(new FilterHolder(TestFilter.class), "/*", 0);
 context.addServlet(new ServletHolder(TestServlet.class), "/bar");
 host = "localhost";
 port = getLocalPort();
 server.getConnectors()[0].setHost(host);
 server.getConnectors()[0].setPort(port);
 server.start();
 System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
}

代码示例来源:origin: hopshadoop/hops

protected void startJetty() throws Exception {
 server = new Server(0);
 context = new Context();
 context.setContextPath("/foo");
 server.setHandler(context);
 context.addFilter(new FilterHolder(TestFilter.class), "/*", 0);
 context.addServlet(new ServletHolder(TestServlet.class), "/bar");
 host = "localhost";
 port = getLocalPort();
 server.getConnectors()[0].setHost(host);
 server.getConnectors()[0].setPort(port);
 server.start();
 System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
}

代码示例来源:origin: hortonworks/registry

protected void startJetty() throws Exception {
  server = new Server(0);
  context = new Context();
  context.setContextPath("/foo");
  server.setHandler(context);
  context.addFilter(new FilterHolder(TestFilter.class), "/*", 0);
  context.addServlet(new ServletHolder(TestServlet.class), "/bar");
  host = "localhost";
  port = getLocalPort();
  server.getConnectors()[0].setHost(host);
  server.getConnectors()[0].setPort(port);
  server.start();
  System.out.println("Running embedded servlet container at: http://" + host + ":" + port);
}

相关文章