Search in sources :

Example 1 with StandardDescriptorProcessor

use of org.eclipse.jetty.webapp.StandardDescriptorProcessor 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);
}
Also used : StandardDescriptorProcessor(org.eclipse.jetty.webapp.StandardDescriptorProcessor) ServletContainerInitializersStarter(org.eclipse.jetty.annotations.ServletContainerInitializersStarter) Resource(org.eclipse.jetty.util.resource.Resource) WebAppClassLoader(org.eclipse.jetty.webapp.WebAppClassLoader) AnnotationDecorator(org.eclipse.jetty.annotations.AnnotationDecorator)

Aggregations

AnnotationDecorator (org.eclipse.jetty.annotations.AnnotationDecorator)1 ServletContainerInitializersStarter (org.eclipse.jetty.annotations.ServletContainerInitializersStarter)1 Resource (org.eclipse.jetty.util.resource.Resource)1 StandardDescriptorProcessor (org.eclipse.jetty.webapp.StandardDescriptorProcessor)1 WebAppClassLoader (org.eclipse.jetty.webapp.WebAppClassLoader)1