Package org.eclipse.jetty.annotations
Class AnnotationConfiguration
- java.lang.Object
-
- org.eclipse.jetty.webapp.AbstractConfiguration
-
- org.eclipse.jetty.annotations.AnnotationConfiguration
-
- All Implemented Interfaces:
org.eclipse.jetty.webapp.Configuration
public class AnnotationConfiguration extends org.eclipse.jetty.webapp.AbstractConfigurationConfiguration for Annotations
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAnnotationConfiguration.ClassInheritanceMapclassAnnotationConfiguration.ParserTaskParserTask Task to executing scanning of a resource for annotations.classAnnotationConfiguration.ServletContainerInitializerComparatorServletContainerInitializerComparator Comparator impl that orders a set of ServletContainerInitializers according to the list of classnames (optionally containing a "*" wildcard character) established in a ServletContainerInitializerOrdering.classAnnotationConfiguration.ServletContainerInitializerOrderingServletContainerInitializerOrderingclassAnnotationConfiguration.TimeStatisticTimeStatistic Simple class to capture elapsed time of an operation.
-
Field Summary
Fields Modifier and Type Field Description protected ClassInheritanceHandler_classInheritanceHandlerprotected java.util.List<ContainerInitializerAnnotationHandler>_containerInitializerAnnotationHandlersprotected org.eclipse.jetty.util.statistic.CounterStatistic_containerPathStatsprotected java.util.List<AbstractDiscoverableAnnotationHandler>_discoverableAnnotationHandlersprotected java.util.List<jakarta.servlet.ServletContainerInitializer>_initializersprotected java.util.List<AnnotationConfiguration.ParserTask>_parserTasksprotected java.util.regex.Pattern_sciExcludePatternprotected org.eclipse.jetty.util.statistic.CounterStatistic_webInfClassesStatsprotected org.eclipse.jetty.util.statistic.CounterStatistic_webInfLibStatsstatic java.lang.StringCLASS_INHERITANCE_MAPstatic java.lang.StringCONTAINER_INITIALIZER_STARTERstatic java.lang.StringCONTAINER_INITIALIZERSstatic intDEFAULT_MAX_SCAN_WAITstatic booleanDEFAULT_MULTI_THREADEDstatic java.lang.StringMAX_SCAN_WAITstatic java.lang.StringMULTI_THREADEDstatic java.lang.StringSERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERNstatic java.lang.StringSERVLET_CONTAINER_INITIALIZER_ORDER
-
Constructor Summary
Constructors Constructor Description AnnotationConfiguration()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDiscoverableAnnotationHandler(AbstractDiscoverableAnnotationHandler handler)voidcloneConfigure(org.eclipse.jetty.webapp.WebAppContext template, org.eclipse.jetty.webapp.WebAppContext context)voidconfigure(org.eclipse.jetty.webapp.WebAppContext context)protected AnnotationParsercreateAnnotationParser(int javaPlatform)voidcreateServletContainerInitializerAnnotationHandlers(org.eclipse.jetty.webapp.WebAppContext context, java.util.List<jakarta.servlet.ServletContainerInitializer> scis)AnnotationConfiguration.ServletContainerInitializerOrderinggetInitializerOrdering(org.eclipse.jetty.webapp.WebAppContext context)Jetty-specific extension that allows an ordering to be applied across ALL ServletContainerInitializers.org.eclipse.jetty.util.resource.ResourcegetJarFor(jakarta.servlet.ServletContainerInitializer service)protected intgetMaxScanWait(org.eclipse.jetty.webapp.WebAppContext context)Work out how long we should wait for the async scanning to occur.java.util.List<jakarta.servlet.ServletContainerInitializer>getNonExcludedInitializers(org.eclipse.jetty.webapp.WebAppContext context)Get SCIs that are not excluded from considerationbooleanisFromContainerClassPath(org.eclipse.jetty.webapp.WebAppContext context, jakarta.servlet.ServletContainerInitializer sci)Test if the ServletContainerInitializer is from the container classpathbooleanisFromExcludedJar(org.eclipse.jetty.webapp.WebAppContext context, jakarta.servlet.ServletContainerInitializer sci, org.eclipse.jetty.util.resource.Resource sciResource)Check to see if the ServletContainerIntializer loaded via the ServiceLoader came from a jar that is excluded by the fragment ordering.booleanisFromWebInfClasses(org.eclipse.jetty.webapp.WebAppContext context, org.eclipse.jetty.util.resource.Resource sci)Test if the ServletContainerInitializer is from WEB-INF/classesprotected booleanisUseMultiThreading(org.eclipse.jetty.webapp.WebAppContext context)Check if we should use multiple threads to scan for annotations or notbooleanmatchesExclusionPattern(jakarta.servlet.ServletContainerInitializer sci)Test if the ServletContainerIntializer is excluded by the o.e.j.containerInitializerExclusionPatternvoidparseContainerPath(org.eclipse.jetty.webapp.WebAppContext context, AnnotationParser parser)Scan jars on container path.voidparseWebInfClasses(org.eclipse.jetty.webapp.WebAppContext context, AnnotationParser parser)Scan classes in WEB-INF/classes.voidparseWebInfLib(org.eclipse.jetty.webapp.WebAppContext context, AnnotationParser parser)Scan jars in WEB-INF/lib.voidpostConfigure(org.eclipse.jetty.webapp.WebAppContext context)voidpreConfigure(org.eclipse.jetty.webapp.WebAppContext context)protected voidscanForAnnotations(org.eclipse.jetty.webapp.WebAppContext context)Perform scanning of classes for discoverable annotations such as WebServlet/WebFilter/WebListener-
Methods inherited from class org.eclipse.jetty.webapp.AbstractConfiguration
abort, addDependencies, addDependencies, addDependents, addDependents, deconfigure, destroy, expose, getDependencies, getDependents, getServerClasses, getSystemClasses, hide, isEnabledByDefault, protect, protectAndExpose
-
-
-
-
Field Detail
-
SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN
public static final java.lang.String SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN
- See Also:
- Constant Field Values
-
SERVLET_CONTAINER_INITIALIZER_ORDER
public static final java.lang.String SERVLET_CONTAINER_INITIALIZER_ORDER
- See Also:
- Constant Field Values
-
CLASS_INHERITANCE_MAP
public static final java.lang.String CLASS_INHERITANCE_MAP
- See Also:
- Constant Field Values
-
CONTAINER_INITIALIZERS
public static final java.lang.String CONTAINER_INITIALIZERS
- See Also:
- Constant Field Values
-
CONTAINER_INITIALIZER_STARTER
public static final java.lang.String CONTAINER_INITIALIZER_STARTER
- See Also:
- Constant Field Values
-
MULTI_THREADED
public static final java.lang.String MULTI_THREADED
- See Also:
- Constant Field Values
-
MAX_SCAN_WAIT
public static final java.lang.String MAX_SCAN_WAIT
- See Also:
- Constant Field Values
-
DEFAULT_MAX_SCAN_WAIT
public static final int DEFAULT_MAX_SCAN_WAIT
- See Also:
- Constant Field Values
-
DEFAULT_MULTI_THREADED
public static final boolean DEFAULT_MULTI_THREADED
- See Also:
- Constant Field Values
-
_discoverableAnnotationHandlers
protected final java.util.List<AbstractDiscoverableAnnotationHandler> _discoverableAnnotationHandlers
-
_classInheritanceHandler
protected ClassInheritanceHandler _classInheritanceHandler
-
_containerInitializerAnnotationHandlers
protected final java.util.List<ContainerInitializerAnnotationHandler> _containerInitializerAnnotationHandlers
-
_parserTasks
protected java.util.List<AnnotationConfiguration.ParserTask> _parserTasks
-
_containerPathStats
protected org.eclipse.jetty.util.statistic.CounterStatistic _containerPathStats
-
_webInfLibStats
protected org.eclipse.jetty.util.statistic.CounterStatistic _webInfLibStats
-
_webInfClassesStats
protected org.eclipse.jetty.util.statistic.CounterStatistic _webInfClassesStats
-
_sciExcludePattern
protected java.util.regex.Pattern _sciExcludePattern
-
_initializers
protected java.util.List<jakarta.servlet.ServletContainerInitializer> _initializers
-
-
Method Detail
-
preConfigure
public void preConfigure(org.eclipse.jetty.webapp.WebAppContext context) throws java.lang.Exception- Specified by:
preConfigurein interfaceorg.eclipse.jetty.webapp.Configuration- Overrides:
preConfigurein classorg.eclipse.jetty.webapp.AbstractConfiguration- Throws:
java.lang.Exception
-
addDiscoverableAnnotationHandler
public void addDiscoverableAnnotationHandler(AbstractDiscoverableAnnotationHandler handler)
-
configure
public void configure(org.eclipse.jetty.webapp.WebAppContext context) throws java.lang.Exception- Specified by:
configurein interfaceorg.eclipse.jetty.webapp.Configuration- Overrides:
configurein classorg.eclipse.jetty.webapp.AbstractConfiguration- Throws:
java.lang.Exception
-
postConfigure
public void postConfigure(org.eclipse.jetty.webapp.WebAppContext context) throws java.lang.Exception- Specified by:
postConfigurein interfaceorg.eclipse.jetty.webapp.Configuration- Overrides:
postConfigurein classorg.eclipse.jetty.webapp.AbstractConfiguration- Throws:
java.lang.Exception
-
scanForAnnotations
protected void scanForAnnotations(org.eclipse.jetty.webapp.WebAppContext context) throws java.lang.ExceptionPerform scanning of classes for discoverable annotations such as WebServlet/WebFilter/WebListener- Parameters:
context- the context for the scan- Throws:
java.lang.Exception- if unable to scan
-
createAnnotationParser
protected AnnotationParser createAnnotationParser(int javaPlatform)
- Parameters:
javaPlatform- The java platform to scan for.- Returns:
- a new AnnotationParser. This method can be overridden to use a different implementation of the AnnotationParser. Note that this is considered internal API.
-
isUseMultiThreading
protected boolean isUseMultiThreading(org.eclipse.jetty.webapp.WebAppContext context)
Check if we should use multiple threads to scan for annotations or not- Parameters:
context- the context of the multi threaded setting- Returns:
- true if multi threading is enabled on the context, server, or via a System property.
- See Also:
MULTI_THREADED
-
getMaxScanWait
protected int getMaxScanWait(org.eclipse.jetty.webapp.WebAppContext context)
Work out how long we should wait for the async scanning to occur.- Parameters:
context- the context of the max scan wait setting- Returns:
- the max scan wait setting on the context, or server, or via a System property.
- See Also:
MAX_SCAN_WAIT
-
cloneConfigure
public void cloneConfigure(org.eclipse.jetty.webapp.WebAppContext template, org.eclipse.jetty.webapp.WebAppContext context) throws java.lang.Exception- Overrides:
cloneConfigurein classorg.eclipse.jetty.webapp.AbstractConfiguration- Throws:
java.lang.Exception
-
createServletContainerInitializerAnnotationHandlers
public void createServletContainerInitializerAnnotationHandlers(org.eclipse.jetty.webapp.WebAppContext context, java.util.List<jakarta.servlet.ServletContainerInitializer> scis) throws java.lang.Exception- Throws:
java.lang.Exception
-
getJarFor
public org.eclipse.jetty.util.resource.Resource getJarFor(jakarta.servlet.ServletContainerInitializer service) throws java.net.MalformedURLException, java.io.IOException- Throws:
java.net.MalformedURLExceptionjava.io.IOException
-
isFromExcludedJar
public boolean isFromExcludedJar(org.eclipse.jetty.webapp.WebAppContext context, jakarta.servlet.ServletContainerInitializer sci, org.eclipse.jetty.util.resource.Resource sciResource) throws java.lang.ExceptionCheck to see if the ServletContainerIntializer loaded via the ServiceLoader came from a jar that is excluded by the fragment ordering. See ServletSpec 3.0 p.85.- Parameters:
context- the context for the jarssci- the servlet container initializersciResource- the resource for the servlet container initializer- Returns:
- true if excluded
- Throws:
java.lang.Exception- if unable to determine exclusion
-
matchesExclusionPattern
public boolean matchesExclusionPattern(jakarta.servlet.ServletContainerInitializer sci)
Test if the ServletContainerIntializer is excluded by the o.e.j.containerInitializerExclusionPattern- Parameters:
sci- the ServletContainerIntializer- Returns:
- true if the ServletContainerIntializer is excluded
-
isFromContainerClassPath
public boolean isFromContainerClassPath(org.eclipse.jetty.webapp.WebAppContext context, jakarta.servlet.ServletContainerInitializer sci)Test if the ServletContainerInitializer is from the container classpath- Parameters:
context- the context for the webapp classpathsci- the ServletContainerIntializer- Returns:
- true if ServletContainerIntializer is from container classpath
-
isFromWebInfClasses
public boolean isFromWebInfClasses(org.eclipse.jetty.webapp.WebAppContext context, org.eclipse.jetty.util.resource.Resource sci)Test if the ServletContainerInitializer is from WEB-INF/classes- Parameters:
context- the webapp to testsci- a Resource representing the SCI- Returns:
- true if the sci Resource is inside a WEB-INF/classes directory, false otherwise
-
getNonExcludedInitializers
public java.util.List<jakarta.servlet.ServletContainerInitializer> getNonExcludedInitializers(org.eclipse.jetty.webapp.WebAppContext context) throws java.lang.ExceptionGet SCIs that are not excluded from consideration- Parameters:
context- the web app context- Returns:
- the list of non-excluded servlet container initializers
- Throws:
java.lang.Exception- if unable to get list
-
getInitializerOrdering
public AnnotationConfiguration.ServletContainerInitializerOrdering getInitializerOrdering(org.eclipse.jetty.webapp.WebAppContext context)
Jetty-specific extension that allows an ordering to be applied across ALL ServletContainerInitializers.- Parameters:
context- the context for the initializer ordering configuration- Returns:
- the ordering of the ServletContainerIntializer's
-
parseContainerPath
public void parseContainerPath(org.eclipse.jetty.webapp.WebAppContext context, AnnotationParser parser) throws java.lang.ExceptionScan jars on container path.- Parameters:
context- the context for the scanparser- the parser to scan with- Throws:
java.lang.Exception- if unable to scan
-
parseWebInfLib
public void parseWebInfLib(org.eclipse.jetty.webapp.WebAppContext context, AnnotationParser parser) throws java.lang.ExceptionScan jars in WEB-INF/lib. Only jars selected by MetaInfConfiguration, and that are not excluded by an ordering will be considered.- Parameters:
context- the context for the scanparser- the annotation parser to use- Throws:
java.lang.Exception- if unable to scan and/or parse
-
parseWebInfClasses
public void parseWebInfClasses(org.eclipse.jetty.webapp.WebAppContext context, AnnotationParser parser) throws java.lang.ExceptionScan classes in WEB-INF/classes.- Parameters:
context- the context for the scanparser- the annotation parser to use- Throws:
java.lang.Exception- if unable to scan and/or parse
-
-