本文整理匯總了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;
}
示例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();
}
示例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();
}
示例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;
}
示例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;
}
示例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));
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}