當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。