當前位置: 首頁>>代碼示例>>Java>>正文


Java SelectChannelConnector.setPort方法代碼示例

本文整理匯總了Java中org.eclipse.jetty.server.nio.SelectChannelConnector.setPort方法的典型用法代碼示例。如果您正苦於以下問題:Java SelectChannelConnector.setPort方法的具體用法?Java SelectChannelConnector.setPort怎麽用?Java SelectChannelConnector.setPort使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.jetty.server.nio.SelectChannelConnector的用法示例。


在下文中一共展示了SelectChannelConnector.setPort方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private Server createServer() {
    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(8384);
    server.addConnector(connector);

    ServletHandler handler = new ServletHandler();
    Servlet servlet = new HttpServlet() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
            String path = req.getServletPath().substring(1);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
            resp.getWriter().append(path);
        }
        
    };
    handler.addServletWithMapping(new ServletHolder(servlet), "/");
    server.setHandler(handler);
    return server;
}
 
開發者ID:cschneider,項目名稱:reactive-components,代碼行數:27,代碼來源:TestRs.java

示例2: run

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public void run(int port) throws Exception {
    Server server = new Server();
    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);

    ResourceHandler resource_handler = new ResourceHandler();
    resource_handler.setDirectoriesListed(true);
    resource_handler.setWelcomeFiles(new String[] { "index.html" });

    resource_handler.setResourceBase("./performance/site/");

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { resource_handler,
            new DefaultHandler() });
    server.setHandler(handlers);

    server.start();
    System.out.println("Started performance file server at port: " + port);
    server.join();
}
 
開發者ID:wxyzZ,項目名稱:little_mitm,代碼行數:22,代碼來源:PerformanceServer.java

示例3: buildJetty

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public void buildJetty(int port, String sourceDir, String webXmlFile) throws Exception {
    server = new Server();

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);
    WebAppContext context = new WebAppContext();
    context.setResourceBase(sourceDir);
    context.setDescriptor(sourceDir + "/WEB-INF/" + webXmlFile);
    context.setLogUrlOnStart(true);
    context.setContextPath("/");
    context.setParentLoaderPriority(true);

    server.setHandler(context);

    server.start();
}
 
開發者ID:hazelcast,項目名稱:hazelcast-wm,代碼行數:18,代碼來源:JettyServer.java

示例4: createServerInSource

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * 創建用於開發運行調試的Jetty Server, 以src/main/webapp為Web應用目錄.
 */
public static Server createServerInSource(int port, String contextPath) {
	Server server = new Server();
	// 設置在JVM退出時關閉Jetty的鉤子。
	server.setStopAtShutdown(true);

	SelectChannelConnector connector = new SelectChannelConnector();
	connector.setPort(port);
	// 解決Windows下重複啟動Jetty居然不報告端口衝突的問題.
	connector.setReuseAddress(false);
	server.setConnectors(new Connector[] { connector });

	WebAppContext webContext = new WebAppContext(DEFAULT_WEBAPP_PATH, contextPath);
	// 修改webdefault.xml,解決Windows下Jetty Lock住靜態文件的問題.
	webContext.setDefaultsDescriptor(WINDOWS_WEBDEFAULT_PATH);
	server.setHandler(webContext);

	return server;
}
 
開發者ID:pengqiuyuan,項目名稱:g2,代碼行數:22,代碼來源:JettyFactory.java

