本文整理汇总了Java中org.eclipse.jetty.webapp.WebXmlConfiguration类的典型用法代码示例。如果您正苦于以下问题:Java WebXmlConfiguration类的具体用法?Java WebXmlConfiguration怎么用?Java WebXmlConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebXmlConfiguration类属于org.eclipse.jetty.webapp包,在下文中一共展示了WebXmlConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的package包/类
private void init() {
System.out.println("host:" + hostList + " war:" + war);
this.setContextPath("/");
this.setWar(war);
if (hostList != null && !hostList.isEmpty()) {
if (!"localhost".equals(hostList.get(0))) {
String[] hosts = new String[hostList.size()];
hostList.toArray(hosts);
super.setVirtualHosts(hosts);
}
}
this.setConfigurations(new Configuration[] { //
new io.leopard.myjetty.webapp.EmbedWebInfConfiguration(hostList, war), //
new MetaInfConfiguration(), //
new AnnotationConfiguration(), //
new WebXmlConfiguration(), //
new FragmentConfiguration() //
// new TagLibConfiguration() //
});
}
示例2: createFrontAppContext
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的package包/类
protected WebAppContext createFrontAppContext(ClassLoader serverClassLoader, ClassLoader sharedClassLoader) throws URISyntaxException {
ClassLoader frontClassLoader = new URLClassLoader(pathsToURLs(serverClassLoader, getAppClassesPath(FRONT_PATH_IN_JAR)), sharedClassLoader);
WebAppContext frontContext = new WebAppContext();
frontContext.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
frontContext.setContextPath(frontContextPath);
frontContext.setClassLoader(frontClassLoader);
setResourceBase(serverClassLoader, frontContext, FRONT_PATH_IN_JAR);
System.setProperty("cuba.front.baseUrl", PATH_DELIMITER.equals(frontContextPath) ? frontContextPath :
frontContextPath + PATH_DELIMITER);
System.setProperty("cuba.front.apiUrl", PATH_DELIMITER.equals(contextPath) ? "/rest/" :
contextPath + PATH_DELIMITER + "rest" + PATH_DELIMITER);
return frontContext;
}
示例3: main
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的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();
}
示例4: createWebAppContext
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的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;
}
示例5: shouldAddWebAppContextHandler
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的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"));
}
示例6: createControlledBounceproxyWebApp
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的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;
}
示例7: createBounceproxyControllerWebApp
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的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;
}
示例8: start
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的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();
}
示例9: createConfigurations
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的package包/类
private Configuration[] createConfigurations() {
Configuration[] configurations = {
new AnnotationConfiguration(),
new WebInfConfiguration(),
new WebXmlConfiguration(),
new MetaInfConfiguration(),
new FragmentConfiguration(),
new EnvConfiguration(),
new PlusConfiguration(),
new JettyWebXmlConfiguration()
};
return configurations;
}
示例10: createAppContext
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的package包/类
protected WebAppContext createAppContext(ClassLoader serverClassLoader, ClassLoader sharedClassLoader,
String appPathInJar, String contextPath) throws URISyntaxException {
ClassLoader appClassLoader = new URLClassLoader(pathsToURLs(serverClassLoader, getAppClassesPath(appPathInJar)), sharedClassLoader);
WebAppContext appContext = new WebAppContext();
appContext.setConfigurations(new Configuration[]{new WebXmlConfiguration(), createEnvConfiguration()});
appContext.setContextPath(contextPath);
appContext.setClassLoader(appClassLoader);
setResourceBase(serverClassLoader, appContext, appPathInJar);
return appContext;
}
示例11: createWebServer
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的package包/类
@Override
protected ServletContext createWebServer() throws Exception {
server = new Server(new ThreadPoolImpl(new ThreadPoolExecutor(10, 10, 10L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), r -> {
Thread t = new Thread(r);
t.setName("Jetty Thread Pool");
return t;
})));
WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
context.setClassLoader(getClass().getClassLoader());
context.setConfigurations(new Configuration[]{new WebXmlConfiguration()});
context.addBean(new NoListenerConfiguration(context));
server.setHandler(context);
context.setMimeTypes(MIME_TYPES);
context.getSecurityHandler().setLoginService(configureUserRealm());
context.setResourceBase(WarExploder.getExplodedDir().getPath());
ServerConnector connector = new ServerConnector(server);
HttpConfiguration config = connector.getConnectionFactory(HttpConnectionFactory.class).getHttpConfiguration();
// use a bigger buffer as Stapler traces can get pretty large on deeply nested URL
config.setRequestHeaderSize(12 * 1024);
connector.setHost(ADDRESS);
if (System.getProperty("port") != null)
connector.setPort(Integer.parseInt(System.getProperty("port")));
server.addConnector(connector);
server.start();
localPort = connector.getLocalPort();
LOG.info("Running on {}", getURL());
return context.getServletContext();
}
示例12: start
import org.eclipse.jetty.webapp.WebXmlConfiguration; //导入依赖的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.WebXmlConfiguration; //导入依赖的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.WebXmlConfiguration; //导入依赖的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.WebXmlConfiguration; //导入依赖的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");
}