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


Java SelectChannelConnector.setPort方法代码示例

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


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

示例1: start

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的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

示例2: startHttpServer

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
private void startHttpServer() throws Exception {
    server = new Server();
    SelectChannelConnector selectChannelConnector = new SelectChannelConnector();
    selectChannelConnector.setPort(11060);
    server.setConnectors(new Connector[]{selectChannelConnector});

    PackagesResourceConfig packagesResourceConfig = new PackagesResourceConfig("com/ngdata/hbaseindexer/rest");

    ServletHolder servletHolder = new ServletHolder(new ServletContainer(packagesResourceConfig));
    servletHolder.setName("HBase-Indexer");


    Context context = new Context(server, "/", Context.NO_SESSIONS);
    context.addServlet(servletHolder, "/*");
    context.setContextPath("/");
    context.setAttribute("indexerModel", indexerModel);
    context.setAttribute("indexerSupervisor", indexerSupervisor);

    server.setHandler(context);
    server.start();
}
 
开发者ID:NGDATA,项目名称:hbase-indexer,代码行数:22,代码来源:Main.java

示例3: main

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    Server server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(PORT);
    server.addConnector(connector);
    server.setStopAtShutdown(true);

    // the orders of handlers is very important!
    ContextHandler contextHandler = new ContextHandler();
    contextHandler.setContextPath("/reports");
    contextHandler.setResourceBase("./reports/");
    contextHandler.addHandler(new ResourceHandler());
    server.addHandler(contextHandler);

    server.addHandler(new WebAppContext("webapp", "/nextreports-server"));

    long t = System.currentTimeMillis();
    server.start();
    t = System.currentTimeMillis() - t;
    String version = server.getClass().getPackage().getImplementationVersion();
    System.out.println("Started Jetty Server " + version + " on port " + PORT + " in " + t / 1000 + "s");
    
    server.join();
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:26,代码来源:JettyLauncher.java