示例5: initJettyServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private Server initJettyServer(ComponentRepository repo) {
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setPort(getPort());
  connector.setConfidentialPort(getSecurePort());
  connector.setRequestHeaderSize(16384);

  Server jettyServer = new Server();
  jettyServer.setConnectors(new Connector[] {connector});
  
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  HandlerCollection handlers = new HandlerCollection();
  handlers.addHandler(contexts);
  addHandlers(repo, jettyServer, contexts);
  
  jettyServer.setHandler(handlers);
  jettyServer.setStopAtShutdown(true);
  jettyServer.setGracefulShutdown(2000);
  jettyServer.setSendDateHeader(true);
  jettyServer.setSendServerVersion(true);
  
  ComponentInfo info = new ComponentInfo(Server.class, "jetty");
  repo.registerComponent(info, jettyServer);
  repo.registerLifecycle(new ServerLifecycle(jettyServer));
  return jettyServer;
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:26,代碼來源:EmbeddedJettyComponentFactory.java

示例6: startServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@BeforeClass
public void startServer() throws Exception {
  int port = 49152 + RandomUtils.nextInt(65535 - 49152);
  String serverUrl = "http://localhost:" + port + "/jax";
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setPort(port);
  _jettyServer = new Server();
  _jettyServer.setConnectors(new Connector[]{connector});
  ContextHandlerCollection contexts = new ContextHandlerCollection();
  HandlerCollection handlers = new HandlerCollection();
  handlers.addHandler(contexts);
  WebAppContext ogWebAppContext = new WebAppContext("RemoteViewRunnerTest", "/");
  org.springframework.core.io.Resource resource = new ClassPathResource("web-engine");
  ogWebAppContext.setBaseResource(Resource.newResource(resource.getFile()));
  DataViewRunnerResource viewRunnerResource = new DataViewRunnerResource(new TestViewRunner());
  ComponentRepository repo = new ComponentRepository(ComponentLogger.Console.VERBOSE);
  repo.getRestComponents().publishResource(viewRunnerResource);
  repo.getRestComponents().publishHelper(new FudgeObjectBinaryConsumer());
  repo.getRestComponents().publishHelper(new FudgeObjectBinaryProducer());
  ogWebAppContext.setEventListeners(new EventListener[]{new ComponentRepositoryServletContextListener(repo)});
  handlers.addHandler(ogWebAppContext);
  _jettyServer.setHandler(handlers);
  _jettyServer.start();
  _remoteViewRunner = new RemoteViewRunner(URI.create(serverUrl));
}
 
開發者ID:DevStreet,項目名稱:FinanceAnalytics,代碼行數:26,代碼來源:RemoteViewRunnerTest.java

示例7: WebSocketServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public WebSocketServer(int port, String rootDirPath, final MainWindow m, final Statement smt, final java.sql.Connection sqlcon) {
	idCounter = 0;

	connector = new SelectChannelConnector();
	connector.setPort(port);
	addConnector(connector);

	wsHandler = new WebSocketHandler() {
		@Override
		public WebSocket doWebSocketConnect(HttpServletRequest request,
				String protocol) {
			idCounter++;
			System.out.printf("Protocol:%s\n", protocol);
			return new MyWebSocket(idCounter, m, smt, sqlcon);
		}
	};

	resHandler = new ResourceHandler();
	resHandler.setDirectoriesListed(true);
	resHandler.setResourceBase(rootDirPath);

	wsHandler.setHandler(resHandler);
	setHandler(wsHandler);
}
 
開發者ID:ryohashioka,項目名稱:Visual-Programming-Environment-for-Coordinating-Appliances-and-Services-in-a-Smart-House,代碼行數:25,代碼來源:WebSocketServer.java

示例8: start

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public void start() throws Exception {
    URI uri = new URI(agent.getRegistryURL());

    server = new Server();
    ServletContextHandler context = new ServletContextHandler(ServletContextHandler.NO_SECURITY | ServletContextHandler.NO_SESSIONS);
    
    context.setContextPath("/");
    ServletHolder holder = new ServletHolder();
    holder.setServlet(camelServlet);
    context.addServlet(holder, "/*");
    server.setHandler(context);
    server.start();
    
    int port = 80;
    if( uri.getPort() >=0 ) {
        port = uri.getPort();
    }
    
    connector = new SelectChannelConnector();
    connector.setPort(port);
    server.addConnector(connector);
    connector.start();
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:24,代碼來源:EmbeddedJettyServer.java

示例9: createServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private Server createServer(final int port, final boolean multiThreaded) throws Exception {
    final String testName = getClass().getSimpleName() + "_" + getName();
    final DataCleanerConfiguration configuration = ClusterTestHelper.createConfiguration(testName, multiThreaded);

    final SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);

    final WebAppContext webApp = new WebAppContext();
    webApp.setAttribute(SlaveServlet.SERVLET_CONTEXT_ATTRIBUTE_CONFIGURATION, configuration);
    webApp.setContextPath("/");
    webApp.setWar("src/test/resources/jetty_webapp_folder");

    final Server server = new Server();
    server.addConnector(connector);
    server.setHandler(webApp);
    server.start();

    System.out.println("Jetty server started on port " + port);

    return server;
}
 
開發者ID:datacleaner,項目名稱:DataCleaner,代碼行數:22,代碼來源:HttpClusterManagerTest.java

示例10: createServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private Server createServer(int port, boolean multiThreaded) throws Exception {
    final String testName = getClass().getSimpleName() + "_" + getName();
    final AnalyzerBeansConfiguration configuration = ClusterTestHelper.createConfiguration(testName, multiThreaded);

    final SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);

    final WebAppContext webApp = new WebAppContext();
    webApp.setAttribute(SlaveServlet.SERVLET_CONTEXT_ATTRIBUTE_CONFIGURATION, configuration);
    webApp.setContextPath("/");
    webApp.setWar("src/test/resources/jetty_webapp_folder");

    final Server server = new Server();
    server.addConnector(connector);
    server.setHandler(webApp);
    server.start();

    System.out.println("Jetty server started on port " + port);

    return server;
}
 
