本文整理汇总了Java中org.mortbay.jetty.bio.SocketConnector.setMaxIdleTime方法的典型用法代码示例。如果您正苦于以下问题:Java SocketConnector.setMaxIdleTime方法的具体用法?Java SocketConnector.setMaxIdleTime怎么用?Java SocketConnector.setMaxIdleTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.bio.SocketConnector
的用法示例。
在下文中一共展示了SocketConnector.setMaxIdleTime方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}
示例5: 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);
}
}
示例6: startWebApp
import org.mortbay.jetty.bio.SocketConnector; //导入方法依赖的package包/类
public static void startWebApp() {
Server server = new Server();
SocketConnector connector = new SocketConnector();
connector.setMaxIdleTime(1000 * 60 * 60);
connector.setSoLingerTime(-1);
connector.setPort(3030);
server.setConnectors(new Connector[]{connector});
WebAppContext webAppContext = new WebAppContext();
webAppContext.setServer(server);
String path = "sample/src/main/webapp";
path = findWarPath(path);
System.out.println("path = " + path);
webAppContext.setWar(path);
server.addHandler(webAppContext);
try {
String msg = "http://localhost:3030/";
log("Starting " + msg + " (please wait)...");
server.start();
log("Started " + msg);
System.out.println("PRESS ANY KEY TO STOP");
while (System.in.available() == 0) {
Thread.sleep(5000);
}
log("Stopping the webapp...");
webAppContext.stop();
log("The webapp was stopped.");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(100);
}
}