本文整理汇总了Java中org.mortbay.jetty.Server.setSendServerVersion方法的典型用法代码示例。如果您正苦于以下问题:Java Server.setSendServerVersion方法的具体用法?Java Server.setSendServerVersion怎么用?Java Server.setSendServerVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mortbay.jetty.Server
的用法示例。
在下文中一共展示了Server.setSendServerVersion方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
}
示例2: 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));
}