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


Java Connector类代码示例

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


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

示例1: checkBindAddress

import org.mortbay.jetty.Connector; //导入依赖的package包/类
private HttpServer2 checkBindAddress(String host, int port, boolean findPort)
    throws Exception {
  HttpServer2 server = createServer(host, port);
  try {
    // not bound, ephemeral should return requested port (0 for ephemeral)
    List<?> listeners = (List<?>) Whitebox.getInternalState(server,
        "listeners");
    Connector listener = (Connector) listeners.get(0);

    assertEquals(port, listener.getPort());
    // verify hostname is what was given
    server.openListeners();
    assertEquals(host, server.getConnectorAddress(0).getHostName());

    int boundPort = server.getConnectorAddress(0).getPort();
    if (port == 0) {
      assertTrue(boundPort != 0); // ephemeral should now return bound port
    } else if (findPort) {
      assertTrue(boundPort > port);
    }
  } catch (Exception e) {
    server.stop();
    throw e;
  }
  return server;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:27,代码来源:TestHttpServer.java

示例2: 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

示例3: createDefaultChannelConnector

import org.mortbay.jetty.Connector; //导入依赖的package包/类
@InterfaceAudience.Private
public static Connector createDefaultChannelConnector() {
  SelectChannelConnector ret = new SelectChannelConnector();
  ret.setLowResourceMaxIdleTime(10000);
  ret.setAcceptQueueSize(128);
  ret.setResolveNames(false);
  ret.setUseDirectBuffers(false);
  if(Shell.WINDOWS) {
    // result of setting the SO_REUSEADDR flag is different on Windows
    // http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
    // without this 2 NN's can start on the same machine and listen on 
    // the same port with indeterminate routing of incoming requests to them
    ret.setReuseAddress(false);
  }
  ret.setHeaderBufferSize(1024*64);
  return ret;
}
 
开发者ID:huiyi-learning,项目名称:hardfs,代码行数:18,代码来源:HttpServer.java

示例4: createDefaultChannelConnector

import org.mortbay.jetty.Connector; //导入依赖的package包/类
@InterfaceAudience.Private
public static Connector createDefaultChannelConnector() {
  SelectChannelConnector ret = new SelectChannelConnector();
  ret.setLowResourceMaxIdleTime(10000);
  ret.setAcceptQueueSize(128);
  ret.setResolveNames(false);
  ret.setUseDirectBuffers(false);
  if(Shell.WINDOWS) {
    // result of setting the SO_REUSEADDR flag is different on Windows
    // http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
    // without this 2 NN's can start on the same machine and listen on
    // the same port with indeterminate routing of incoming requests to them
    ret.setReuseAddress(false);
  }
  ret.setHeaderBufferSize(1024*64);
  return ret;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:HttpServer2.java

示例5: start

import org.mortbay.jetty.Connector; //导入依赖的package包/类
@Override
public void start() {
  jettyServer = new Server();
  //We can use Contexts etc if we have many urls to handle. For one url,
  //specifying a handler directly is the most efficient.
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setReuseAddress(true);
  connector.setPort(port);
  jettyServer.setConnectors(new Connector[] {connector});
  jettyServer.setHandler(new HTTPMetricsHandler());
  try {
    jettyServer.start();
    while (!jettyServer.isStarted()) {
      Thread.sleep(500);
    }
  } catch (Exception ex) {
    LOG.error("Error starting Jetty. JSON Metrics may not be available.", ex);
  }

}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:HTTPMetricsServer.java

示例6: createJettyServer

import org.mortbay.jetty.Connector; //导入依赖的package包/类
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not stop embedded servlet container, " + ex.getMessage(), ex);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestJettyHelper.java

示例7: createDefaultChannelConnector

import org.mortbay.jetty.Connector; //导入依赖的package包/类
@InterfaceAudience.Private
public static Connector createDefaultChannelConnector() {
  SelectChannelConnector ret = new SelectChannelConnectorWithSafeStartup();
  ret.setLowResourceMaxIdleTime(10000);
  ret.setAcceptQueueSize(128);
  ret.setResolveNames(false);
  ret.setUseDirectBuffers(false);
  if(Shell.WINDOWS) {
    // result of setting the SO_REUSEADDR flag is different on Windows
    // http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
    // without this 2 NN's can start on the same machine and listen on 
    // the same port with indeterminate routing of incoming requests to them
    ret.setReuseAddress(false);
  }
  ret.setHeaderBufferSize(1024*64);
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:HttpServer.java

示例8: createDefaultChannelConnector

import org.mortbay.jetty.Connector; //导入依赖的package包/类
@InterfaceAudience.Private
public static Connector createDefaultChannelConnector() {
  SelectChannelConnector ret = new SelectChannelConnectorWithSafeStartup();
  ret.setLowResourceMaxIdleTime(10000);
  ret.setAcceptQueueSize(128);
  ret.setResolveNames(false);
  ret.setUseDirectBuffers(false);
  if(Shell.WINDOWS) {
    // result of setting the SO_REUSEADDR flag is different on Windows
    // http://msdn.microsoft.com/en-us/library/ms740621(v=vs.85).aspx
    // without this 2 NN's can start on the same machine and listen on
    // the same port with indeterminate routing of incoming requests to them
    ret.setReuseAddress(false);
  }
  ret.setHeaderBufferSize(1024*64);
  return ret;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:HttpServer2.java

示例9: createJettyServer

import org.mortbay.jetty.Connector; //导入依赖的package包/类
private Server createJettyServer() {
  try {
    InetAddress localhost = InetAddress.getByName("localhost");
    String host = "localhost";
    ServerSocket ss = new ServerSocket(0, 50, localhost);
    int port = ss.getLocalPort();
    ss.close();
    Server server = new Server(0);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
      server.getConnectors()[0].setPort(port);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setPort(port);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType(keyStoreType);
      c.setKeyPassword(keyStorePassword);
      server.setConnectors(new Connector[] {c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, " + ex.getMessage(), ex);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestJettyHelper.java

示例10: createJettyServer

import org.mortbay.jetty.Connector; //导入依赖的package包/类
private static Server createJettyServer(String keyStore, String password, int inPort) {
  try {
    boolean ssl = keyStore != null;
    String host = "localhost";
    Server server = new Server(inPort);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
    } else {
      SslSocketConnector c = new SslSocketConnectorSecure();
      c.setHost(host);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType("jks");
      c.setKeyPassword(password);
      server.setConnectors(new Connector[]{c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, "
        + ex.getMessage(), ex);
  }
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:23,代码来源:MiniKMS.java

示例11: cleanUpConnectors

import org.mortbay.jetty.Connector; //导入依赖的package包/类
private void cleanUpConnectors()
   {
	Iterator<Map.Entry<String, Connector>> it = _connectors.entrySet().iterator();
	while (it.hasNext())
	{
		Map.Entry<String, Connector> entry = (Map.Entry<String, Connector>) it.next();
		Connector connector = entry.getValue();
		try
		{
			connector.stop();
		} catch (Exception ex)
		{
			Log.warn(ex);
		}
		_server.removeConnector(connector);
	}
	_connectors.clear();
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:19,代码来源:JettyHttpServer.java

示例12: 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

示例13: createHttpsChannelConnector

import org.mortbay.jetty.Connector; //导入依赖的package包/类
private Connector createHttpsChannelConnector() {
  SslSelectChannelConnector c = new SslSelectChannelConnectorSecure();
  configureChannelConnector(c);

  c.setNeedClientAuth(needsClientAuth);
  c.setKeyPassword(keyPassword);

  if (keyStore != null) {
    c.setKeystore(keyStore);
    c.setKeystoreType(keyStoreType);
    c.setPassword(keyStorePassword);
  }

  if (trustStore != null) {
    c.setTruststore(trustStore);
    c.setTruststoreType(trustStoreType);
    c.setTrustPassword(trustStorePassword);
  }

  if(null != excludeCiphers && !excludeCiphers.isEmpty()) {
    c.setExcludeCipherSuites(excludeCiphers.split(","));
    LOG.info("Excluded Cipher List:" + excludeCiphers);
  }
  return c;
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:26,代码来源:HttpServer2.java

示例14: createJettyServer

import org.mortbay.jetty.Connector; //导入依赖的package包/类
private static Server createJettyServer(String keyStore, String password, int inPort) {
  try {
    boolean ssl = keyStore != null;
    String host = "localhost";
    Server server = new Server(inPort);
    if (!ssl) {
      server.getConnectors()[0].setHost(host);
    } else {
      SslSelectChannelConnector c = new SslSelectChannelConnectorSecure();
      c.setHost(host);
      c.setNeedClientAuth(false);
      c.setKeystore(keyStore);
      c.setKeystoreType("jks");
      c.setKeyPassword(password);
      server.setConnectors(new Connector[]{c});
    }
    return server;
  } catch (Exception ex) {
    throw new RuntimeException("Could not start embedded servlet container, "
        + ex.getMessage(), ex);
  }
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:23,代码来源:MiniKMS.java

示例15: getInstance

import org.mortbay.jetty.Connector; //导入依赖的package包/类
public static StaticHttpServer getInstance(Object containerObject, String name,
    String bindAddress, int port, boolean findPort, Connector connector,
    TajoConf conf,
    String[] pathSpecs) throws IOException {
  String addr = bindAddress;
  if(instance == null) {
    if(bindAddress == null || bindAddress.compareTo("") == 0) {
      if (containerObject instanceof TajoMaster) {
        addr = conf.getVar(ConfVars.TAJO_MASTER_UMBILICAL_RPC_ADDRESS).split(":")[0];
      } else if (containerObject instanceof TajoWorker) {
        addr = Inet4Address.getLocalHost().getHostName();
      }
    }
    
    instance = new StaticHttpServer(containerObject, name, addr, port,
        findPort, connector, conf, pathSpecs);
    instance.setAttribute("tajo.info.server.object", containerObject);
    instance.setAttribute("tajo.info.server.addr", addr);
    instance.setAttribute("tajo.info.server.conf", conf);
    instance.setAttribute("tajo.info.server.starttime", System.currentTimeMillis());
  }
  return instance;
}
 
开发者ID:apache,项目名称:incubator-tajo,代码行数:24,代码来源:StaticHttpServer.java


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