or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

class-visibility.mdclassloader.mdconfiguration.mddescriptors.mdindex.mdmetadata.mdwebapp-context.md
tile.json

tessl/maven-org-eclipse-jetty--jetty-webapp

Jetty web application support library providing comprehensive webapp deployment, configuration, and class loading capabilities

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.eclipse.jetty/jetty-webapp@11.0.x

To install, run

npx @tessl/cli install tessl/maven-org-eclipse-jetty--jetty-webapp@11.0.0

index.mddocs/

Jetty WebApp

Jetty WebApp is a comprehensive web application support library for the Eclipse Jetty web server and servlet container. It provides complete infrastructure for deploying, configuring, and managing Java web applications (WAR files) with full servlet specification compliance, advanced class loading capabilities, and extensive customization through a pluggable configuration system.

Package Information

  • Package Name: org.eclipse.jetty:jetty-webapp
  • Package Type: Maven
  • Language: Java
  • Installation: Add to your Maven pom.xml:
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-webapp</artifactId>
    <version>11.0.25</version>
</dependency>

For Gradle:

implementation 'org.eclipse.jetty:jetty-webapp:11.0.25'

Core Imports

import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.webapp.Configuration;
import org.eclipse.jetty.webapp.Configurations;
import org.eclipse.jetty.webapp.WebAppClassLoader;

Basic Usage

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

public class WebAppExample {
    public static void main(String[] args) throws Exception {
        Server server = new Server(8080);
        
        // Create webapp context
        WebAppContext webapp = new WebAppContext();
        webapp.setContextPath("/myapp");
        webapp.setWar("path/to/myapp.war");
        
        // Configure and start
        server.setHandler(webapp);
        server.start();
        server.join();
    }
}

Architecture

Jetty WebApp is built around several key architectural components:

  • WebAppContext: Central orchestrator that coordinates all aspects of webapp deployment and lifecycle management
  • Configuration System: Pluggable configuration components implementing specific aspects of webapp setup (XML processing, class loading, security, etc.)
  • ClassLoader Framework: Servlet-compliant class loading with fine-grained visibility controls and caching capabilities
  • Metadata System: Comprehensive tracking of configuration sources, descriptor processing, and annotation discovery
  • Descriptor Processing: XML descriptor parsing and processing for web.xml, web-fragment.xml, and Jetty-specific configurations

Capabilities

Web Application Context Management

Primary interface for creating, configuring, and managing web application contexts with complete lifecycle control and extensive customization options.

public class WebAppContext extends ServletContextHandler implements WebAppClassLoader.Context {
    // Core constructors
    public WebAppContext();
    public WebAppContext(String webApp, String contextPath);
    public WebAppContext(Resource webApp, String contextPath);
    
    // Configuration management
    public void setConfigurationClasses(String[] configurations);
    public Configurations getConfigurations();
    public void addConfiguration(Configuration... configuration);
    
    // WAR and resource management
    public void setWar(String war);
    public void setWarResource(Resource war);
    public String getWar();
    
    // Lifecycle methods
    public void preConfigure() throws Exception;
    public boolean configure() throws Exception;
    public void postConfigure() throws Exception;
}

Web Application Context

ClassLoader Management

Servlet specification compliant class loading with advanced visibility controls, caching, and transformation capabilities for isolated webapp execution.

public class WebAppClassLoader extends URLClassLoader implements ClassVisibilityChecker {
    public WebAppClassLoader(Context context);
    public WebAppClassLoader(ClassLoader parent, Context context);
    
    // Classpath management
    public void addClassPath(Resource resource);
    public void addJars(Resource lib);
    
    // Visibility controls
    public boolean isSystemClass(Class<?> clazz);
    public boolean isServerClass(Class<?> clazz);
    
    // Transformation support
    public void addTransformer(ClassFileTransformer transformer);
}

public class CachingWebAppClassLoader extends WebAppClassLoader {
    public void clearCache();
}

ClassLoader Management

Configuration Framework

Pluggable system for configuring different aspects of webapp deployment through the ServiceLoader pattern with dependency resolution and lifecycle management.

public interface Configuration {
    void preConfigure(WebAppContext context) throws Exception;
    void configure(WebAppContext context) throws Exception;
    void postConfigure(WebAppContext context) throws Exception;
    void deconfigure(WebAppContext context) throws Exception;
    
    boolean isEnabledByDefault();
    Collection<String> getDependencies();
    Collection<String> getDependents();
}

