本文整理汇总了Java中org.eclipse.jetty.webapp.WebAppContext.setConfigurations方法的典型用法代码示例。如果您正苦于以下问题:Java WebAppContext.setConfigurations方法的具体用法?Java WebAppContext.setConfigurations怎么用?Java WebAppContext.setConfigurations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.webapp.WebAppContext
的用法示例。
在下文中一共展示了WebAppContext.setConfigurations方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public void start() {
// TODO: remove redundant fields from config and move this check to XRE Redirector
if (! config.getEnableCommunicationEndpoint()) {
log.warn("skipping Jetty endpoint due to configuration");
return;
}
if (started) {
log.warn("Jetty is already started");
}
started = true;
Integer port = config.getCommunicationEndpointPort();
log.info("Starting embedded jetty server (XRERedirector Gateway) on port: {}", port);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setConfigurations(new Configuration[]{new AnnotationConfiguration() {
@Override
public void preConfigure(WebAppContext context) {
ClassInheritanceMap map = new ClassInheritanceMap();
map.put(WebApplicationInitializer.class.getName(), new ConcurrentHashSet<String>() {{
add(WebAppInitializer.class.getName());
}});
context.setAttribute(CLASS_INHERITANCE_MAP, map);
_classInheritanceHandler = new ClassInheritanceHandler(map);
}
}});
server = new Server(port);
server.setHandler(webAppContext);
try {
server.start();
} catch (Exception e) {
log.error("Failed to start embedded jetty server (XRERedirector communication endpoint) on port: " + port, e);
}
log.info("Started embedded jetty server (Redirector Gateway) on port: {}", port);
}
示例2: createWebAppContext
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
private WebAppContext createWebAppContext(URL webXml, Configuration[] configurations) {
WebAppContext context = new WebAppContext();
String war = webXml == null
? "src/main/webapp"
: MY_URL.toExternalForm();
context.setWar(war);
context.setContextPath(prefix);
if (webXml != null) {
context.getMetaData().setWebInfClassesDirs(
Arrays.asList(Resource.newResource(MY_URL)));
}
context.setConfigurations(configurations);
return context;
}
示例3: configureWebAppContext
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Configure the given Jetty {@link WebAppContext} for use.
* @param context the context to configure
* @param initializers the set of initializers to apply
*/
protected final void configureWebAppContext(WebAppContext context,
ServletContextInitializer... initializers) {
Assert.notNull(context, "Context must not be null");
context.setTempDirectory(getTempDirectory());
if (this.resourceLoader != null) {
context.setClassLoader(this.resourceLoader.getClassLoader());
}
String contextPath = getContextPath();
context.setContextPath(StringUtils.hasLength(contextPath) ? contextPath : "/");
context.setDisplayName(getDisplayName());
configureDocumentRoot(context);
if (isRegisterDefaultServlet()) {
addDefaultServlet(context);
}
if (shouldRegisterJspServlet()) {
addJspServlet(context);
context.addBean(new JasperInitializer(context), true);
}
ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
Configuration[] configurations = getWebAppContextConfigurations(context,
initializersToUse);
context.setConfigurations(configurations);
configureSession(context);
postProcessWebAppContext(context);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:31,代码来源:JettyEmbeddedServletContainerFactory.java
示例4: createFrontAppContext
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的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;
}
示例5: configureWebAppContext
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* Configure the given Jetty {@link WebAppContext} for use.
* @param context the context to configure
* @param initializers the set of initializers to apply
*/
protected final void configureWebAppContext(WebAppContext context,
ServletContextInitializer... initializers) {
Assert.notNull(context, "Context must not be null");
context.setTempDirectory(getTempDirectory());
if (this.resourceLoader != null) {
context.setClassLoader(this.resourceLoader.getClassLoader());
}
String contextPath = getContextPath();
context.setContextPath(StringUtils.hasLength(contextPath) ? contextPath : "/");
context.setDisplayName(getDisplayName());
configureDocumentRoot(context);
if (isRegisterDefaultServlet()) {
addDefaultServlet(context);
}
if (shouldRegisterJspServlet()) {
addJspServlet(context);
}
ServletContextInitializer[] initializersToUse = mergeInitializers(initializers);
Configuration[] configurations = getWebAppContextConfigurations(context,
initializersToUse);
context.setConfigurations(configurations);
configureSession(context);
postProcessWebAppContext(context);
}
示例6: createServer
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static Server createServer(int port) {
WebAppContext context = new WebAppContext();
context.setContextPath("/");
context.setResourceBase(WEBAPP);
context.setConfigurations(new Configuration[] { new JettyAnnotationConfiguration() });
// Create server and configure it
final Server server = new Server(port);
server.setHandler(context);
return server;
}
示例7: main
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
WebAppContext webAppContext = new WebAppContext();
webAppContext.setContextPath("/");
webAppContext.setConfigurations(new Configuration[] {
new WebApplicationInitializersConfiguration(SpringInitializer.class) });
webAppContext.setParentLoaderPriority(true);
server.setHandler(webAppContext);
server.start();
server.join();
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:15,代码来源:EmbeddedWarStarter.java
示例8: createAppContext
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的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;
}
示例9: 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);
}
}
}
示例10: 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);
}
}
}
示例11: build
import org.eclipse.jetty.webapp.WebAppContext; //导入方法依赖的package包/类
/**
* 创建用于正常运行调试的Jetty Server, 以src/main/webapp为Web应用目录.
*/
@Override
public Server build(int port, String webApp, String contextPath) throws BindException {
port = this.getAutoPort(port);
serverInitializer.run();
Server server = new Server(port);
WebAppContext webContext = new WebAppContext(webApp, contextPath);
if (false) {
ServletHolder holder = new ServletHolder(new ProxyServlet());
holder.setInitParameter("proxyTo", "http://localhost:3000/");
holder.setInitParameter("prefix", "/");
webContext.addServlet(holder, "/app/");
webContext.addServlet(new ServletHolder(new IndexServlet()), "/proxy/");
}
// webContext.setDefaultsDescriptor("leopard-jetty/webdefault.xml");
// 问题点:http://stackoverflow.com/questions/13222071/spring-3-1-webapplicationinitializer-embedded-jetty-8-annotationconfiguration
webContext.setConfigurations(new Configuration[] { //
new EmbedWebInfConfiguration(), //
new MetaInfConfiguration(), //
new AnnotationConfiguration(), //
new WebXmlConfiguration(), //
new FragmentConfiguration() //
// new TagLibConfiguration() //
});
// webContext.setConfigurations(new Configuration[] { //
// new EmbedWebInfConfiguration()//
// , new EmbedWebXmlConfiguration()//
// , new EmbedMetaInfConfiguration()//
// , new EmbedFragmentConfiguration()//
// , new EmbedAnnotionConfiguration() //
// // , new PlusConfiguration(),//
// // new EnvConfiguration()//
// });
WebAppClassLoader classLoader = null;
try {
// addTldLib(webContext);
classLoader = new LeopardWebAppClassLoader(webContext);
}
catch (IOException e) {
e.printStackTrace();
}
// ClassLoader tldClassLoader = addTldLib(classLoader);
webContext.setClassLoader(classLoader);
webContext.setParentLoaderPriority(true);
// logger.debug(webContext.dump());
Handler rewriteHandler = ResourcesManager.getHandler();
if (rewriteHandler == null) {
server.setHandler(webContext);
}
else {
HandlerCollection handlers = new HandlerCollection();
handlers.addHandler(rewriteHandler);
handlers.addHandler(webContext);
server.setHandler(handlers);
}
server.setStopAtShutdown(true);
return server;
}