本文整理汇总了Java中org.eclipse.jetty.webapp.WebAppContext.setInitParameter方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.setInitParameter方法的具体用法?Java WebAppContext.setInitParameter怎么用?Java WebAppContext.setInitParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.webapp.WebAppContext
的用法示例。
在下文中一共展示了WebAppContext.setInitParameter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addWebApplication
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server addWebApplication(final Server jetty, final String webAppContext,
final String warFilePath) {
WebAppContext webapp = new WebAppContext();
webapp.setContextPath(webAppContext);
webapp.setWar(warFilePath);
webapp.setParentLoaderPriority(false);
webapp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
File tmpPath = new File(getWebAppBaseDirectory(webAppContext));
tmpPath.mkdirs();
webapp.setTempDirectory(tmpPath);
((HandlerCollection) jetty.getHandler()).addHandler(webapp);
return jetty;
}
示例2: initWebApp
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private WebAppContext initWebApp() throws IOException {
WebAppContext ctx = new WebAppContext();
ctx.setContextPath(CONFIG.getContextPath());
ctx.setResourceBase(new ClassPathResource("webapp").getURI().toString());
// Disable directory listings if no index.html is found.
ctx.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
ServletHolder web = new ServletHolder("spring-dispatcher", new DispatcherServlet(springContext));
ServletHolder cxf = new ServletHolder("cxf", new CXFServlet());
ctx.addEventListener(new ContextLoaderListener(springContext));
ctx.addServlet(web, CONFIG.getSpringMapping());
ctx.addServlet(cxf, CONFIG.getCxfMapping());
if (CONFIG.getProfile().isProd()) {
addSecurityFilter(ctx);
}
initJSP(ctx);
return ctx;
}
示例3: createWebApp
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private static WebAppContext createWebApp(String contextPah)
throws Exception
{
WebAppContext webApp = new WebAppContext();
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
webApp.setContextPath(contextPah);
webApp.setCopyWebDir(true);
webApp.setPersistTempDirectory(false);
webApp.setTempDirectory(WORK_DIR);
webApp.setWar(WAR_FILENAME);
return webApp;
}
示例4: start
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start(boolean devMode, int port) throws Exception {
Server server = new Server(new QueuedThreadPool(500));
WebAppContext appContext = new WebAppContext();
String resourceBasePath = "";
//开发者模式
if (devMode) {
String artifact = MavenUtils.get(Thread.currentThread().getContextClassLoader()).getArtifactId();
resourceBasePath = artifact + "/src/main/webapp";
}
appContext.setDescriptor(resourceBasePath + "WEB-INF/web.xml");
appContext.setResourceBase(resourceBasePath);
appContext.setExtractWAR(true);
//init param
appContext.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
if (CommonUtils.isWindowOs()) {
appContext.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
}
//for jsp support
appContext.addBean(new JettyJspParser(appContext));
appContext.addServlet(JettyJspServlet.class, "*.jsp");
appContext.setContextPath("/");
appContext.getServletContext().setExtendedListenerTypes(true);
appContext.setParentLoaderPriority(true);
appContext.setThrowUnavailableOnStartupException(true);
appContext.setConfigurationDiscovered(true);
appContext.setClassLoader(Thread.currentThread().getContextClassLoader());
ServerConnector connector = new ServerConnector(server);
connector.setHost("0.0.0.0");
connector.setPort(port);
server.setConnectors(new Connector[]{connector});
server.setAttribute("org.eclipse.jetty.server.Request.maxFormContentSize", 1024 * 1024 * 1024);
server.setDumpAfterStart(false);
server.setDumpBeforeStop(false);
server.setStopAtShutdown(true);
server.setHandler(appContext);
logger.info("[opencron] JettyLauncher starting...");
server.start();
}
示例5: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(final String[] args) {
InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
final Server server = new Server(_inetSocketAddress);
WebAppContext _webAppContext = new WebAppContext();
final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
it.setResourceBase("WebRoot");
it.setWelcomeFiles(new String[] { "index.html" });
it.setContextPath("/");
AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/com\\.hribol\\.bromium\\.dsl\\.web/.*,.*\\.jar");
it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
};
WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
server.setHandler(_doubleArrow);
String _name = ServerLauncher.class.getName();
final Slf4jLog log = new Slf4jLog(_name);
try {
server.start();
URI _uRI = server.getURI();
String _plus = ("Server started " + _uRI);
String _plus_1 = (_plus + "...");
log.info(_plus_1);
final Runnable _function_1 = () -> {
try {
log.info("Press enter to stop the server...");
final int key = System.in.read();
if ((key != (-1))) {
server.stop();
} else {
log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
new Thread(_function_1).start();
server.join();
} catch (final Throwable _t) {
if (_t instanceof Exception) {
final Exception exception = (Exception)_t;
log.warn(exception.getMessage());
System.exit(1);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
示例6: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(final String[] args) {
InetSocketAddress _inetSocketAddress = new InetSocketAddress("localhost", 8080);
final Server server = new Server(_inetSocketAddress);
WebAppContext _webAppContext = new WebAppContext();
final Procedure1<WebAppContext> _function = (WebAppContext it) -> {
it.setResourceBase("WebRoot");
it.setWelcomeFiles(new String[] { "index.html" });
it.setContextPath("/");
AnnotationConfiguration _annotationConfiguration = new AnnotationConfiguration();
WebXmlConfiguration _webXmlConfiguration = new WebXmlConfiguration();
WebInfConfiguration _webInfConfiguration = new WebInfConfiguration();
MetaInfConfiguration _metaInfConfiguration = new MetaInfConfiguration();
it.setConfigurations(new Configuration[] { _annotationConfiguration, _webXmlConfiguration, _webInfConfiguration, _metaInfConfiguration });
it.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/org\\.xtext\\.dsl\\.restaurante\\.web/.*,.*\\.jar");
it.setInitParameter("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false");
};
WebAppContext _doubleArrow = ObjectExtensions.<WebAppContext>operator_doubleArrow(_webAppContext, _function);
server.setHandler(_doubleArrow);
String _name = ServerLauncher.class.getName();
final Slf4jLog log = new Slf4jLog(_name);
try {
server.start();
URI _uRI = server.getURI();
String _plus = ("Server started " + _uRI);
String _plus_1 = (_plus + "...");
log.info(_plus_1);
final Runnable _function_1 = () -> {
try {
log.info("Press enter to stop the server...");
final int key = System.in.read();
if ((key != (-1))) {
server.stop();
} else {
log.warn("Console input is not available. In order to stop the server, you need to cancel process manually.");
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
new Thread(_function_1).start();
server.join();
} catch (final Throwable _t) {
if (_t instanceof Exception) {
final Exception exception = (Exception)_t;
log.warn(exception.getMessage());
System.exit(1);
} else {
throw Exceptions.sneakyThrow(_t);
}
}
}
示例7: startJettyServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private static void startJettyServer() throws Exception {
final Server server = new Server(Configs.getInt("jetty.port"));
WebAppContext context = new WebAppContext();
String classesPath = RexxarReaderWebBoot.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm();
String webContextPath = StringUtils.substringBefore(classesPath, "/WEB-INF");
logger.info("classesPath : {}",classesPath);
logger.info("web context : {}",webContextPath);
context.setResourceBase(webContextPath);
context.setContextPath("/");
context.setParentLoaderPriority(true);
context.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
context.setClassLoader(Thread.currentThread().getContextClassLoader());
context.setConfigurationClasses(Lists.newArrayList("org.eclipse.jetty.webapp.WebInfConfiguration",
"org.eclipse.jetty.webapp.WebXmlConfiguration",
"org.eclipse.jetty.webapp.MetaInfConfiguration",
"org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
"org.eclipse.jetty.annotations.AnnotationConfiguration"));
server.setHandler(context);
server.start();
logger.info("reader server start");
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
server.stop();
logger.info("reader server stop");
} catch (Exception e) {
logger.error(e.getMessage(),e);
e.printStackTrace();
}
}
});
server.join();
}