public class Configurations extends AbstractList<Configuration> implements Dumpable {
    public static Configurations setServerDefault(Server server);
    public static List<Configuration> getKnown();
    
    public void sort();
    public boolean configure(WebAppContext webapp) throws Exception;
}

Configuration Framework

Metadata and Descriptor Processing

Complete metadata container for webapp configuration with descriptor processing, annotation discovery, and origin tracking for all configuration elements.

public class MetaData {
    // Descriptor management
    public void setWebDescriptor(WebDescriptor descriptor);
    public void addFragmentDescriptor(Resource jarResource, FragmentDescriptor descriptor);
    public void addOverrideDescriptor(OverrideDescriptor descriptor);
    
    // Annotation processing
    public void addDiscoveredAnnotations(List<DiscoveredAnnotation> annotations);
    
    // Resolution and ordering
    public void orderFragments();
    public void resolve(WebAppContext context) throws Exception;
    
    // Origin tracking
    public Origin getOrigin(String name);
    public void setOrigin(String name, Descriptor d);
}

Metadata and Descriptors

Descriptor Classes

XML descriptor parsing and processing for web.xml, web-fragment.xml, and Jetty configuration files.

public abstract class Descriptor {
    public void parse(XmlParser parser) throws Exception;
    public boolean isParsed();
    public Resource getResource();
    public XmlParser.Node getRoot();
}

public class WebDescriptor extends Descriptor {
    public int getMajorVersion();
    public int getMinorVersion();
    public MetaData.Complete getMetaDataComplete();
    public boolean isDistributable();
}

public class FragmentDescriptor extends WebDescriptor {
    public String getName();
    public List<String> getBefores();
    public List<String> getAfters();
    public OtherType getOtherType();
}

Descriptor Classes

Class Visibility Controls

Pattern-based system for controlling class visibility between webapp, server, and system classloaders with support for inclusion/exclusion patterns.

public class ClassMatcher extends AbstractSet<String> {
    public ClassMatcher();
    public ClassMatcher(String... patterns);
    
    public boolean include(String name);
    public boolean exclude(String name);
    public boolean match(String name);
    public boolean match(Class<?> clazz);
    public boolean match(String name, URL url);
    
    public String[] getInclusions();
    public String[] getExclusions();
}

Class Visibility

Types

Core Context Types

public interface WebAppClassLoader.Context extends ClassVisibilityChecker {
    Resource newResource(String urlOrPath) throws IOException;
    PermissionCollection getPermissions();
    boolean isParentLoaderPriority();
    List<Resource> getExtraClasspath();
    boolean isServerResource(String name, URL parentUrl);
    boolean isSystemResource(String name, URL webappUrl);
}

Configuration Types

public abstract class AbstractConfiguration implements Configuration {
    protected AbstractConfiguration();
    protected AbstractConfiguration(boolean enabledByDefault);
    
    protected void addDependencies(String... classes);
    protected void protect(String... classes);
    protected void hide(String... classes);
    protected void expose(String... classes);
}

public interface Configuration.WrapperFunction {
    Configuration wrapConfiguration(Configuration configuration);
}

Metadata Types

public enum Origin {
    NotSet, WebXml, WebDefaults, WebOverride, WebFragment, Annotation, API;
    
    public static Origin of(Object o);
}

public static class MetaData.OriginInfo {
    public OriginInfo(String n, Annotation a, Class<?> ac);
    public OriginInfo(String n, Descriptor d);
    public OriginInfo(String n);
    
    public String getName();
    public Origin getOriginType();
    public Descriptor getDescriptor();
}

public enum MetaData.Complete {
    NotSet, True, False
}

Descriptor Types

public abstract class Descriptor {
    protected Descriptor(Resource xml);
    
    public void parse(XmlParser parser) throws Exception;
    public boolean isParsed();
    public Resource getResource();
    public XmlParser.Node getRoot();
}

public interface DescriptorProcessor {
    void process(WebAppContext context, Descriptor descriptor) throws Exception;
}

Utility Types

public interface Ordering {
    List<Resource> order(List<Resource> fragments);
}

public abstract class DiscoveredAnnotation {
    public DiscoveredAnnotation(WebAppContext context, String className);
    public DiscoveredAnnotation(WebAppContext context, String className, Resource resource);
    
    public abstract void apply();
    public String getClassName();
    public Class<?> getTargetClass();
}