本文整理汇总了Java中org.eclipse.jetty.server.Server.getHandler方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getHandler方法的具体用法?Java Server.getHandler怎么用?Java Server.getHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.server.Server
的用法示例。
在下文中一共展示了Server.getHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
public void start() throws Exception {
Resource configXml = Resource.newSystemResource(config);
XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
server = (Server) configuration.configure();
// Integer port = getPort();
// if (port != null && port > 0) {
// Connector[] connectors = server.getConnectors();
// for (Connector connector : connectors) {
// connector.setPort(port);
// }
// }
Handler handler = server.getHandler();
if (handler != null && handler instanceof WebAppContext) {
WebAppContext webAppContext = (WebAppContext) handler;
webAppContext.setResourceBase(JettyEmbedServer.class.getResource("/webapp").toString());
}
server.start();
if (logger.isInfoEnabled()) {
logger.info("##Jetty Embed Server is startup!");
}
}
示例2: afterPropertiesSet
import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
public void afterPropertiesSet() throws Exception {
Resource configXml = Resource.newSystemResource(config);
XmlConfiguration configuration = new XmlConfiguration(configXml.getInputStream());
server = (Server) configuration.configure();
Integer port = getPort();
if (port != null && port > 0) {
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", htdocsDir);
}
server.start();
if (logger.isInfoEnabled()) {
logger.info("##Jetty Embed Server is startup!");
}
}
示例3: main
import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
public static void main(String args[]) throws Exception {
Resource jetty_xml = Resource.newSystemResource("jetty/jetty.xml");
XmlConfiguration configuration = new XmlConfiguration(jetty_xml.getInputStream());
Server server = (Server) configuration.configure();
int port = 8081;
Connector[] connectors = server.getConnectors();
for (Connector connector : connectors) {
connector.setPort(port);
}
Handler handler = server.getHandler();
if (handler != null && handler instanceof ServletContextHandler) {
ServletContextHandler servletHandler = (ServletContextHandler) handler;
servletHandler.getInitParams().put("org.eclipse.jetty.servlet.Default.resourceBase", "/tmp/");
}
server.start();
server.join();
}
示例4: reloadContext
import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
/**
* 快速重新启动Application
* @see 通常用Main函数启动JettyServer后,若改动项目的代码,那就需要停止再启动Jetty
* @see 虽免去了Tomcat重新打包几十兆的消耗,但比起PHP完全不用重启来说还是慢,特别是关闭,启动一个新的JVM,消耗不小
* @see 所以我们可以在Main()中捕捉到回车后调用此函数,即可重新载入应用(包括Spring配置文件)
* @param server 当前运行的JettyServer实例
* @param classPath 当前运行的Web应用的classpath
*/
@SuppressWarnings("unused")
private static /*synchronized*/ void reloadContext(Server server, String classPath) throws Exception{
WebAppContext context = (WebAppContext)server.getHandler();
System.out.println("Application reloading..开始");
context.stop();
WebAppClassLoader classLoader = new WebAppClassLoader(context);
classLoader.addClassPath(classPath);
context.setClassLoader(classLoader);
//根据给定的配置文件初始化日志配置(否则应用重载后日志输出组件就会失效)
Log4jConfigurer.initLogging(classPath + "/log4j.properties");
context.start();
System.out.println("Application reloading..完毕");
}
示例5: getTestContainerFactory
import org.eclipse.jetty.server.Server; //导入方法依赖的package包/类
protected TestContainerFactory getTestContainerFactory() throws TestContainerException {
final TestContainerFactory testContainerFactory = super.getTestContainerFactory();
return new TestContainerFactory() {
@Override
public TestContainer create(URI baseUri, DeploymentContext deploymentContext) {
TestContainer container = testContainerFactory.create(baseUri, deploymentContext);
try {
Field field = container.getClass().getDeclaredField("server");
field.setAccessible(true);
Server server = (Server) field.get(container);
Handler handler = server.getHandler();
SecurityHandler securityHandler = identityManager.getSecurityHandler();
if (securityHandler.getHandler() == null) {
securityHandler.setHandler(handler);
}
server.setHandler(securityHandler);
}
catch (Exception e) {
throw new IllegalStateException(e);
}
return container;
}
};
}