本文整理汇总了Java中org.eclipse.jetty.webapp.WebInfConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java WebInfConfiguration类的具体用法?Java WebInfConfiguration怎么用?Java WebInfConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebInfConfiguration类属于org.eclipse.jetty.webapp包,在下文中一共展示了WebInfConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureWebAppContext
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
/**
* Setups the web application context.
*
* @throws IOException
* @throws Exception
*/
protected void configureWebAppContext(final WebContextWithExtraConfigurations context) throws Exception {
context.setAttribute("javax.servlet.context.tempdir", getScratchDir());
// Set the ContainerIncludeJarPattern so that jetty examines these
// container-path jars for tlds, web-fragments etc.
// If you omit the jar that contains the jstl .tlds, the jsp engine will
// scan for them instead.
context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/[^/]*taglibs.*\\.jar$");
context.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.addBean(new ServletContainerInitializersStarter(context), true);
// context.setClassLoader(getUrlClassLoader());
context.addServlet(jspServletHolder(), "*.jsp");
context.replaceConfiguration(WebInfConfiguration.class, WebInfConfigurationHomeUnpacked.class);
}
示例2: main
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
int port = 8080;
Server server = new Server(port);
WebAppContext context = new WebAppContext();
context.setWar("./src/main/webapp");
context.setConfigurations(new Configuration[] {
new AnnotationConfiguration(), new WebXmlConfiguration(),
new WebInfConfiguration(), new TagLibConfiguration(),
new PlusConfiguration(), new MetaInfConfiguration(),
new FragmentConfiguration(), new EnvConfiguration() });
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
server.dump(System.err);
server.join();
}
示例3: createWebAppContext
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
WebAppContext createWebAppContext() throws IOException, SAXException, ClassNotFoundException, UnavailableException {
webAppContext = new WebAppContext();
webAppContext.setDefaultsDescriptor(GoWebXmlConfiguration.configuration(getWarFile()));
webAppContext.setConfigurationClasses(new String[]{
WebInfConfiguration.class.getCanonicalName(),
WebXmlConfiguration.class.getCanonicalName(),
JettyWebXmlConfiguration.class.getCanonicalName()
});
webAppContext.setContextPath(systemEnvironment.getWebappContextPath());
// delegate all logging to parent classloader to avoid initialization of loggers in multiple classloaders
webAppContext.addSystemClass("org.apache.log4j.");
webAppContext.addSystemClass("org.slf4j.");
webAppContext.addSystemClass("org.apache.commons.logging.");
webAppContext.setWar(getWarFile());
webAppContext.setParentLoaderPriority(systemEnvironment.getParentLoaderPriority());
return webAppContext;
}
示例4: shouldAddWebAppContextHandler
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
@Test
public void shouldAddWebAppContextHandler() throws Exception {
ArgumentCaptor<HandlerCollection> captor = ArgumentCaptor.forClass(HandlerCollection.class);
jetty9Server.configure();
verify(server, times(1)).setHandler(captor.capture());
HandlerCollection handlerCollection = captor.getValue();
assertThat(handlerCollection.getHandlers().length, is(3));
Handler handler = handlerCollection.getHandlers()[2];
assertThat(handler instanceof WebAppContext, is(true));
WebAppContext webAppContext = (WebAppContext) handler;
List<String> configClasses = new ArrayList<>(Arrays.asList(webAppContext.getConfigurationClasses()));
assertThat(configClasses.contains(WebInfConfiguration.class.getCanonicalName()), is(true));
assertThat(configClasses.contains(WebXmlConfiguration.class.getCanonicalName()), is(true));
assertThat(configClasses.contains(JettyWebXmlConfiguration.class.getCanonicalName()), is(true));
assertThat(webAppContext.getContextPath(), is("context"));
assertThat(webAppContext.getWar(), is("cruise.war"));
assertThat(webAppContext.isParentLoaderPriority(), is(true));
assertThat(webAppContext.getDefaultsDescriptor(), is("jar:file:cruise.war!/WEB-INF/webdefault.xml"));
}
示例5: createControlledBounceproxyWebApp
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
public static WebAppContext createControlledBounceproxyWebApp(String parentContext, Properties props) {
WebAppContext bounceproxyWebapp = new WebAppContext();
bounceproxyWebapp.setContextPath(createContextPath(parentContext, BOUNCEPROXY_CONTEXT));
bounceproxyWebapp.setWar("target/controlled-bounceproxy.war");
if (props != null) {
bounceproxyWebapp.setConfigurations(new Configuration[]{ new WebInfConfiguration(),
new WebXmlConfiguration(), new SystemPropertyServletConfiguration(props) });
}
// Makes jetty load classes in the same order as JVM. Otherwise there's
// a conflict loading loggers.
bounceproxyWebapp.setParentLoaderPriority(true);
return bounceproxyWebapp;
}
示例6: createBounceproxyControllerWebApp
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
public static WebAppContext createBounceproxyControllerWebApp(String warFileName,
String parentContext,
Properties props) {
WebAppContext bounceproxyWebapp = new WebAppContext();
bounceproxyWebapp.setContextPath(createContextPath(parentContext, BOUNCEPROXYCONTROLLER_CONTEXT));
bounceproxyWebapp.setWar("target/" + warFileName + ".war");
if (props != null) {
bounceproxyWebapp.setConfigurations(new Configuration[]{ new WebInfConfiguration(),
new WebXmlConfiguration(), new SystemPropertyServletConfiguration(props) });
}
// Makes jetty load classes in the same order as JVM. Otherwise there's
// a conflict loading loggers.
bounceproxyWebapp.setParentLoaderPriority(true);
return bounceproxyWebapp;
}
示例7: start
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
public void start() throws Exception {
server = new Server(8080);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setResourceBase("src/main/webapp");
webAppContext.setContextPath("/");
File[] mavenLibs = Maven.resolver().loadPomFromFile("pom.xml")
.importCompileAndRuntimeDependencies()
.resolve().withTransitivity().asFile();
for (File file: mavenLibs) {
webAppContext.getMetaData().addWebInfJar(new FileResource(file.toURI()));
}
webAppContext.getMetaData().addContainerResource(new FileResource(new File("./target/classes").toURI()));
webAppContext.setConfigurations(new Configuration[] {
new AnnotationConfiguration(),
new WebXmlConfiguration(),
new WebInfConfiguration()
});
server.setHandler(webAppContext);
logger.info(">>> STARTING EMBEDDED JETTY SERVER");
server.start();
}
示例8: createConfigurations
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
private Configuration[] createConfigurations() {
Configuration[] configurations = {
new AnnotationConfiguration(),
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new FragmentConfiguration(),
new EnvConfiguration(),
new PlusConfiguration(),
new JettyWebXmlConfiguration()
};
return configurations;
}
示例9: beforeStart
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
@Override
public void beforeStart(WebAppContext context) {
context.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*/taglibs-standard-impl-[^/]*\\.jar$");
Configuration[] current = context.getConfigurations();
List<Configuration> cfn = new ArrayList<Configuration>(Arrays.asList(current));
cfn.add(new EmbeddedJspConfiguration());
context.setConfigurations(cfn.toArray(new Configuration[cfn.size()]));
}
示例10: configureWebAppContext
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
@Override
protected void configureWebAppContext(final WebContextWithExtraConfigurations context) throws Exception {
super.configureWebAppContext(context);
WebContextWithExtraConfigurations webAppContext = context;
webAppContext.replaceConfiguration(MetaInfConfiguration.class, MetaInfFolderConfiguration.class);
// webAppContext.replaceConfiguration(FragmentConfiguration.class,
// FragmentFolderConfiguration.class);
webAppContext.replaceConfiguration(WebInfConfiguration.class, WebInfFolderExtendedConfiguration.class);
// TODO Review - this will make EVERYTHING on the classpath be
// scanned for META-INF/resources and web-fragment.xml - great for dev!
// NOTE: Several patterns can be listed, separate by comma
webAppContext.setAttribute(WebInfConfiguration.CONTAINER_JAR_PATTERN, ".*\\.jar");
webAppContext.setAttribute(WebInfConfiguration.WEBINF_JAR_PATTERN, ".*\\.jar");
}
示例11: JettyLaucher
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
JettyLaucher(final Properties props) {
String host = props.getProperty("host", "127.0.0.1");
int port = Integer.parseInt(props.getProperty("port", "8080"));
int timeout = Integer.parseInt(props.getProperty("timeoutSec", "900"));
String baseDir = props.getProperty("baseDir", "webapp");
logger.info("Try to start server [{}:{}], baseDir={}, connection-timeout={}sec.", host, port, baseDir, timeout);
System.setProperty(Constants.SYSPROP_DIR_WEBAPP, baseDir);
// Handler for multiple web apps
HandlerCollection handlers = new HandlerCollection();
webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
".*/classes/*");
webAppContext.setResourceBase(baseDir);
webAppContext.setConfigurations(new Configuration[] {
new AnnotationConfiguration(), new WebInfConfiguration(),
new PlusConfiguration(), new MetaInfConfiguration(),
new FragmentConfiguration(), new EnvConfiguration()
});
handlers.addHandler(webAppContext);
ServerConnector connector = new ServerConnector(server);
connector.setHost(host);
connector.setPort(port);
connector.setIdleTimeout(timeout * 1000);
server.addConnector(connector);
server.setHandler(handlers);
}
示例12: start
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
private void start() {
ProtectionDomain domain = WebAppRunner.class.getProtectionDomain();
URL location = domain.getCodeSource().getLocation();
WebAppContext context = new WebAppContext();
context.setContextPath( "/" );
context.setWar( location.toExternalForm() );
context.setParentLoaderPriority( true );
context.setConfigurations( new Configuration[] {
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new PlusConfiguration(),
new JettyWebXmlConfiguration(),
new AnnotationConfiguration()
} );
Server server = new Server( 8080 );
server.dumpStdErr();
server.setHandler( context );
try {
server.start();
server.join();
}
catch ( Exception e ) {
LOG.warn( e );
}
}
示例13: createWebAppContext
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
private WebAppContext createWebAppContext(String path, File war) throws MalformedURLException {
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath(path);
webAppContext.setParentLoaderPriority(false);
if (war == null) {
webAppContext.setWar(Main.class.getProtectionDomain().getCodeSource().getLocation().toExternalForm());
} else {
webAppContext.setWar(war.toURI().toURL().toExternalForm());
}
webAppContext.setConfigurations(new Configuration[] { new AnnotationConfiguration(), new WebInfConfiguration(),
new WebXmlConfiguration(), new MetaInfConfiguration(), new FragmentConfiguration(),
new EnvConfiguration(), new PlusConfiguration(), new JettyWebXmlConfiguration() });
return webAppContext;
}
示例14: loadWar
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
private void loadWar()
{
File war = new File("./webapp/jqm-ws.war");
if (!war.exists() || !war.isFile())
{
return;
}
jqmlogger.info("Jetty will now load the web service application war");
// Load web application.
webAppContext = new WebAppContext(war.getPath(), "/");
webAppContext.setDisplayName("JqmWebServices");
// Hide server classes from the web app
final int nbEx = 5;
String[] defExcl = webAppContext.getDefaultServerClasses();
String[] exclusions = new String[defExcl.length + nbEx];
for (int i = nbEx; i <= defExcl.length; i++)
{
exclusions[i] = defExcl[i - nbEx];
}
exclusions[0] = "com.enioka.jqm.tools.";
exclusions[1] = "com.enioka.jqm.api.";
// exclusions[2] = "org.slf4j.";
// exclusions[3] = "org.apache.log4j.";
exclusions[4] = "org.glassfish."; // Jersey
webAppContext.setServerClasses(exclusions);
// JQM configuration should be on the class path
webAppContext.setExtraClasspath("conf/jqm.properties");
webAppContext.setInitParameter("jqmnode", node.getName());
webAppContext.setInitParameter("jqmnodeid", node.getId().toString());
// Set configurations (order is important: need to unpack war before reading web.xml)
webAppContext.setConfigurations(new Configuration[] { new WebInfConfiguration(), new WebXmlConfiguration(),
new MetaInfConfiguration(), new FragmentConfiguration(), new AnnotationConfiguration() });
h.addHandler(webAppContext);
}
示例15: ExternalContext
import org.eclipse.jetty.webapp.WebInfConfiguration; //导入依赖的package包/类
public ExternalContext(String webAppRoot,
MetricRegistry metricsRegistry,
HealthCheckRegistry healthCheckRegistry,
String contextPath) throws IOException {
super(webAppRoot, contextPath);
setAttribute(METRICS_REGISTRY_SERVLET_ATTRIBUTE, metricsRegistry);
setAttribute(HEALTH_CHECK_REGISTRY_SERVLET_ATTRIBUTE, healthCheckRegistry);
setAttribute(InstrumentedFilter.REGISTRY_ATTRIBUTE, metricsRegistry);
addFilter(ThreadNameFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
addFilter(RequestAndAccessCorrelationFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
addFilter(InstrumentedFilter.class, "/*", EnumSet.allOf(DispatcherType.class));
setConfigurations(new org.eclipse.jetty.webapp.Configuration[]{new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new JettyWebXmlConfiguration(),
new TagLibConfiguration()});
// Jetty requires a 'defaults descriptor' on the filesystem
setDefaultsDescriptor(extractWebdefaultXml().getPath());
//ensure the logback settings we've already configured are re-used in the app.
setParentLoaderPriority(true);
//disable the default directory listing
setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
}