use of org.eclipse.jetty.annotations.ServletContainerInitializersStarter in project jetty.project by eclipse.
the class QuickStartConfiguration method configure.
/**
* @see org.eclipse.jetty.webapp.AbstractConfiguration#configure(org.eclipse.jetty.webapp.WebAppContext)
*/
@Override
public void configure(WebAppContext context) throws Exception {
LOG.debug("configure {}", this);
if (context.isStarted()) {
LOG.warn("Cannot configure webapp after it is started");
return;
}
//Temporary: set up the classpath here. This should be handled by the QuickStartDescriptorProcessor
Resource webInf = context.getWebInf();
if (webInf != null && webInf.isDirectory() && context.getClassLoader() instanceof WebAppClassLoader) {
// Look for classes directory
Resource classes = webInf.addPath("classes/");
if (classes.exists())
((WebAppClassLoader) context.getClassLoader()).addClassPath(classes);
// Look for jars
Resource lib = webInf.addPath("lib/");
if (lib.exists() || lib.isDirectory())
((WebAppClassLoader) context.getClassLoader()).addJars(lib);
}
//add the processor to handle normal web.xml content
context.getMetaData().addDescriptorProcessor(new StandardDescriptorProcessor());
//add a processor to handle extended web.xml format
context.getMetaData().addDescriptorProcessor(new QuickStartDescriptorProcessor());
//add a decorator that will find introspectable annotations
//this must be the last Decorator because they are run in reverse order!
context.getObjectFactory().addDecorator(new AnnotationDecorator(context));
//add a context bean that will run ServletContainerInitializers as the context starts
ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter) context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER);
if (starter != null)
throw new IllegalStateException("ServletContainerInitializersStarter already exists");
starter = new ServletContainerInitializersStarter(context);
context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER, starter);
context.addBean(starter, true);
LOG.debug("configured {}", this);
}
use of org.eclipse.jetty.annotations.ServletContainerInitializersStarter in project steve by RWTH-i5-IDSG.
the class SteveAppContext method initJSP.
// -------------------------------------------------------------------------
// JSP stuff
//
// Help by:
//
// https://github.com/jetty-project/embedded-jetty-jsp
// https://github.com/jasonish/jetty-springmvc-jsp-template
// http://examples.javacodegeeks.com/enterprise-java/jetty/jetty-jsp-example
// -------------------------------------------------------------------------
private void initJSP(WebAppContext ctx) {
ctx.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
ctx.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
ctx.addBean(new ServletContainerInitializersStarter(ctx), true);
}
use of org.eclipse.jetty.annotations.ServletContainerInitializersStarter in project mysql_perf_analyzer by yahoo.
the class App method createDeployedApplicationInstance.
private WebAppContext createDeployedApplicationInstance(File workDirectory, String deployedApplicationPath) {
WebAppContext deployedApplication = new WebAppContext();
deployedApplication.setContextPath(this.getContextPath());
deployedApplication.setWar(deployedApplicationPath);
deployedApplication.setAttribute("javax.servlet.context.tempdir", workDirectory.getAbsolutePath());
deployedApplication.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/[^/]*servlet-api-[^/]*\\.jar$|.*/javax.servlet.jsp.jstl-.*\\.jar$|.*/.*taglibs.*\\.jar$");
deployedApplication.setAttribute("org.eclipse.jetty.containerInitializers", jspInitializers());
deployedApplication.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
deployedApplication.addBean(new ServletContainerInitializersStarter(deployedApplication), true);
// webapp.setClassLoader(new URLClassLoader(new
// URL[0],App.class.getClassLoader()));
deployedApplication.addServlet(jspServletHolder(), "*.jsp");
return deployedApplication;
}
use of org.eclipse.jetty.annotations.ServletContainerInitializersStarter in project jetty.project by eclipse.
the class QuickStartDescriptorProcessor method visitContainerInitializer.
public void visitContainerInitializer(WebAppContext context, ContainerInitializer containerInitializer) {
if (containerInitializer == null)
return;
//add the ContainerInitializer to the list of container initializers
List<ContainerInitializer> containerInitializers = (List<ContainerInitializer>) context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS);
if (containerInitializers == null) {
containerInitializers = new ArrayList<ContainerInitializer>();
context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, containerInitializers);
}
containerInitializers.add(containerInitializer);
//Ensure a bean is set up on the context that will invoke the ContainerInitializers as the context starts
ServletContainerInitializersStarter starter = (ServletContainerInitializersStarter) context.getAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER);
if (starter == null) {
starter = new ServletContainerInitializersStarter(context);
context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZER_STARTER, starter);
context.addBean(starter, true);
}
}
use of org.eclipse.jetty.annotations.ServletContainerInitializersStarter in project opennms by OpenNMS.
the class OpenNMSWebAppProvider method createContextHandler.
@Override
public ContextHandler createContextHandler(final App app) throws Exception {
final ContextHandler handler = super.createContextHandler(app);
/*
* Add an alias check that accepts double slashes in our resource paths.
*/
handler.addAliasCheck(new ApproveAbsolutePathAliases());
/*
* Pulled from: http://bengreen.eu/fancyhtml/quickreference/jettyjsp9error.html
*
* Configure the application to support the compilation of JSP files.
* We need a new class loader and some stuff so that Jetty can call the
* onStartup() methods as required.
*/
if (handler instanceof WebAppContext) {
WebAppContext context = (WebAppContext) handler;
context.setAttribute(AnnotationConfiguration.CONTAINER_INITIALIZERS, jspInitializers());
context.setAttribute(InstanceManager.class.getName(), new SimpleInstanceManager());
context.addBean(new ServletContainerInitializersStarter(context), true);
}
return handler;
}
Aggregations