本文整理汇总了Java中org.mortbay.jetty.Server.setStopAtShutdown方法的典型用法代码示例。如果您正苦于以下问题:Java Server.setStopAtShutdown方法的具体用法?Java Server.setStopAtShutdown怎么用?Java Server.setStopAtShutdown使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.Server
的用法示例。
在下文中一共展示了Server.setStopAtShutdown方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ServerProxyImpl
import org.mortbay.jetty.Server; //导入方法依赖的package包/类
/**
* Default constructor. Creates a new Jetty server with a standard connector
* listening on a given port.
*
* @param userRealmsList
*
* @param port default connector port number.
* @param maxIdleTime default connector maximum idle time of for each
* connection.
*/
public ServerProxyImpl(List connectors, List userRealmsList, RequestLog requestLog,
File jettyXml)
{
server = new Server();
server.setStopAtShutdown(true);
this.connectors = connectors;
this.userRealms = userRealmsList;
this.requestLog = requestLog;
this.jettyXml = jettyXml;
configure();
}
示例2: doStart
import org.mortbay.jetty.Server; //导入方法依赖的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();
}
}
示例3: main
import org.mortbay.jetty.Server; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
String confPath = args[0];
confPath = confPath.trim();
Properties conf = new Properties();
InputStream is = new FileInputStream(new File(confPath + "/conf/lts-admin.cfg"));
conf.load(is);
String port = conf.getProperty("port");
if (port == null || port.trim().equals("")) {
port = "8081";
}
Server server = new Server(Integer.parseInt(port));
WebAppContext webapp = new WebAppContext();
webapp.setWar(confPath + "/lts-admin.war");
Map<String, String> initParams = new HashMap<String, String>();
initParams.put("lts.admin.config.path", confPath + "/conf");
webapp.setInitParams(initParams);
server.setHandler(webapp);
server.setStopAtShutdown(true);
server.start();
System.out.println("LTS-Admin started. http://" + NetUtils.getLocalHost() + ":" + port + "/index.htm");
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例4: JettyServer
import org.mortbay.jetty.Server; //导入方法依赖的package包/类
public JettyServer(int port, HttpsConfiguration httpsConf)
{
server = new Server();
SslSelectChannelConnector connector = new SslSelectChannelConnector();
connector.setPort(port);
connector.setKeystore(httpsConf.getServerKeystorePath());
connector.setKeyPassword(httpsConf.getServerKeystorePassword());
if ( httpsConf.isVerifyPeerCert() )
{
connector.setTruststore(httpsConf.getTruststorePath());
connector.setTrustPassword(httpsConf.getTruststorePassword());
connector.setNeedClientAuth(true);
}
connector.setWantClientAuth(httpsConf.isRequireClientCert());
connector.setAcceptors(8);
connector.setMaxIdleTime(5000);
connector.setAcceptQueueSize(32);
server.addConnector(connector);
server.setStopAtShutdown(true);
DefaultResourceConfig config = new DefaultResourceConfig(JettyServer.RestService.class);
ServletContainer container = new ServletContainer(config);
Context context = new Context(server, "/", Context.SESSIONS);
context.addServlet(new ServletHolder(container), "/*");
}
示例5: setupHTTPServer
import org.mortbay.jetty.Server; //导入方法依赖的package包/类
private void setupHTTPServer() throws IOException {
TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
TProcessor processor = new Hbase.Processor<Hbase.Iface>(handler);
TServlet thriftHttpServlet = new ThriftHttpServlet(processor, protocolFactory, realUser,
conf, hbaseHandler, securityEnabled, doAsEnabled);
httpServer = new Server();
// Context handler
Context context = new Context(httpServer, "/", Context.SESSIONS);
context.setContextPath("/");
String httpPath = "/*";
httpServer.setHandler(context);
context.addServlet(new ServletHolder(thriftHttpServlet), httpPath);
// set up Jetty and run the embedded server
Connector connector = new SelectChannelConnector();
if(conf.getBoolean(THRIFT_SSL_ENABLED, false)) {
SslSelectChannelConnector sslConnector = new SslSelectChannelConnector();
String keystore = conf.get(THRIFT_SSL_KEYSTORE_STORE);
String password = HBaseConfiguration.getPassword(conf,
THRIFT_SSL_KEYSTORE_PASSWORD, null);
String keyPassword = HBaseConfiguration.getPassword(conf,
THRIFT_SSL_KEYSTORE_KEYPASSWORD, password);
sslConnector.setKeystore(keystore);
sslConnector.setPassword(password);
sslConnector.setKeyPassword(keyPassword);
connector = sslConnector;
}
String host = getBindAddress(conf).getHostAddress();
connector.setPort(listenPort);
connector.setHost(host);
connector.setHeaderBufferSize(1024 * 64);
httpServer.addConnector(connector);
if (doAsEnabled) {
ProxyUsers.refreshSuperUserGroupsConfiguration(conf);
}
// Set the default max thread number to 100 to limit
// the number of concurrent requests so that Thrfit HTTP server doesn't OOM easily.
// Jetty set the default max thread number to 250, if we don't set it.
//
// Our default min thread number 2 is the same as that used by Jetty.
int minThreads = conf.getInt(HTTP_MIN_THREADS, 2);
int maxThreads = conf.getInt(HTTP_MAX_THREADS, 100);
QueuedThreadPool threadPool = new QueuedThreadPool(maxThreads);
threadPool.setMinThreads(minThreads);
httpServer.setThreadPool(threadPool);
httpServer.setSendServerVersion(false);
httpServer.setSendDateHeader(false);
httpServer.setStopAtShutdown(true);
LOG.info("Starting Thrift HTTP Server on " + Integer.toString(listenPort));
}