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


Java SocketConnector类代码示例

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


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

示例1: startServer

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
/**
 * Starts the Jetty server at a specified port.
 *
 * Will try up to 10 ports to find an available port to use.
 *
 * @param portno
 *          Port number.
 * @throws Exception
 *           When an error occurs.
 */
private void startServer(int portno) throws Exception {
  SocketConnector listener = new SocketConnector();
  listener.setHost("127.0.0.1");
  server.addConnector(listener);
  for (int p = portno; p < portno + 10; p++) {
    port = portno;
    listener.setPort(port);
    try {
      server.start();
      break;
    } catch (Exception e) {
      if (p == portno + 9) {
        throw e;
      }
    }
  }
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:28,代码来源:TestProtocolHttpClient.java

示例2: getServer

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
/**
 * Creates a new JettyServer with one static root context
 * 
 * @param port
 *          port to listen to
 * @param staticContent
 *          folder where static content lives
 * @throws UnknownHostException
 */
public static Server getServer(int port, String staticContent)
    throws UnknownHostException {
  Server webServer = new org.mortbay.jetty.Server();
  SocketConnector listener = new SocketConnector();
  listener.setPort(port);
  listener.setHost("127.0.0.1");
  webServer.addConnector(listener);
  ContextHandler staticContext = new ContextHandler();
  staticContext.setContextPath("/");
  staticContext.setResourceBase(staticContent);
  staticContext.addHandler(new ResourceHandler());
  webServer.addHandler(staticContext);
  return webServer;
}
 
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:24,代码来源:CrawlDBTestUtil.java

示例3: main

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
public static void main(String[] args) {
    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(9080);
    server.setConnectors(new Connector[]{connector});

    WebAppContext context = new WebAppContext();
    context.setServer(server);
    context.setContextPath("/");

    ProtectionDomain protectionDomain = Main.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();
    context.setWar(location.toExternalForm());

    server.addHandler(context);
    try {
        server.start();
        System.in.read();
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:30,代码来源:WebLauncher.java

示例4: startServer

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
/**
 * Starts the Jetty server at a specified port.
 *
 * @param  portno     Port number.
 * @throws Exception  When an error occurs.
 */
private void startServer(int portno) throws Exception {
  port = portno;
  SocketConnector listener = new SocketConnector();
  listener.setHost("127.0.0.1");
  listener.setPort(port);
  server.addConnector(listener);
  server.start();
}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:15,代码来源:TestProtocolHttpClient.java

示例5: getServer

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
/**
 * Creates a new JettyServer with one static root context
 * 
 * @param port port to listen to
 * @param staticContent folder where static content lives
 * @throws UnknownHostException 
 */
public static Server getServer(int port, String staticContent) throws UnknownHostException{
  Server webServer = new org.mortbay.jetty.Server();
  SocketConnector listener = new SocketConnector();
  listener.setPort(port);
  listener.setHost("127.0.0.1");
  webServer.addConnector(listener);
  ContextHandler staticContext = new ContextHandler();
  staticContext.setContextPath("/");
  staticContext.setResourceBase(staticContent);
  staticContext.addHandler(new ResourceHandler());
  webServer.addHandler(staticContext);
  return webServer;
}
 
开发者ID:yahoo,项目名称:anthelion,代码行数:21,代码来源:CrawlDBTestUtil.java

示例6: setupLocalServer

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
@Before
public void setupLocalServer() throws Exception {

    // Set up a local Jetty HTTP server
    Server server = new Server();
    server.addConnector(new SocketConnector());
    ResourceHandler resourceHandler = new ResourceHandler();
    resourceHandler.setResourceBase("src/test/resources/server");
    server.addHandler(resourceHandler);
    server.start();

    // The server will have a random port assigned, so capture that
    localPort = server.getConnectors()[0].getLocalPort();
}
 
开发者ID:testcontainers,项目名称:testcontainers-java,代码行数:15,代码来源:LocalServerWebDriverContainerTest.java

示例7: startServer

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
public void startServer() throws NamingException {
    LOG.info("Configuring jetty web server ...");

    final Server server = new Server();
    SocketConnector connector = new SocketConnector();
    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(Integer.parseInt(System.getProperty("jetty.port", "8086")));

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

    WebAppContext demo = new WebAppContext();
    demo.setServer(server);
    demo.setContextPath("/superfly-demo");
    demo.setWar("src/main/webapp");
    demo.setConfigurationClasses(new String[] {
            "org.mortbay.jetty.webapp.WebInfConfiguration",
            "org.mortbay.jetty.plus.webapp.EnvConfiguration",
            "org.mortbay.jetty.plus.webapp.Configuration",
            "org.mortbay.jetty.webapp.JettyWebXmlConfiguration"
    });

    server.addHandler(demo);

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();

        while (System.in.available() == 0) {
            Thread.sleep(5000);
        }
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:40,代码来源:Demo.java

示例8: startServer

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
/**
 * Start embedded server.
 * @throws Exception
 */
public void startServer() throws Exception {
    SocketConnector connector = new SocketConnector();
    connector.setPort(0);
    connector.setHost("127.0.0.1");
    webServer.addConnector(connector);

    webServer.start();
    port = connector.getLocalPort();
    host = connector.getHost();
}
 
开发者ID:eBay,项目名称:oink,代码行数:15,代码来源:ServletTestContext.java

示例9: startServer

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
/** Start the server, including a handler that responds with registered
 * files, removes registered files on request, and gives 404 otherwise.
 * @throws IOFailure if it cannot be initialised.
 */
protected void startServer() {
    server = new Server();
    SocketConnector connector = new SocketConnector();
    connector.setPort(port);
    server.addConnector(connector);
    server.addHandler(new HTTPRemoteFileRegistryHandler());
    try {
        server.start();
    } catch (Exception e) {
        throw new IOFailure(
                "Cannot start HTTPRemoteFile registry on port "
                + port, e);
    }
}
 
开发者ID:netarchivesuite,项目名称:netarchivesuite-svngit-migration,代码行数:19,代码来源:HTTPRemoteFileRegistry.java

示例10: start

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
/**
 * Same as {@link #start(IComponentFactory)}, but allows to specify the context path and the port
 * 
 * @param factory
 * @param contextPath
 * @param port
 */
public static void start(IComponentFactory factory, String contextPath, int port) {
    // sanity check and install the factory
    if (factory == null) {
        throw new NullPointerException("You must provide a non null component factory");
    }
    TestHomePage.componentFactory = factory;

    // setup the embedded Jetty server
    Server server = new Server();
    SocketConnector connector = new SocketConnector();

    // Set some timeout options to make debugging easier.
    connector.setMaxIdleTime(1000 * 60 * 60);
    connector.setSoLingerTime(-1);
    connector.setPort(port);
    server.setConnectors(new Connector[] { connector });

    // programmatically add the wicket servlet to the context
    Context root = new Context(server, contextPath, Context.SESSIONS);
    ServletHolder wicket = new ServletHolder(WicketServlet.class);
    wicket.setInitParameter("applicationClassName", WicketTestApplication.class.getName());
    root.addServlet(wicket, "/*");

    try {
        System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
        server.start();
        while (System.in.available() == 0) {
            Thread.sleep(1000);
        }
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:44,代码来源:WicketTestApplication.java

示例11: createListeners

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
private void createListeners() 
{
    SocketConnector connector = new SocketConnector();
    connector.setPort(port);
    connector.setHost(hostname);
    connector.setName(Messages.getString("WebServer.Log.KettleHTTPListener",hostname));
    log.logBasic(toString(), Messages.getString("WebServer.Log.CreateListener",hostname,""+port));

    server.setConnectors( new Connector[] { connector });
}
 
开发者ID:icholy,项目名称:geokettle-2.0,代码行数:11,代码来源:WebServer.java

示例12: tryPort

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的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: go

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
public void go() {
  QueuedThreadPool pool = new QueuedThreadPool();
  pool.setMinThreads(2); // debug server doesn't need many threads.
  pool.setMaxThreads(10);
  pool.setName("DebugServer(port" + port + ")");
  pool.setDaemon(true);
  server.setThreadPool(pool);
  SocketConnector connector = new SocketConnector();

  connector.setPort(port);
  connector.setHost(host);
  connector.setMaxIdleTime(60000); // 1 min
  server.addConnector(connector);

  context.setContextPath("/");
  context.setBaseResource(Resource.newClassPathResource("/org/cloudera/stethoscope"));
  server.setHandler(context);

  addServlet(new DefaultServlet(), "/");
  addServlet(new DataServlet(), "/json/*");
  addServlet(new TracerServlet(inst), "/tracer/*");
  addServlet(new EvaluateServlet(), "/evaluate");
  addServlet(new PoorMansProfileServlet(), "/poorMansProfiler");
  addServlet(new JMXJsonServlet(), "/jmx");
  
  // addServlet(new LoggerServlet(), "/logging");
  
  try {
    server.start();
  } catch (Exception e) {
    // avoiding logging in this context.
    e.printStackTrace(System.err);
  }
}
 
开发者ID:philz,项目名称:stethoscope,代码行数:35,代码来源:StethoscopeWebServer.java

示例14: createListeners

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
private void createListeners() 
{
    SocketConnector connector = new SocketConnector();
    connector.setPort(port);
    connector.setHost(hostname);
    connector.setName(BaseMessages.getString(PKG, "WebServer.Log.KettleHTTPListener",hostname));
    log.logBasic(BaseMessages.getString(PKG, "WebServer.Log.CreateListener",hostname,""+port));

    server.setConnectors( new Connector[] { connector });
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:11,代码来源:WebServer.java

示例15: main

import org.mortbay.jetty.bio.SocketConnector; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	Server server = new Server();
	SocketConnector connector = new SocketConnector();
	// Set some timeout options to make debugging easier.
	connector.setMaxIdleTime(1000 * 60 * 60);
	connector.setSoLingerTime(-1);
	connector.setPort(8080);
	server.setConnectors(new Connector[] { connector });

	WebAppContext bb = new WebAppContext();
	bb.setServer(server);
	bb.setContextPath("/");
	bb.setWar("src/main/webapp");

	
	// START JMX SERVER
	// MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
	// MBeanContainer mBeanContainer = new MBeanContainer(mBeanServer);
	// server.getContainer().addEventListener(mBeanContainer);
	// mBeanContainer.start();
	
	server.addHandler(bb);

	try {
		System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
		server.start();
		while (System.in.available() == 0) {
			Thread.sleep(5000);
		}
		server.stop();
		server.join();
	} catch (Exception e) {
		e.printStackTrace();
		System.exit(100);
	}
}
 
开发者ID:r-h,项目名称:wicket-notes-demo,代码行数:37,代码来源:Start.java


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