開發者ID:datacleaner,項目名稱:AnalyzerBeans,代碼行數:22,代碼來源:HttpClusterManagerTest.java

示例11: start

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@Override
public void start() throws IOException
{
  _server = new Server();
  SelectChannelConnector connector = new SelectChannelConnector();
  connector.setPort(_port);
  _server.setConnectors(new Connector[] { connector });
  _server.setThreadPool(new QueuedThreadPool(_threadPoolSize));
  ServletContextHandler root =
      new ServletContextHandler(_server, _contextPath, ServletContextHandler.SESSIONS);
  root.addServlet(new ServletHolder(_servlet), "/*");

  try
  {
    _server.start();
  }
  catch (Exception e)
  {
    throw new IOException("Failed to start Jetty", e);
  }
}
 
開發者ID:ppdai,項目名稱:rest4j,代碼行數:22,代碼來源:HttpJettyServer.java

示例12: createServerInSource

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * 創建用於開發運行調試的Jetty Server, 以src/main/webapp為Web應用目錄.
 */
public static Server createServerInSource(int port) {
    Server server = new Server();
    // 設置在JVM退出時關閉Jetty的鉤子。
    server.setStopAtShutdown(true);

    SelectChannelConnector connector = new SelectChannelConnector();
    connector.setPort(port);
    // 解決Windows下重複啟動Jetty居然不報告端口衝突的問題.
    connector.setReuseAddress(false);
    server.setConnectors(new Connector[] { connector });

    WebAppContext webContext = new WebAppContext(DEFAULT_WEBAPP_PATH, CONTEXT_PATH);

    server.setHandler(webContext);

    return server;
}
 
開發者ID:chenlg,項目名稱:jmms,代碼行數:21,代碼來源:JettyFactory.java

示例13: createServerInSource

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * 創建用於開發運行調試的Jetty Server, 以src/main/webapp為Web應用目錄.
 */
public static Server createServerInSource(int port, String contextPath) {
	Server server = new Server();
	// 設置在JVM退出時關閉Jetty的鉤子。
	server.setStopAtShutdown(true);

	SelectChannelConnector connector = new SelectChannelConnector();
	connector.setPort(port);
	// 解決Windows下重複啟動Jetty居然不報告端口衝突的問題.
	connector.setReuseAddress(false);
	server.setConnectors(new Connector[] { connector });

	WebAppContext webContext = new WebAppContext(DEFAULT_WEBAPP_PATH, contextPath);
	server.setHandler(webContext);

	return server;
}
 
開發者ID:extion,項目名稱:base-framework,代碼行數:20,代碼來源:JettyFactory.java

示例14: createServerInSource

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
 * 創建用於開發運行調試的Jetty Server, 以src/main/webapp為Web應用目錄.
 */
public static Server createServerInSource(int port, String contextPath) {
	Server server = new Server();
	//設置在JVM退出時關閉Jetty的鉤子。
	server.setStopAtShutdown(true);

	SelectChannelConnector connector = new SelectChannelConnector();
	connector.setPort(port);
	//解決Windows下重複啟動Jetty居然不報告端口衝突的問題.
	connector.setReuseAddress(false);
	server.setConnectors(new Connector[] { connector });

	WebAppContext webContext = new WebAppContext(DEFAULT_WEBAPP_PATH, contextPath);
	//修改webdefault.xml,解決Windows下Jetty Lock住靜態文件的問題.
	webContext.setDefaultsDescriptor(WINDOWS_WEBDEFAULT_PATH);
	server.setHandler(webContext);

	return server;
}
 
開發者ID:Michaelleolee,項目名稱:appengine,代碼行數:22,代碼來源:JettyFactory.java

示例15: startWebServer

import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public static void startWebServer(int port) throws Exception {
	webServer = new Server();
	SelectChannelConnector connector = new SelectChannelConnector();
	connector.setPort(port);
	webServer.addConnector(connector);

	ResourceHandler resource_handler = new ResourceHandler();
	resource_handler.setDirectoriesListed(true);
	//resource_handler.setWelcomeFiles(new String[] { "index.html" });

	String serverRoot = ServerStarter.class.getResource("/").getFile();

	resource_handler.setResourceBase(serverRoot);

	HandlerList handlers = new HandlerList();
	handlers.setHandlers(new Handler[] { resource_handler,
			new DefaultHandler() });
	webServer.setHandler(handlers);

	webServer.start();

}
 
開發者ID:impactcentre,項目名稱:iif-resultsrepository,代碼行數:23,代碼來源:ServerStarter.java


注:本文中的org.eclipse.jetty.server.nio.SelectChannelConnector.setPort方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。