Class DeferredDynamic
java.lang.Object
de.aristaflow.adept2.base.servletcontainer.demux.DeferredDynamic
- All Implemented Interfaces:
WrapSupportingDynamic,jakarta.servlet.Registration,jakarta.servlet.Registration.Dynamic,jakarta.servlet.ServletRegistration,jakarta.servlet.ServletRegistration.Dynamic
This class wraps a dynamically added
Servlet and allows to change initialisation
parameters and URL patterns for the servlet. Since servlet registration is deferred (i. e. after
the servlet context has already been initialised), this dynamic also initialises the servlet, i.
e. performs servlet lifecycle tasks. Usually these tasks are handled by the servlet context of
the servlet container.-
Nested Class Summary
Nested classes/interfaces inherited from interface jakarta.servlet.Registration
jakarta.servlet.Registration.DynamicNested classes/interfaces inherited from interface jakarta.servlet.ServletRegistration
jakarta.servlet.ServletRegistration.Dynamic -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DemuxServletThe demultiplexing servlet that is used for demultiplexing requests to the dynamically added servlets.protected booleanWhether the servlet has been initialised.The parameters for the initialisation of the servlet of thisDeferredDynamic.protected StringTherunAsrole of thisServletRegistration.protected final DynamicServletThe servlet thisDeferredDynamichandles and initialises.protected jakarta.servlet.ServletContextThe servlet context that creates thisDeferredDynamicfor initialising the servlet. -
Constructor Summary
ConstructorsConstructorDescriptionDeferredDynamic(DynamicServlet servlet, DemuxServlet demuxServlet, jakarta.servlet.ServletContext servletContext, Map<String, String> contextInitParams) Creates a newDeferredDynamicfor the designated servlet using the designated multiplexing servlet and having the designated (deferred) servlet context and init parameters. -
Method Summary
Modifier and TypeMethodDescriptionaddMapping(String... urlPatterns) protected voidChecks the state by throwing anIllegalArgumentExceptionif the servlet has already been initialised.getInitParameter(String name) getName()jakarta.servlet.ServletGets the servlet thisDynamicwraps.voidInitialises the servlet of thisDeferredDynamic.voidRemove all previously added URL mappings for this servlet.voidsetAsyncSupported(boolean isAsyncSupported) booleansetInitParameter(String name, String value) setInitParameters(Map<String, String> initParameters) voidsetLoadOnStartup(int loadOnStartup) voidsetMultipartConfig(jakarta.servlet.MultipartConfigElement multipartConfig) voidsetRunAsRole(String roleName) setServletSecurity(jakarta.servlet.ServletSecurityElement constraint) voidsetWrappingServletContext(jakarta.servlet.ServletContext wrapped, jakarta.servlet.ServletContext wrapper) Set the designated wrapping servlet context if thisDynamiccontains the designatedwrappedservlet context.
-
Field Details
-
servlet
The servlet thisDeferredDynamichandles and initialises. -
demuxServlet
The demultiplexing servlet that is used for demultiplexing requests to the dynamically added servlets. This handles the mapping. -
servletContext
protected jakarta.servlet.ServletContext servletContextThe servlet context that creates thisDeferredDynamicfor initialising the servlet. -
initParams
The parameters for the initialisation of the servlet of thisDeferredDynamic. These are copied from the servlet context when creating thisDeferredDynamic(i. e. when adding the servlet to the servlet context). Before initialising the servlet, additional init parameters can be added. -
role
TherunAsrole of thisServletRegistration. -
initialised
protected boolean initialisedWhether the servlet has been initialised. If so, all set methods cannot be called any more but lead to anIllegalStateException.
-
-
Constructor Details
-
DeferredDynamic
public DeferredDynamic(DynamicServlet servlet, DemuxServlet demuxServlet, jakarta.servlet.ServletContext servletContext, Map<String, String> contextInitParams) Creates a newDeferredDynamicfor the designated servlet using the designated multiplexing servlet and having the designated (deferred) servlet context and init parameters. The init parameters may be changed until the servlet is initialised.- Parameters:
servlet- The servlet which is added to the designated servlet context which is about to be initialised and which can be configured via the createdDeferredDynamic.demuxServlet- The demultiplexing servlet handling and forwarding incoming requests.servletContext- The context of the servlet.contextInitParams- The init parameters of the servlet context. These can be changed until the servlet is initialised.
-
-
Method Details
-
addMapping
- Specified by:
addMappingin interfacejakarta.servlet.ServletRegistration
-
removeMappings
public void removeMappings()Remove all previously added URL mappings for this servlet. -
getMappings
- Specified by:
getMappingsin interfacejakarta.servlet.ServletRegistration
-
getRunAsRole
- Specified by:
getRunAsRolein interfacejakarta.servlet.ServletRegistration
-
getName
- Specified by:
getNamein interfacejakarta.servlet.Registration
-
getClassName
- Specified by:
getClassNamein interfacejakarta.servlet.Registration
-
setInitParameter
- Specified by:
setInitParameterin interfacejakarta.servlet.Registration
-
getInitParameter
- Specified by:
getInitParameterin interfacejakarta.servlet.Registration
-
setInitParameters
- Specified by:
setInitParametersin interfacejakarta.servlet.Registration
-
getInitParameters
- Specified by:
getInitParametersin interfacejakarta.servlet.Registration
-
setAsyncSupported
public void setAsyncSupported(boolean isAsyncSupported) - Specified by:
setAsyncSupportedin interfacejakarta.servlet.Registration.Dynamic
-
setLoadOnStartup
public void setLoadOnStartup(int loadOnStartup) - Specified by:
setLoadOnStartupin interfacejakarta.servlet.ServletRegistration.Dynamic
-
setServletSecurity
- Specified by:
setServletSecurityin interfacejakarta.servlet.ServletRegistration.Dynamic
-
setMultipartConfig
public void setMultipartConfig(jakarta.servlet.MultipartConfigElement multipartConfig) - Specified by:
setMultipartConfigin interfacejakarta.servlet.ServletRegistration.Dynamic
-
setRunAsRole
- Specified by:
setRunAsRolein interfacejakarta.servlet.ServletRegistration.Dynamic
-
setWrappingServletContext
public void setWrappingServletContext(jakarta.servlet.ServletContext wrapped, jakarta.servlet.ServletContext wrapper) Description copied from interface:WrapSupportingDynamicSet the designated wrapping servlet context if thisDynamiccontains the designatedwrappedservlet context.- Specified by:
setWrappingServletContextin interfaceWrapSupportingDynamic- Parameters:
wrapped- The wrapped servlet context thisDynamicmay contain.wrapper- The wrapping servlet context to replace the servlet context within thisDynamic.
-
getServlet
public jakarta.servlet.Servlet getServlet()Gets the servlet thisDynamicwraps.- Returns:
- The servlet this
Dynamicwraps.
-
init
Initialises the servlet of thisDeferredDynamic. After this, the servlet is reachable and the set methods on thisDeferredDynamiccannot be called any more.- Parameters:
hierContext- The hierarchical context of the servlet with trailing "/".- Throws:
jakarta.servlet.ServletException- If initialisation of the servlet fails, aServletExceptionwill be thrown.
-
checkState
protected void checkState()Checks the state by throwing anIllegalArgumentExceptionif the servlet has already been initialised. This prevents calling methods that change data that is relevant for initialising the servlet, e. g. init parameters.
-