示例4: createDefaultConnector

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
public Object createDefaultConnector(int port) throws Exception {
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    connector.setMaxIdleTime(DEFAULT_MAX_IDLE_TIME);

    return connector;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:Jetty6PluginServer.java

示例5: JettyHttpServer

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
public JettyHttpServer(URL url, final HttpHandler handler){
    super(url, handler);
    DispatcherServlet.addHttpHandler(url.getPort(), handler);
    
    int threads = url.getParameter(Constants.THREADS_KEY, Constants.DEFAULT_THREADS);
    QueuedThreadPool threadPool = new QueuedThreadPool();
    threadPool.setDaemon(true);
    threadPool.setMaxThreads(threads);
    threadPool.setMinThreads(threads);

    SelectChannelConnector connector = new SelectChannelConnector();
    if (! url.isAnyHost() && NetUtils.isValidLocalHost(url.getHost())) {
        connector.setHost(url.getHost());
    }
    connector.setPort(url.getPort());

    server = new Server();
    server.setThreadPool(threadPool);
    server.addConnector(connector);
    
    ServletHandler servletHandler = new ServletHandler();
    ServletHolder servletHolder = servletHandler.addServletWithMapping(DispatcherServlet.class, "/*");
    servletHolder.setInitOrder(2);
    
    server.addHandler(servletHandler);
    
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + url.getAddress() + ", cause: "
                                        + e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:34,代码来源:JettyHttpServer.java

示例6: start

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:32,代码来源:JettyContainer.java

示例7: main

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
/**
 * Sets up and runs server.
 * @param args
 */
public static void main(String[] args)
{
    final Server server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(8080);
    server.addConnector(connector);

    Context htmlContext = new Context(server, "/", Context.SESSIONS);

    ResourceHandler htmlHandler = new ResourceHandler();
    htmlHandler.setResourceBase("web");
    htmlContext.setHandler(htmlHandler);

    Context servletContext = new Context(server, "/", Context.SESSIONS);

    GenericWebApplicationContext springContext = new GenericWebApplicationContext();
    springContext.setParent(new ClassPathXmlApplicationContext("org/getahead/dwrdemo/cli/spring.xml"));
    servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, springContext);

    ServletHolder holder = new ServletHolder(new DwrSpringServlet());
    holder.setInitParameter("pollAndCometEnabled", "true");
    holder.setInitParameter("debug", "true");
    servletContext.addServlet(holder, "/dwr/*");

    try
    {
        JettyShutdown.addShutdownHook(server);
        server.start();
        server.join();
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:41,代码来源:JettySpringLauncher.java

示例8: main

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
/**
 * Sets up and runs server.
 * @param args
 */
public static void main(String[] args)
{
    Server server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(8080);
    server.addConnector(connector);

    Context htmlContext = new Context(server, "/", Context.SESSIONS);
    ResourceHandler htmlHandler = new ResourceHandler();
    htmlHandler.setResourceBase("web");
    htmlContext.setHandler(htmlHandler);

    Context servletContext = new Context(server, "/", Context.SESSIONS);
    ServletHolder holder = new ServletHolder(new DwrServlet());
    holder.setInitParameter("activeReverseAjaxEnabled", "true");
    holder.setInitParameter("debug", "true");
    servletContext.addServlet(holder, "/dwr/*");
    servletContext.setResourceBase("web");

    try
    {
        JettyShutdown.addShutdownHook(server);
        server.start();
        server.join();
    }
    catch (Exception ex)
    {
        ex.printStackTrace();
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:36,代码来源:JettyLauncher.java

示例9: startServer

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
/**
 * Starts the Jetty server at a specified port and redirection parameter.
 * 
 * @param portno
 *          Port number.
 * @param redirection
 *          whether redirection
 */
private void startServer(int portno, boolean redirection) throws Exception {
  port = portno;
  setUp(redirection);
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setHost("127.0.0.1");
  connector.setPort(port);

  server.addConnector(connector);
  server.start();
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:19,代码来源:TestProtocolHttp.java

示例10: start

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
public void start() {
    String serverPort = ConfigUtils.getProperty(JETTY_PORT);
    int port;
    if (serverPort == null || serverPort.length() == 0) {
        port = DEFAULT_JETTY_PORT;
    } else {
        port = Integer.parseInt(serverPort);
    }
    connector = new SelectChannelConnector();
    
    connector.setPort(port);
    ServletHandler handler = new ServletHandler();
    
    String resources = ConfigUtils.getProperty(JETTY_DIRECTORY);
    if (resources != null && resources.length() > 0) {
        FilterHolder resourceHolder = handler.addFilterWithMapping(ResourceFilter.class, "/*", Handler.DEFAULT);
        resourceHolder.setInitParameter("resources", resources);
    }
    
    ServletHolder pageHolder = handler.addServletWithMapping(PageServlet.class, "/*");
    pageHolder.setInitParameter("pages", ConfigUtils.getProperty(JETTY_PAGES));
    pageHolder.setInitOrder(2);
    
    Server server = new Server();
    server.addConnector(connector);
    server.addHandler(handler);
    try {
        server.start();
    } catch (Exception e) {
        throw new IllegalStateException("Failed to start jetty server on " + NetUtils.getLocalHost() + ":" + port + ", cause: " + e.getMessage(), e);
    }
}
 
开发者ID:spccold,项目名称:dubbo-comments,代码行数:33,代码来源:JettyContainer.java

示例11: bind

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
@Override
 public void bind(InetSocketAddress addr, int backlog) throws IOException
 {
     this._addr = addr;
     
 	// check if there is already a connector listening
     Connector[] connectors = _server.getConnectors();
     if (connectors != null)
     {
      for (int i = 0; i < connectors.length; i++)
      {
	if (connectors[i].getPort() == addr.getPort())
	{
		if (Log.isDebugEnabled()) Log.debug("server already bound to port " + addr.getPort() + ", no need to rebind");
		return;
	}
}
     }
     
     if (_executor != null && _server.getThreadPool() == null)
     {
     	if (Log.isDebugEnabled()) Log.debug("using given Executor for server thread pool");
     	_server.setThreadPool(new ThreadPoolExecutorAdapter(_executor));
     }

     SelectChannelConnector connector = new SelectChannelConnector();
     connector.setAcceptors(1);
     connector.setPort(addr.getPort());
     connector.setHost(addr.getHostName());
     _server.addConnector(connector);
     
     _connectors.put(addr.getHostName() + addr.getPort(), connector);
 }
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:34,代码来源:JettyHttpServer.java

示例12: main

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception
{
    String jetty_home=System.getProperty("jetty.home","../../..");

    String jetty_port=System.getProperty("jetty.port", "8080");

    String node_name=System.getProperty("node.name", "red");

    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(Integer.parseInt(jetty_port));
    server.setConnectors(new Connector[]{connector});
    
    HandlerCollection handlers = new HandlerCollection();
    ContextHandlerCollection contexts = new ContextHandlerCollection();
    
    //TODO: find a way to dynamically get the endpoint url
    WadiCluster wadiCluster = new WadiCluster("CLUSTER", node_name, "http://localhost:"+jetty_port+"/test");
    wadiCluster.doStart();
    
    WadiSessionManager wadiManager = new WadiSessionManager(wadiCluster, 2, 24, 360);
    
    WadiSessionHandler wSessionHandler = new WadiSessionHandler(wadiManager);
    WebAppContext wah = new WebAppContext(null, wSessionHandler, null, null);
    wah.setContextPath("/test");
    wah.setResourceBase(jetty_home+"/webapps/test");
    
    contexts.setHandlers(new Handler[]{wah});
    handlers.setHandlers(new Handler[]{contexts,new DefaultHandler()});
    server.setHandler(handlers);

    HashUserRealm hur = new HashUserRealm();
    hur.setName("Test Realm");
    hur.setConfig(jetty_home+"/etc/realm.properties");
    wah.getSecurityHandler().setUserRealm(hur);
    
    server.start();
    server.join();
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:40,代码来源:WadiSessionHandler.java

示例13: doStart

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
public static void doStart() throws Exception {

        Server server = new Server();
        SelectChannelConnector connector = new SelectChannelConnector();
        connector.setPort(JETTY_SERVER_PORT);

        String webDefault = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "**/webdefault.xml";
        Resource web = resolver.getResources(webDefault)[0];
        String descriptor = web.getFile().getAbsolutePath();

        String pattern = ResourcePatternResolver.CLASSPATH_ALL_URL_PREFIX + "**/" + SpiderJetty.class.getName() + ".class";
        Resource resource = resolver.getResources(pattern)[0];
        String resourcePath = resource.getFile().getAbsolutePath().replaceAll("target.*$", "") + "webapp";

        WebAppContext context = new WebAppContext();
        context.setContextPath("/");
        context.setDefaultsDescriptor(descriptor);
        context.setResourceBase("file:" + resourcePath);
        context.setClassLoader(Thread.currentThread().getContextClassLoader());

        server.setConnectors(new Connector[]{connector});
        server.setHandler(context);

        server.setStopAtShutdown(true);
        server.setSendServerVersion(false);
        server.setSendDateHeader(false);
        server.setGracefulShutdown(1000);


        try {
            server.start();
            server.join();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
开发者ID:MartinDai,项目名称:TBSpider,代码行数:37,代码来源:SpiderJetty.java

示例14: JettyAdminServer

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
public JettyAdminServer(String address, int port, String commandUrl) {
    this.port = port;
    this.commandUrl = commandUrl;
    this.address = address;

    server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setHost(address);
    connector.setPort(port);
    server.addConnector(connector);
    Context context = new Context(server, "/");
    server.setHandler(context);
    context.addServlet(new ServletHolder(new CommandServlet()), commandUrl
            + "/*");
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:16,代码来源:JettyAdminServer.java

示例15: createBaseListener

import org.mortbay.jetty.nio.SelectChannelConnector; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected Connector createBaseListener(Configuration conf)
    throws IOException {
  final String sAddr;
  if (null == (sAddr = conf.get("proxy.http.test.listener.addr"))) {
    SslSocketConnector sslListener = new SslSocketConnector();
    sslListener.setKeystore(conf.get("ssl.server.keystore.location"));
    sslListener.setPassword(conf.get("ssl.server.keystore.password", ""));
    sslListener.setKeyPassword(conf.get("ssl.server.keystore.keypassword", ""));
    sslListener.setKeystoreType(conf.get("ssl.server.keystore.type", "jks"));
    sslListener.setNeedClientAuth(true);
    System.setProperty("javax.net.ssl.trustStore",
        conf.get("ssl.server.truststore.location", ""));
    System.setProperty("javax.net.ssl.trustStorePassword",
        conf.get("ssl.server.truststore.password", ""));
    System.setProperty("javax.net.ssl.trustStoreType",
        conf.get("ssl.server.truststore.type", "jks"));
    return sslListener;
  }
  // unit test
  InetSocketAddress proxyAddr = NetUtils.createSocketAddr(sAddr);
  SelectChannelConnector testlistener = new SelectChannelConnector();
  testlistener.setUseDirectBuffers(false);
  testlistener.setHost(proxyAddr.getHostName());
  testlistener.setPort(proxyAddr.getPort());
  return testlistener;
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:28,代码来源:ProxyHttpServer.java


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