Package org.eclipse.jetty.ee10.servlet
Class ServletContextHandler
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.Handler.Abstract
org.eclipse.jetty.server.Handler.AbstractContainer
org.eclipse.jetty.server.Handler.Wrapper
org.eclipse.jetty.server.handler.ContextHandler
org.eclipse.jetty.ee10.servlet.ServletContextHandler
- All Implemented Interfaces:
org.eclipse.jetty.server.AliasCheck,org.eclipse.jetty.server.Handler,org.eclipse.jetty.server.Handler.Container,org.eclipse.jetty.server.Handler.Singleton,org.eclipse.jetty.server.Request.Handler,org.eclipse.jetty.util.Attributes,org.eclipse.jetty.util.component.Container,org.eclipse.jetty.util.component.Destroyable,org.eclipse.jetty.util.component.Dumpable,org.eclipse.jetty.util.component.Dumpable.DumpableContainer,org.eclipse.jetty.util.component.LifeCycle,org.eclipse.jetty.util.thread.Invocable
@ManagedObject("Servlet Context Handler")
public class ServletContextHandler
extends org.eclipse.jetty.server.handler.ContextHandler
Servlet Context.
This extension to the ContextHandler allows for simple construction of a context with ServletHandler and optionally session and security handlers, et.
new ServletContext("/context",Context.SESSIONS|Context.NO_SECURITY);
This class should have been called ServletContext, but this would have
cause confusion with ServletContext.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic classstatic classstatic interfacestatic classBean that is added to the ServletContextHandler to start all of the ServletContainerInitializers by starting their corresponding ServletContainerInitializerHolders when this bean is itself started.classstatic interfaceListener for all threads entering context scope, including async IO callbacksstatic interfaceThe interface used byServletApiRequestto access theServletContextRequestwithout access to the unwrappedRequestmethods.static interfaceThe interface used byServletApiResponseto access theServletContextResponsewithout access to the unwrappedResponsemethods.classstatic classNested classes/interfaces inherited from class org.eclipse.jetty.server.handler.ContextHandler
org.eclipse.jetty.server.handler.ContextHandler.Availability, org.eclipse.jetty.server.handler.ContextHandler.ContextScopeListener, org.eclipse.jetty.server.handler.ContextHandler.ScopedContextNested classes/interfaces inherited from class org.eclipse.jetty.server.Handler.Abstract
org.eclipse.jetty.server.Handler.Abstract.NonBlockingNested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener, org.eclipse.jetty.util.component.AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface org.eclipse.jetty.util.Attributes
org.eclipse.jetty.util.Attributes.Layer, org.eclipse.jetty.util.Attributes.Lazy, org.eclipse.jetty.util.Attributes.Mapped, org.eclipse.jetty.util.Attributes.Synthetic, org.eclipse.jetty.util.Attributes.WrapperNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
org.eclipse.jetty.util.component.Container.InheritedListener, org.eclipse.jetty.util.component.Container.ListenerNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
org.eclipse.jetty.util.component.Dumpable.DumpableContainerNested classes/interfaces inherited from interface org.eclipse.jetty.server.Handler
org.eclipse.jetty.server.Handler.Abstract, org.eclipse.jetty.server.Handler.AbstractContainer, org.eclipse.jetty.server.Handler.Collection, org.eclipse.jetty.server.Handler.Container, org.eclipse.jetty.server.Handler.Sequence, org.eclipse.jetty.server.Handler.Singleton, org.eclipse.jetty.server.Handler.WrapperNested classes/interfaces inherited from interface org.eclipse.jetty.util.thread.Invocable
org.eclipse.jetty.util.thread.Invocable.Callable, org.eclipse.jetty.util.thread.Invocable.InvocationType, org.eclipse.jetty.util.thread.Invocable.ReadyTask, org.eclipse.jetty.util.thread.Invocable.TaskNested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
org.eclipse.jetty.util.component.LifeCycle.Listener -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final org.eclipse.jetty.util.component.EnvironmentDeprecated, for removal: This API element is subject to removal in a future version.protected ServletContextHandler.ContextStatusprotected jakarta.servlet.descriptor.JspConfigDescriptorprotected final org.eclipse.jetty.util.DecoratedObjectFactoryprotected intprotected org.eclipse.jetty.security.SecurityHandlerprotected ServletHandlerprotected SessionHandlerstatic final intstatic final intstatic final intstatic final org.eclipse.jetty.util.component.Environmentstatic final intstatic final Stringstatic final Stringstatic final intstatic final intstatic final intstatic final Class<?>[]static final intFields inherited from class org.eclipse.jetty.server.handler.ContextHandler
CROSS_CONTEXT_ATTRIBUTE, MANAGED_ATTRIBUTESFields inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
FAILED, STARTED, STARTING, STOPPED, STOPPINGFields inherited from interface org.eclipse.jetty.util.Attributes
NULLFields inherited from interface org.eclipse.jetty.util.component.Dumpable
KEYFields inherited from interface org.eclipse.jetty.util.thread.Invocable
__nonBlocking, NOOP -
Constructor Summary
ConstructorsConstructorDescriptionServletContextHandler(int options) ServletContextHandler(String contextPath) ServletContextHandler(String contextPath, boolean sessions, boolean security) ServletContextHandler(String contextPath, int options) ServletContextHandler(String contextPath, SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler) ServletContextHandler(String contextPath, SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler, int options) ServletContextHandler(SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler) -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddEventListener(EventListener listener) Add a context event listeners.addFilter(jakarta.servlet.Filter filter, String pathSpec, EnumSet<jakarta.servlet.DispatcherType> dispatches) Convenience method to add a servlet.addFilter(Class<? extends jakarta.servlet.Filter> filterClass, String pathSpec, EnumSet<jakarta.servlet.DispatcherType> dispatches) Convenience method to add a filterConvenience method to add a filtervoidaddFilter(FilterHolder holder, String pathSpec, EnumSet<jakarta.servlet.DispatcherType> dispatches) Convenience method to add a filtervoidaddLocaleEncoding(String locale, String encoding) protected voidaddProgrammaticListener(EventListener listener) Apply any necessary restrictions on a programmatic added listener.protected voiddelegate for ServletContext.declareRole methodaddServlet(jakarta.servlet.http.HttpServlet servlet, String pathSpec) Convenience method to add a servlet.addServlet(Class<? extends jakarta.servlet.Servlet> servlet, String pathSpec) Convenience method to add a servlet.addServlet(String className, String pathSpec) Convenience method to add a servlet.voidaddServlet(ServletHolder servlet, String pathSpec) Convenience method to add a servlet.addServletContainerInitializer(jakarta.servlet.ServletContainerInitializer sci) Convenience method to programmatically add aServletContainerInitializer.addServletContainerInitializer(jakarta.servlet.ServletContainerInitializer sci, Class<?>... classes) Convenience method to programmatically add aServletContainerInitializer.voidaddServletContainerInitializer(ServletContainerInitializerHolder... sciHolders) Convenience method to programmatically add a list ofServletContainerInitializer.voidcallContextDestroyed(jakarta.servlet.ServletContextListener l, jakarta.servlet.ServletContextEvent e) voidcallContextInitialized(jakarta.servlet.ServletContextListener l, jakarta.servlet.ServletContextEvent e) voidCall the ServletContextListeners with contextDestroyed.voidCall the ServletContextListeners contextInitialized methods.protected voiddoStart()protected voiddoStop()voiddump(Appendable out, String indent) protected jakarta.servlet.ServletRegistration.DynamicdynamicHolderAdded(ServletHolder holder) notification that a ServletRegistration has been created so we can track the annotationsstatic jakarta.servlet.ServletContextstatic ServletContextHandlerClass<? extends org.eclipse.jetty.security.SecurityHandler> Get the defaultSecurityHandlerClass.getInitParameter(String name) org.eclipse.jetty.util.thread.Invocable.InvocationTypegetLocaleEncoding(String locale) getLocaleEncoding(Locale locale) Get the character encoding for a locale.Get all of the locale encodingsorg.slf4j.Loggerintintorg.eclipse.jetty.util.DecoratedObjectFactoryThe DecoratedObjectFactory for use by IoC containers (weld / spring / etc)Get the context path in a form suitable to be returned fromHttpServletRequest.getContextPath()orServletContext.getContextPath().org.eclipse.jetty.util.resource.ResourcegetResource(String pathInContext) Attempt to get a Resource from the Context.getResourcePaths(String path) org.eclipse.jetty.security.SecurityHandlerjakarta.servlet.ServletContextstatic jakarta.servlet.ServletContextgetServletContext(org.eclipse.jetty.server.Context context) static ServletContextHandlergetServletContextHandler(jakarta.servlet.ServletContext servletContext) static ServletContextHandlergetServletContextHandler(jakarta.servlet.ServletContext servletContext, String purpose) String[]protected booleanhandleByContextHandler(String pathInContext, org.eclipse.jetty.server.handler.ContextRequest request, org.eclipse.jetty.server.Response response, org.eclipse.jetty.util.Callback callback) voidinsertHandler(org.eclipse.jetty.server.Handler.Singleton handler) Insert a HandlerWrapper before the first Session, Security or ServletHandler but after any other HandlerWrappers.booleanisDurableListener(EventListener listener) booleanisProgrammaticListener(EventListener listener) booleanClass<?> protected org.eclipse.jetty.server.handler.ContextHandler.ScopedContextorg.eclipse.jetty.util.resource.ResourcenewResource(String urlOrPath) Convert a URL or path to a Resource.org.eclipse.jetty.util.resource.ResourcenewResource(URI uri) Convert URL to Resource wrapper forResourceFactory.newResource(URL)enables extensions to provide alternate resource implementations.org.eclipse.jetty.util.resource.ResourcenewResource(URL url) Convert URL to Resource wrapper forResourceFactory.newResource(URL)enables extensions to provide alternate resource implementations.protected org.eclipse.jetty.security.SecurityHandlerprotected ServletContextRequestnewServletContextRequest(ServletChannel servletChannel, org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, String decodedPathInContext, org.eclipse.jetty.http.pathmap.MatchedResource<ServletHandler.MappedServlet> matchedResource) protected ServletHandlerprotected SessionHandlerprotected voidnotifyEnterScope(org.eclipse.jetty.server.Request request) protected voidnotifyExitScope(org.eclipse.jetty.server.Request request) booleanremoveEventListener(EventListener listener) protected voidrequestDestroyed(org.eclipse.jetty.server.Request baseRequest, jakarta.servlet.http.HttpServletRequest request) protected voidrequestInitialized(org.eclipse.jetty.server.Request baseRequest, jakarta.servlet.http.HttpServletRequest request) voidsetContextPath(String contextPath) voidsetDefaultRequestCharacterEncoding(String encoding) voidsetDefaultResponseCharacterEncoding(String encoding) voidsetDefaultSecurityHandlerClass(Class<? extends org.eclipse.jetty.security.SecurityHandler> defaultSecurityHandlerClass) Set the defaultSecurityHandlerClass.voidsetHandler(org.eclipse.jetty.server.Handler handler) setInitParameter(String name, String value) voidsetLogger(org.slf4j.Logger logger) voidsetMaxFormContentSize(int maxSize) Set the maximum size of a form post, to protect against DOS attacks from large forms.voidsetMaxFormKeys(int max) Set the maximum number of form Keys to protect against DOS attack from crafted hash keys.voidsetSecurityHandler(org.eclipse.jetty.security.SecurityHandler securityHandler) voidsetServletHandler(ServletHandler servletHandler) setServletSecurity(jakarta.servlet.ServletRegistration.Dynamic registration, jakarta.servlet.ServletSecurityElement servletSecurityElement) Delegate for ServletRegistration.Dynamic.setServletSecurity methodvoidsetSessionHandler(SessionHandler sessionHandler) voidsetTempDirectory(File tempDirectory) voidsetUsingSecurityManager(boolean usingSecurityManager) voidsetWelcomeFiles(String[] files) protected voidFinish constructing handlers and link them together.protected voidprotected org.eclipse.jetty.server.handler.ContextRequestwrapRequest(org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response) protected org.eclipse.jetty.server.handler.ContextResponsewrapResponse(org.eclipse.jetty.server.handler.ContextRequest request, org.eclipse.jetty.server.Response response) Methods inherited from class org.eclipse.jetty.server.handler.ContextHandler
addAliasCheck, addVirtualHosts, checkAlias, checkVirtualHost, cleanupAfterStop, clearAliasChecks, clearAttributes, createTempDirectory, destroy, enterScope, exitScope, getAliasChecks, getAllowNullPathInContext, getAttribute, getAttributeNameSet, getBaseName, getBaseResource, getCanonicalNameForTmpDir, getClassLoader, getClassPath, getContextHandler, getContextPath, getCrossContextHandler, getCurrentContext, getCurrentContext, getCurrentContextHandler, getDisplayName, getErrorHandler, getMimeTypes, getProtectedTargets, getResourceForTempDirName, getTempDirectory, getVirtualHosts, handle, handleMovedPermanently, handleUnavailable, isAvailable, isCrossContextDispatchSupported, isProtectedTarget, isTempDirectoryPersistent, makeTempDirectory, removeAttribute, removeVirtualHosts, setAliasChecks, setAllowNullPathInContext, setAttribute, setAvailable, setBaseResource, setBaseResourceAsPath, setBaseResourceAsString, setClassLoader, setCrossContextDispatchSupported, setDisplayName, setErrorHandler, setProtectedTargets, setServer, setTempDirectoryPersistent, setVirtualHosts, toStringMethods inherited from class org.eclipse.jetty.server.Handler.Wrapper
getHandlerMethods inherited from class org.eclipse.jetty.server.Handler.AbstractContainer
findContainerOf, getDescendant, getDescendants, isDynamic, setDynamicMethods inherited from class org.eclipse.jetty.server.Handler.Abstract
getServerMethods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addManaged, contains, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.jetty.util.Attributes
asAttributeMap, equals, hashCodeMethods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListenersMethods inherited from interface org.eclipse.jetty.util.component.Dumpable
dumpSelfMethods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpableMethods inherited from interface org.eclipse.jetty.server.Handler
getServerMethods inherited from interface org.eclipse.jetty.server.Handler.Container
getContainer, getDescendant, getDescendants, getDescendantsMethods inherited from interface org.eclipse.jetty.server.Handler.Singleton
getHandlers, getTail, setHandlerMethods inherited from interface org.eclipse.jetty.util.component.LifeCycle
isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, start, stop
-
Field Details
-
ENVIRONMENT
public static final org.eclipse.jetty.util.component.Environment ENVIRONMENT -
__environment
@Deprecated(since="12.0.9", forRemoval=true) public static final org.eclipse.jetty.util.component.Environment __environmentDeprecated, for removal: This API element is subject to removal in a future version.UseENVIRONMENTinstead. -
SERVLET_LISTENER_TYPES
-
DEFAULT_LISTENER_TYPE_INDEX
public static final int DEFAULT_LISTENER_TYPE_INDEX- See Also:
-
EXTENDED_LISTENER_TYPE_INDEX
public static final int EXTENDED_LISTENER_TYPE_INDEX- See Also:
-
MAX_FORM_KEYS_KEY
- See Also:
-
MAX_FORM_CONTENT_SIZE_KEY
- See Also:
-
DEFAULT_MAX_FORM_KEYS
public static final int DEFAULT_MAX_FORM_KEYS- See Also:
-
DEFAULT_MAX_FORM_CONTENT_SIZE
public static final int DEFAULT_MAX_FORM_CONTENT_SIZE- See Also:
-
SESSIONS
public static final int SESSIONS- See Also:
-
SECURITY
public static final int SECURITY- See Also:
-
NO_SESSIONS
public static final int NO_SESSIONS- See Also:
-
NO_SECURITY
public static final int NO_SECURITY- See Also:
-
_contextStatus
-
_objFactory
protected final org.eclipse.jetty.util.DecoratedObjectFactory _objFactory -
_sessionHandler
-
_securityHandler
protected org.eclipse.jetty.security.SecurityHandler _securityHandler -
_servletHandler
-
_options
protected int _options -
_jspConfig
protected jakarta.servlet.descriptor.JspConfigDescriptor _jspConfig
-
-
Constructor Details
-
ServletContextHandler
public ServletContextHandler() -
ServletContextHandler
-
ServletContextHandler
public ServletContextHandler(int options) -
ServletContextHandler
-
ServletContextHandler
-
ServletContextHandler
public ServletContextHandler(SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler) -
ServletContextHandler
public ServletContextHandler(String contextPath, SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler) -
ServletContextHandler
public ServletContextHandler(String contextPath, SessionHandler sessionHandler, org.eclipse.jetty.security.SecurityHandler securityHandler, ServletHandler servletHandler, ErrorHandler errorHandler, int options)
-
-
Method Details
-
getServletContextHandler
public static ServletContextHandler getServletContextHandler(jakarta.servlet.ServletContext servletContext, String purpose) -
getServletContextHandler
public static ServletContextHandler getServletContextHandler(jakarta.servlet.ServletContext servletContext) -
getCurrentServletContext
public static jakarta.servlet.ServletContext getCurrentServletContext() -
getServletContext
public static jakarta.servlet.ServletContext getServletContext(org.eclipse.jetty.server.Context context) -
getCurrentServletContextHandler
-
setTempDirectory
- Overrides:
setTempDirectoryin classorg.eclipse.jetty.server.handler.ContextHandler
-
newServletContextApi
-
getInvocationType
public org.eclipse.jetty.util.thread.Invocable.InvocationType getInvocationType()- Specified by:
getInvocationTypein interfaceorg.eclipse.jetty.util.thread.Invocable- Specified by:
getInvocationTypein interfaceorg.eclipse.jetty.server.Request.Handler- Overrides:
getInvocationTypein classorg.eclipse.jetty.server.Handler.Wrapper
-
dump
- Specified by:
dumpin interfaceorg.eclipse.jetty.util.component.Dumpable- Overrides:
dumpin classorg.eclipse.jetty.server.handler.ContextHandler- Throws:
IOException
-
isUsingSecurityManager
public boolean isUsingSecurityManager() -
setUsingSecurityManager
public void setUsingSecurityManager(boolean usingSecurityManager) -
getContextPathEncoded
- Returns:
- Returns the encoded contextPath.
-
getRequestContextPath
Get the context path in a form suitable to be returned fromHttpServletRequest.getContextPath()orServletContext.getContextPath().- Returns:
- Returns the encoded contextPath, or empty string for root context
-
getInitParameter
-
setInitParameter
-
getInitParameterNames
-
getInitParams
-
removeEventListener
- Specified by:
removeEventListenerin interfaceorg.eclipse.jetty.util.component.Container- Specified by:
removeEventListenerin interfaceorg.eclipse.jetty.util.component.LifeCycle- Overrides:
removeEventListenerin classorg.eclipse.jetty.server.handler.ContextHandler
-
addProgrammaticListener
Apply any necessary restrictions on a programmatic added listener.- Parameters:
listener- the programmatic listener to add
-
isProgrammaticListener
-
isDurableListener
-
getLogger
public org.slf4j.Logger getLogger() -
setLogger
public void setLogger(org.slf4j.Logger logger) -
contextInitialized
Call the ServletContextListeners contextInitialized methods. This can be called from a ServletHandler during the proper sequence of initializing filters, servlets and listeners. However, if there is no ServletHandler, the ContextHandler will call this method during doStart().- Throws:
Exception
-
contextDestroyed
Call the ServletContextListeners with contextDestroyed. This method can be called from a ServletHandler in the proper sequence of destroying filters, servlets and listeners. If there is no ServletHandler, the ContextHandler must ensure these listeners are called instead.- Throws:
Exception
-
requestInitialized
protected void requestInitialized(org.eclipse.jetty.server.Request baseRequest, jakarta.servlet.http.HttpServletRequest request) -
requestDestroyed
protected void requestDestroyed(org.eclipse.jetty.server.Request baseRequest, jakarta.servlet.http.HttpServletRequest request) -
setDefaultRequestCharacterEncoding
-
getDefaultRequestCharacterEncoding
-
setDefaultResponseCharacterEncoding
-
getDefaultResponseCharacterEncoding
-
setContextPath
- Overrides:
setContextPathin classorg.eclipse.jetty.server.handler.ContextHandler- Parameters:
contextPath- The _contextPath to set.
-
setWelcomeFiles
-
getWelcomeFiles
@ManagedAttribute(value="Partial URIs of directory welcome files", readonly=true) public String[] getWelcomeFiles()- Returns:
- The names of the files which the server should consider to be welcome files in this context.
- See Also:
-
getMaxFormContentSize
@ManagedAttribute("The maximum content size") public int getMaxFormContentSize() -
setMaxFormContentSize
public void setMaxFormContentSize(int maxSize) Set the maximum size of a form post, to protect against DOS attacks from large forms.- Parameters:
maxSize- the maximum size of the form content (in bytes)
-
getMaxFormKeys
public int getMaxFormKeys() -
setMaxFormKeys
public void setMaxFormKeys(int max) Set the maximum number of form Keys to protect against DOS attack from crafted hash keys.- Parameters:
max- the maximum number of form keys
-
loadClass
- Throws:
ClassNotFoundException
-
addLocaleEncoding
-
getLocaleEncoding
-
getLocaleEncoding
Get the character encoding for a locale. The full locale name is first looked up in the map of encodings. If no encoding is found, then the locale language is looked up.- Parameters:
locale- aLocalevalue- Returns:
- a
Stringrepresenting the character encoding for the locale or null if none found.
-
getLocaleEncodings
-
getResource
public org.eclipse.jetty.util.resource.Resource getResource(String pathInContext) throws MalformedURLException Attempt to get a Resource from the Context.- Parameters:
pathInContext- the path within the base resource to attempt to get- Returns:
- the resource, or null if not available.
- Throws:
MalformedURLException- if unable to form a Resource from the provided path
-
newResource
Convert URL to Resource wrapper forResourceFactory.newResource(URL)enables extensions to provide alternate resource implementations.- Parameters:
url- the url to convert to a Resource- Returns:
- the Resource for that url
- Throws:
IOException- if unable to create a Resource from the URL
-
newResource
Convert URL to Resource wrapper forResourceFactory.newResource(URL)enables extensions to provide alternate resource implementations.- Parameters:
uri- the URI to convert to a Resource- Returns:
- the Resource for that URI
-
newResource
Convert a URL or path to a Resource. The default implementation is a wrapper forResourceFactory.newResource(String).- Parameters:
urlOrPath- The URL or path to convert- Returns:
- The Resource for the URL/path
-
getResourcePaths
-
getServletContext
public jakarta.servlet.ServletContext getServletContext() -
newContext
protected org.eclipse.jetty.server.handler.ContextHandler.ScopedContext newContext()- Overrides:
newContextin classorg.eclipse.jetty.server.handler.ContextHandler
-
getContext
- Overrides:
getContextin classorg.eclipse.jetty.server.handler.ContextHandler
-
addEventListener
Add a context event listeners.- Specified by:
addEventListenerin interfaceorg.eclipse.jetty.util.component.Container- Specified by:
addEventListenerin interfaceorg.eclipse.jetty.util.component.LifeCycle- Overrides:
addEventListenerin classorg.eclipse.jetty.server.handler.ContextHandler- Parameters:
listener- the event listener to add- Returns:
- true if the listener was added
- See Also:
-
setHandler
public void setHandler(org.eclipse.jetty.server.Handler handler) - Specified by:
setHandlerin interfaceorg.eclipse.jetty.server.Handler.Singleton- Overrides:
setHandlerin classorg.eclipse.jetty.server.Handler.Wrapper
-
doStart
-
doStop
-
newServletContextRequest
protected ServletContextRequest newServletContextRequest(ServletChannel servletChannel, org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response, String decodedPathInContext, org.eclipse.jetty.http.pathmap.MatchedResource<ServletHandler.MappedServlet> matchedResource) -
wrapRequest
protected org.eclipse.jetty.server.handler.ContextRequest wrapRequest(org.eclipse.jetty.server.Request request, org.eclipse.jetty.server.Response response) - Overrides:
wrapRequestin classorg.eclipse.jetty.server.handler.ContextHandler
-
wrapResponse
protected org.eclipse.jetty.server.handler.ContextResponse wrapResponse(org.eclipse.jetty.server.handler.ContextRequest request, org.eclipse.jetty.server.Response response) - Overrides:
wrapResponsein classorg.eclipse.jetty.server.handler.ContextHandler
-
handleByContextHandler
protected boolean handleByContextHandler(String pathInContext, org.eclipse.jetty.server.handler.ContextRequest request, org.eclipse.jetty.server.Response response, org.eclipse.jetty.util.Callback callback) - Overrides:
handleByContextHandlerin classorg.eclipse.jetty.server.handler.ContextHandler
-
notifyEnterScope
protected void notifyEnterScope(org.eclipse.jetty.server.Request request) - Overrides:
notifyEnterScopein classorg.eclipse.jetty.server.handler.ContextHandler
-
notifyExitScope
protected void notifyExitScope(org.eclipse.jetty.server.Request request) - Overrides:
notifyExitScopein classorg.eclipse.jetty.server.handler.ContextHandler
-
getDefaultSecurityHandlerClass
Get the defaultSecurityHandlerClass.- Returns:
- the defaultSecurityHandlerClass
-
setDefaultSecurityHandlerClass
public void setDefaultSecurityHandlerClass(Class<? extends org.eclipse.jetty.security.SecurityHandler> defaultSecurityHandlerClass) Set the defaultSecurityHandlerClass.- Parameters:
defaultSecurityHandlerClass- the defaultSecurityHandlerClass to set
-
newSessionHandler
-
newSecurityHandler
protected org.eclipse.jetty.security.SecurityHandler newSecurityHandler() -
newServletHandler
-
startContext
-
stopContext
-
getSecurityHandler
@ManagedAttribute(value="context security handler", readonly=true) public org.eclipse.jetty.security.SecurityHandler getSecurityHandler()- Returns:
- Returns the securityHandler.
-
getServletHandler
@ManagedAttribute(value="context servlet handler", readonly=true) public ServletHandler getServletHandler()- Returns:
- Returns the servletHandler.
-
getSessionHandler
@ManagedAttribute(value="context session handler", readonly=true) public SessionHandler getSessionHandler()- Returns:
- Returns the sessionHandler.
-
addServlet
Convenience method to add a servlet.- Parameters:
className- the servlet class namepathSpec- the path spec to map servlet to- Returns:
- the ServletHolder for the added servlet
-
addServlet
Convenience method to add a servlet.- Parameters:
servlet- the servlet classpathSpec- the path spec to map servlet to- Returns:
- the ServletHolder for the added servlet
-
addServlet
Convenience method to add a servlet.- Parameters:
servlet- the servlet holderpathSpec- the path spec
-
addServlet
Convenience method to add a servlet.- Parameters:
servlet- the servlet instancepathSpec- the path spec- Returns:
- the ServletHolder for the added servlet
-
addFilter
public void addFilter(FilterHolder holder, String pathSpec, EnumSet<jakarta.servlet.DispatcherType> dispatches) Convenience method to add a filter- Parameters:
holder- the filter holderpathSpec- the path specdispatches- the dispatcher types for this filter
-
addFilter
public FilterHolder addFilter(Class<? extends jakarta.servlet.Filter> filterClass, String pathSpec, EnumSet<jakarta.servlet.DispatcherType> dispatches) Convenience method to add a filter- Parameters:
filterClass- the filter classpathSpec- the path specdispatches- the dispatcher types for this filter- Returns:
- the FilterHolder that was created
-
addFilter
public FilterHolder addFilter(String filterClass, String pathSpec, EnumSet<jakarta.servlet.DispatcherType> dispatches) Convenience method to add a filter- Parameters:
filterClass- the filter class namepathSpec- the path specdispatches- the dispatcher types for this filter- Returns:
- the FilterHolder that was created
-
addFilter
public FilterHolder addFilter(jakarta.servlet.Filter filter, String pathSpec, EnumSet<jakarta.servlet.DispatcherType> dispatches) Convenience method to add a servlet.- Parameters:
filter- the filter instancepathSpec- the path specdispatches- the dispatcher types for this filter- Returns:
- the FilterHolder that was created
-
addServletContainerInitializer
public ServletContainerInitializerHolder addServletContainerInitializer(jakarta.servlet.ServletContainerInitializer sci) Convenience method to programmatically add aServletContainerInitializer.- Parameters:
sci- the ServletContainerInitializer to register.- Returns:
- the ServletContainerInitializerHolder that was created
-
addServletContainerInitializer
public ServletContainerInitializerHolder addServletContainerInitializer(jakarta.servlet.ServletContainerInitializer sci, Class<?>... classes) Convenience method to programmatically add aServletContainerInitializer.- Parameters:
sci- the ServletContainerInitializer to register.classes- the Set of application classes.- Returns:
- the ServletContainerInitializerHolder that was created
-
addServletContainerInitializer
Convenience method to programmatically add a list ofServletContainerInitializer. The initializers are guaranteed to be called in the order they are passed into this method.- Parameters:
sciHolders- the ServletContainerInitializerHolders
-
dynamicHolderAdded
notification that a ServletRegistration has been created so we can track the annotations- Parameters:
holder- new holder created through the api.- Returns:
- the ServletRegistration.Dynamic
-
addRoles
delegate for ServletContext.declareRole method- Parameters:
roleNames- role names to add
-
setServletSecurity
public Set<String> setServletSecurity(jakarta.servlet.ServletRegistration.Dynamic registration, jakarta.servlet.ServletSecurityElement servletSecurityElement) Delegate for ServletRegistration.Dynamic.setServletSecurity method- Parameters:
registration- ServletRegistration.Dynamic instance that setServletSecurity was called onservletSecurityElement- new security info- Returns:
- the set of exact URL mappings currently associated with the registration that are also present in the web.xml security constraints and thus will be unaffected by this call.
-
callContextInitialized
public void callContextInitialized(jakarta.servlet.ServletContextListener l, jakarta.servlet.ServletContextEvent e) -
callContextDestroyed
public void callContextDestroyed(jakarta.servlet.ServletContextListener l, jakarta.servlet.ServletContextEvent e) -
setSessionHandler
- Parameters:
sessionHandler- The sessionHandler to set.
-
setSecurityHandler
public void setSecurityHandler(org.eclipse.jetty.security.SecurityHandler securityHandler) - Parameters:
securityHandler- TheSecurityHandlerto set on this context.
-
setServletHandler
- Parameters:
servletHandler- The servletHandler to set.
-
insertHandler
public void insertHandler(org.eclipse.jetty.server.Handler.Singleton handler) Insert a HandlerWrapper before the first Session, Security or ServletHandler but after any other HandlerWrappers. -
getObjectFactory
public org.eclipse.jetty.util.DecoratedObjectFactory getObjectFactory()The DecoratedObjectFactory for use by IoC containers (weld / spring / etc)- Returns:
- The DecoratedObjectFactory
-
ENVIRONMENTinstead.