本文整理汇总了Java中org.eclipse.jetty.webapp.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于org.eclipse.jetty.webapp包,在下文中一共展示了Configuration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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: JettyServer
import org.eclipse.jetty.webapp.Configuration; //导入依赖的package包/类
public JettyServer(final NiFiRegistryProperties properties, final CryptoKeyProvider cryptoKeyProvider) {
final QueuedThreadPool threadPool = new QueuedThreadPool(properties.getWebThreads());
threadPool.setName("NiFi Registry Web Server");
this.properties = properties;
this.masterKeyProvider = cryptoKeyProvider;
this.server = new Server(threadPool);
// enable the annotation based configuration to ensure the jsp container is initialized properly
final Configuration.ClassList classlist = Configuration.ClassList.setServerDefault(server);
classlist.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());
try {
configureConnectors();
loadWars();
} catch (final Throwable t) {
startUpFailure(t);
}
}
示例3: init
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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() //
});
}
示例4: createWebAppContext
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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;
}
示例5: configureWebAppContext
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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
示例6: createFrontAppContext
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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;
}
示例7: configureWebAppContext
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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);
}
示例8: createServer
import org.eclipse.jetty.webapp.Configuration; //导入依赖的package包/类
private Server createServer() {
// Taken from Jetty doc
final QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(this.configuration.getMaxThreads());
final Server server = new Server(threadPool);
server.addBean(new ScheduledExecutorScheduler());
if (this.configuration.isNcc()) {
final Configuration.ClassList classList = Configuration.ClassList.setServerDefault(server);
classList.addAfter(
"org.eclipse.jetty.webapp.FragmentConfiguration",
"org.eclipse.jetty.plus.webapp.EnvConfiguration",
"org.eclipse.jetty.plus.webapp.PlusConfiguration");
classList.addBefore(
"org.eclipse.jetty.webapp.JettyWebXmlConfiguration",
"org.eclipse.jetty.annotations.AnnotationConfiguration");
}
return server;
}
示例9: main
import org.eclipse.jetty.webapp.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
SLF4JBridgeHandler.removeHandlersForRootLogger();
SLF4JBridgeHandler.install();
Server server = new Server(9090);
ClassList classlist = Configuration.ClassList.setServerDefault(server);
classlist.addBefore("org.eclipse.jetty.webapp.JettyWebXmlConfiguration", "org.eclipse.jetty.annotations.AnnotationConfiguration");
WebAppContext webapp = new WebAppContext();
webapp.setParentLoaderPriority(true);
webapp.setConfigurationDiscovered(true);
webapp.setContextPath("/");
webapp.setResourceBase("src/main/webapp");
webapp.setWar("src/main/webapp");
ServletHolder servletHolder = webapp.addServlet(DemoUIServlet.class, "/*");
servletHolder.setAsyncSupported(true);
servletHolder.setInitParameter("org.atmosphere.cpr.asyncSupport", JSR356AsyncSupport.class.getName());
server.setHandler(webapp);
ServerContainer webSocketServer = WebSocketServerContainerInitializer.configureContext(webapp);
webSocketServer.setDefaultMaxSessionIdleTimeout(10000000);
server.start();
log.info("Browse http://localhost:9090 to see the demo");
server.join();
}
示例10: main
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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();
}
示例11: main
import org.eclipse.jetty.webapp.Configuration; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
Server server = new Server(8080);
// add web applications
HandlerCollection handlers = new HandlerCollection();
Preconditions.checkArgument(args != null && args.length > 0, "Missing args: web project. Please pass a list of web projects, e.g.: JettyServer helloworld");
for (String arg : args) {
Iterator<String> it = Splitter.on(":").split(arg).iterator();
String domain = it.next();
String projectName = it.hasNext() ? it.next() : domain;
WebAppContext webappContext = createContext(domain, projectName);
handlers.addHandler(webappContext);
}
server.setHandler(handlers);
// enable web 3.0 annotations
Configuration.ClassList classList = Configuration.ClassList.setServerDefault(server);
classList.addBefore(JettyWebXmlConfiguration.class.getName(), AnnotationConfiguration.class.getName());
server.start();
server.join();
}
示例12: startServer
import org.eclipse.jetty.webapp.Configuration; //导入依赖的package包/类
private static void startServer(int port) {
WebAppContext context = new ClasspathWebAppContext(new HashSet<String>(publishedResources));
context.setConfigurations(new Configuration[]{new ClasspathWebXmlConfiguration()});
context.setDescriptor("web.xml");
context.setResourceBase(".");
context.setContextPath("/");
context.setParentLoaderPriority(true);
context.setClassLoader(Thread.currentThread().getContextClassLoader());
Server server = new Server(port);
server.setHandler(context);
try {
server.start();
server.join();
} catch (Exception e) {
if (!(e instanceof InterruptedException)) {
System.out.print("Server stopped\n" + e.getMessage());
e.printStackTrace(System.out);
}
}
}
示例13: createControlledBounceproxyWebApp
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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;
}
示例14: createBounceproxyControllerWebApp
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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;
}
示例15: start
import org.eclipse.jetty.webapp.Configuration; //导入依赖的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();
}