Class WebAppClassLoading

java.lang.Object
org.eclipse.jetty.ee.WebAppClassLoading

public class WebAppClassLoading extends Object
Common attributes and methods for configuring the Class loading of web application:
  • Protected (a.k.a. System) classes are classes typically provided by the JVM, that cannot be replaced by the web application, and they are always loaded via the environment or system classloader. They are visible but protected.
  • Hidden (a.k.a. Server) classes are those used to implement the Server and are not made available to the web application. They are hidden from the web application ClassLoader.

These protections are set to reasonable defaults DEFAULT_PROTECTED_CLASSES and DEFAULT_HIDDEN_CLASSES, which may be programmatically configured and will affect the defaults applied to all web applications in the same JVM.

The defaults applied by a specific Server can be configured using addProtectedClasses(Server, String...) and addHiddenClasses(Server, String...). Alternately the Server attributes PROTECTED_CLASSES_ATTRIBUTE and HIDDEN_CLASSES_ATTRIBUTE may be used to direct set a ClassMatcher to use for all web applications within the server instance.

The defaults applied by a specific Environment can be configured using addProtectedClasses(Environment, String...) and addHiddenClasses(Environment, String...). Alternately the Environment attributes PROTECTED_CLASSES_ATTRIBUTE and HIDDEN_CLASSES_ATTRIBUTE may be used to direct set a ClassMatcher to use for all web applications within the server instance.

Ultimately, the configurations set by this class only affects the defaults applied to each web application Context and the ClassMatcher fields of the web applications can be directly access to configure a specific context.

  • Field Details

  • Constructor Details

    • WebAppClassLoading

      public WebAppClassLoading()
  • Method Details

    • getProtectedClasses

      public static ClassMatcher getProtectedClasses(Server server)
      Get the default protected (system) classes for a Server
      Parameters:
      server - The Server for the defaults
      Returns:
      The default protected (system) classes for the Server, which will be empty if not previously configured.
    • getProtectedClasses

      public static ClassMatcher getProtectedClasses(Environment environment)
      Get the default protected (system) classes for an Environment
      Parameters:
      environment - The Server for the defaults
      Returns:
      The default protected (system) classes for the Environment, which will be the DEFAULT_PROTECTED_CLASSES if not previously configured.
    • addProtectedClasses

      public static void addProtectedClasses(String... patterns)
      Add a protected (system) Class pattern to use for all WebAppContexts.
      Parameters:
      patterns - the patterns to use
    • addProtectedClasses

      public static void addProtectedClasses(Attributes attributes, String... patterns)
      Add a protected (system) Class pattern to use for all WebAppContexts of a given Server.
      Parameters:
      attributes - The Attributes instance to add classes to
      patterns - the patterns to use
    • addProtectedClasses

      public static void addProtectedClasses(Server server, String... patterns)
      Add a protected (system) Class pattern to use for all WebAppContexts of a given Server.
      Parameters:
      server - The Server instance to add classes to
      patterns - the patterns to use
    • addProtectedClasses

      public static void addProtectedClasses(Environment environment, String... patterns)
      Add a protected (system) Class pattern to use for WebAppContexts of a given environment.
      Parameters:
      environment - The Environment instance to add classes to
      patterns - the patterns to use
    • getHiddenClasses

      public static ClassMatcher getHiddenClasses(Server server)
      Get the default hidden (server) classes for a Server
      Parameters:
      server - The Server for the defaults
      Returns:
      The default hidden (server) classes for the Server, which will be empty if not previously configured.
    • getHiddenClasses

      public static ClassMatcher getHiddenClasses(Environment environment)
      Get the default hidden (server) classes for an Environment
      Parameters:
      environment - The Server for the defaults
      Returns:
      The default hidden (server) classes for the Environment, which will be DEFAULT_PROTECTED_CLASSES if not previously configured.
    • addHiddenClasses

      public static void addHiddenClasses(String... patterns)
      Add a hidden (server) Class pattern to use for all WebAppContexts of a given Server.
      Parameters:
      patterns - the patterns to use
    • addHiddenClasses

      @Deprecated(forRemoval=true) public static void addHiddenClasses(Attributes attributes, String... patterns)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Add a hidden (server) Class pattern to use for all WebAppContexts of a given Server.
      Parameters:
      attributes - The Attributes instance to add classes to
      patterns - the patterns to use
    • addHiddenClasses

      public static void addHiddenClasses(Server server, String... patterns)
      Add a hidden (server) Class pattern to use for all WebAppContexts of a given Server.
      Parameters:
      server - The Server instance to add classes to
      patterns - the patterns to use
    • addHiddenClasses

      public static void addHiddenClasses(Environment environment, String... patterns)
      Add a hidden (server) Class pattern to use for all ee9 WebAppContexts.
      Parameters:
      environment - The Environment instance to add classes to
      patterns - the patterns to use