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


Java Connector.setHost方法代码示例

本文整理汇总了Java中org.mortbay.jetty.Connector.setHost方法的典型用法代码示例。如果您正苦于以下问题:Java Connector.setHost方法的具体用法?Java Connector.setHost怎么用?Java Connector.setHost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.mortbay.jetty.Connector的用法示例。


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

示例1: startup

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
public void startup() {
    if (adminPort > 0) {
        Connector httpConnector = new SelectChannelConnector();
        httpConnector.setHost(adminHost);
        httpConnector.setPort(adminPort);
        adminServer.addConnector(httpConnector);
    }

    if (adminServer.getConnectors() == null
            || adminServer.getConnectors().length == 0) {
        adminServer = null;
        log.warn("Admin console not started due to configuration error.");
        return;
    }

    adminServer
            .setHandlers(new Handler[] { contexts, new DefaultHandler() });

    try {
        adminServer.start();
        httpStarted = true;
        log.debug("Admin console started.");
    } catch (Exception e) {
        log.error("Could not start admin conosle server", e);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:27,代码来源:AdminConsole.java

示例2: getRedirectUri

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
@Override
public String getRedirectUri() throws IOException {
  if (port == -1) {
    port = getUnusedPort();
  }
  server = new Server(port);
  for (Connector c : server.getConnectors()) {
    c.setHost(host);
  }
  server.addHandler(new CallbackHandler());
  try {
    server.start();
  } catch (Exception e) {
    Throwables.propagateIfPossible(e);
    throw new IOException(e);
  }
  return "http://" + host + ":" + port + CALLBACK_PATH;
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:19,代码来源:LocalServerReceiver.java

示例3: putUpJettyServer

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
private void putUpJettyServer() throws IOException {
  if (!conf.getBoolean("hbase.master.infoserver.redirect", true)) {
    return;
  }
  int infoPort = conf.getInt("hbase.master.info.port.orig",
    HConstants.DEFAULT_MASTER_INFOPORT);
  // -1 is for disabling info server, so no redirecting
  if (infoPort < 0 || infoServer == null) {
    return;
  }

  RedirectServlet.regionServerInfoPort = infoServer.getPort();
  masterJettyServer = new org.mortbay.jetty.Server();
  Connector connector = new SelectChannelConnector();
  connector.setHost(conf.get("hbase.master.info.bindAddress", "0.0.0.0"));
  connector.setPort(infoPort);
  masterJettyServer.addConnector(connector);
  masterJettyServer.setStopAtShutdown(true);
  Context context = new Context(masterJettyServer, "/", Context.NO_SESSIONS);
  context.addServlet(RedirectServlet.class, "/*");
  try {
    masterJettyServer.start();
  } catch (Exception e) {
    throw new IOException("Failed to start redirecting jetty server", e);
  }
}
 
开发者ID:shenli-uiuc,项目名称:PyroDB,代码行数:27,代码来源:HMaster.java

示例4: getRedirectUri

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
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";
}
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:26,代码来源:CustomLocalServerReceiver.java

示例5: putUpJettyServer

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
private int putUpJettyServer() throws IOException {
  if (!conf.getBoolean("hbase.master.infoserver.redirect", true)) {
    return -1;
  }
  int infoPort = conf.getInt("hbase.master.info.port.orig",
    HConstants.DEFAULT_MASTER_INFOPORT);
  // -1 is for disabling info server, so no redirecting
  if (infoPort < 0 || infoServer == null) {
    return -1;
  }
  String addr = conf.get("hbase.master.info.bindAddress", "0.0.0.0");
  if (!Addressing.isLocalAddress(InetAddress.getByName(addr))) {
    String msg =
        "Failed to start redirecting jetty server. Address " + addr
            + " does not belong to this host. Correct configuration parameter: "
            + "hbase.master.info.bindAddress";
    LOG.error(msg);
    throw new IOException(msg);
  }

  RedirectServlet.regionServerInfoPort = infoServer.getPort();
  if(RedirectServlet.regionServerInfoPort == infoPort) {
    return infoPort;
  }
  masterJettyServer = new org.mortbay.jetty.Server();
  Connector connector = new SelectChannelConnector();
  connector.setHost(addr);
  connector.setPort(infoPort);
  masterJettyServer.addConnector(connector);
  masterJettyServer.setStopAtShutdown(true);
  Context context = new Context(masterJettyServer, "/", Context.NO_SESSIONS);
  context.addServlet(RedirectServlet.class, "/*");
  try {
    masterJettyServer.start();
  } catch (Exception e) {
    throw new IOException("Failed to start redirecting jetty server", e);
  }
  return connector.getLocalPort();
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:40,代码来源:HMaster.java

示例6: putUpJettyServer

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
private int putUpJettyServer() throws IOException {
    if (!conf.getBoolean("hbase.master.infoserver.redirect", true)) {
        return -1;
    }
    int infoPort = conf.getInt("hbase.master.info.port.orig",
            HConstants.DEFAULT_MASTER_INFOPORT);
    // -1 is for disabling info server, so no redirecting
    if (infoPort < 0 || infoServer == null) {
        return -1;
    }
    String addr = conf.get("hbase.master.info.bindAddress", "0.0.0.0");
    if (!Addressing.isLocalAddress(InetAddress.getByName(addr))) {
        String msg =
                "Failed to start redirecting jetty server. Address " + addr
                        + " does not belong to this host. Correct configuration parameter: "
                        + "hbase.master.info.bindAddress";
        LOG.error(msg);
        throw new IOException(msg);
    }

    RedirectServlet.regionServerInfoPort = infoServer.getPort();
    masterJettyServer = new org.mortbay.jetty.Server();
    Connector connector = new SelectChannelConnector();
    connector.setHost(addr);
    connector.setPort(infoPort);
    masterJettyServer.addConnector(connector);
    masterJettyServer.setStopAtShutdown(true);
    Context context = new Context(masterJettyServer, "/", Context.NO_SESSIONS);
    context.addServlet(RedirectServlet.class, "/*");
    try {
        masterJettyServer.start();
    } catch (Exception e) {
        throw new IOException("Failed to start redirecting jetty server", e);
    }
    return connector.getLocalPort();
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:37,代码来源:HMaster.java

示例7: build

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
public HttpServer2 build() throws IOException {
  Preconditions.checkNotNull(name, "name is not set");
  Preconditions.checkState(!endpoints.isEmpty(), "No endpoints specified");

  if (hostName == null) {
    hostName = endpoints.get(0).getHost();
  }

  if (this.conf == null) {
    conf = new Configuration();
  }

  HttpServer2 server = new HttpServer2(this);

  if (this.securityEnabled) {
    server.initSpnego(conf, hostName, usernameConfKey, keytabConfKey);
  }

  for (URI ep : endpoints) {
    final Connector listener;
    String scheme = ep.getScheme();
    if ("http".equals(scheme)) {
      listener = HttpServer2.createDefaultChannelConnector();
    } else if ("https".equals(scheme)) {
      listener = createHttpsChannelConnector();

    } else {
      throw new HadoopIllegalArgumentException(
          "unknown scheme for endpoint:" + ep);
    }
    listener.setHost(ep.getHost());
    listener.setPort(ep.getPort() == -1 ? 0 : ep.getPort());
    server.addListener(listener);
  }
  server.loadListeners();
  return server;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:38,代码来源:HttpServer2.java

示例8: startServer

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
/**
 * Starts Jetty.
 *
 * @param host        the host to bound.
 * @param port        the port to bound.
 * @param contextPath the context path to bound.
 */
private static void startServer(final String host, final int port, final String contextPath) {
    final Logger log = LoggerFactory.getLogger(JaptProxyServer.class);
    log.info("Starting Japt-Proxy {} on host {} port {} using context path '{}'",
        Util.VERSION, StringUtils.defaultIfEmpty(host, "*"), port, contextPath);

    // Spring startup
    final ClassPathXmlApplicationContext classPathXmlApplicationContext =
        new ClassPathXmlApplicationContext("master.xml", "standalone.xml");
    classPathXmlApplicationContext.registerShutdownHook();

    // Jetty startup
    final Server server = new Server();

    final Connector connector = new BlockingChannelConnector();

    if (!StringUtils.isBlank(host)) {
        connector.setHost(host);
    }

    connector.setPort(port);
    server.setConnectors(new Connector[]{connector});

    server.setStopAtShutdown(true);

    final Context root = new Context(server, contextPath);
    final JaptProxyServlet japtProxyServlet =
        classPathXmlApplicationContext
            .getBean("japtProxyServlet", JaptProxyServlet.class);
    root.addServlet(new ServletHolder(japtProxyServlet), "/*");

    try {
        server.start();
    } catch (final Exception e) {
        // shame on Jetty's exception handling
        throw new IllegalStateException("Couldn't start HTTP engine", e);
    }
}
 
开发者ID:osiegmar,项目名称:japt-proxy,代码行数:45,代码来源:JaptProxyServer.java

示例9: startup

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
/**
 * Starts the Jetty server instance.
 */
public void startup() {
    if (adminPort > 0) {
        Connector httpConnector = new SelectChannelConnector();
        httpConnector.setHost(adminHost);
        httpConnector.setPort(adminPort);
        adminServer.addConnector(httpConnector);
    }

    if (adminServer.getConnectors() == null
            || adminServer.getConnectors().length == 0) {
        adminServer = null;
        log.warn("Admin console not started due to configuration error.");
        return;
    }

    adminServer
            .setHandlers(new Handler[] { contexts, new DefaultHandler() });

    try {
        adminServer.start();
        httpStarted = true;
        log.debug("Admin console started.");
    } catch (Exception e) {
        log.error("Could not start admin conosle server", e);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:30,代码来源:AdminConsole.java

示例10: startup

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
public void startup() {
    // Create connector for http traffic if it's enabled.
    if (adminPort > 0) {
        Connector httpConnector = new SelectChannelConnector();
        httpConnector.setHost(adminHost);
        httpConnector.setPort(adminPort);
        adminServer.addConnector(httpConnector);
    }

    // Make sure that at least one connector was registered.
    if (adminServer.getConnectors() == null
            || adminServer.getConnectors().length == 0) {
        adminServer = null;
        log.warn("Admin console not started due to configuration error.");
        return;
    }

    adminServer
            .setHandlers(new Handler[] { contexts, new DefaultHandler() });

    try {
        adminServer.start();
        httpStarted = true;
        log.debug("Admin Console started.");
    } catch (Exception e) {
        log.error("Could not start admin conosle server", e);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:29,代码来源:AdminConsole.java

示例11: getRedirectUri

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
@Override
public String getRedirectUri() throws Exception {
    int port = LocalServerReceiver.getUnusedPort();
    this.server = new Server(port);
    for (Connector c : this.server.getConnectors()) {
        c.setHost("localhost");
    }
    this.server.addHandler(new CallbackHandler());
    this.server.start();
    return "http://localhost:" + port + LocalServerReceiver.CALLBACK_PATH;

}
 
开发者ID:jonathanswenson,项目名称:starschema-bigquery-jdbc,代码行数:13,代码来源:LocalServerReceiver.java

示例12: tryPort

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:reef,代码行数:16,代码来源:HttpServerImpl.java

示例13: createConnector

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
/**
 *
 * @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;
}
 
开发者ID:opoo,项目名称:opoopress,代码行数:16,代码来源:AbstractServerMojo.java

示例14: startUp

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
@Override
protected void startUp() throws Exception {
  // setup the jetty config
  ServletHolder sh = new ServletHolder(ServletContainer.class);
  sh.setInitParameter("com.sun.jersey.config.property.packages", "com.twitter.hraven.rest");
  sh.setInitParameter(JSONConfiguration.FEATURE_POJO_MAPPING, "true");

  server = new Server();

  Connector connector = new SelectChannelConnector();
  connector.setPort(this.port);
  connector.setHost(address);

  server.addConnector(connector);

  // TODO: in the future we may want to provide settings for the min and max threads
  // Jetty sets the default max thread number to 250, if we don't set it.
  //
  QueuedThreadPool threadPool = new QueuedThreadPool();
  server.setThreadPool(threadPool);

  server.setSendServerVersion(false);
  server.setSendDateHeader(false);
  server.setStopAtShutdown(true);
  // set up context
  Context context = new Context(server, "/", Context.SESSIONS);
  context.addServlet(sh, "/*");

  // start server
  server.start();
}
 
开发者ID:twitter,项目名称:hraven,代码行数:32,代码来源:RestServer.java

示例15: startServer

import org.mortbay.jetty.Connector; //导入方法依赖的package包/类
private void startServer() throws Exception {
	server = new Server(port);
	for (Connector c : server.getConnectors()) {
		c.setHost(host);
	}

	server.addHandler(new CallbackHandler());
	try {
		server.start();
	} catch (Exception e) {
		throw new IOException(e);
	}

}
 
开发者ID:3pillarlabs,项目名称:socialauth,代码行数:15,代码来源:GenerateToken.java


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