Package org.kohsuke.stapler
Class WebApp
java.lang.Object
org.kohsuke.stapler.WebApp
Object scoped to the entire webapp. Mostly used for configuring behavior of Stapler.
In contrast, Stapler
is a servlet, so there can be multiple instances per webapp.
- Author:
- Kohsuke Kawaguchi
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal List<BindInterceptor>
GlobalBindInterceptor
s.final BoundObjectTable
Handles objects that are exported.final javax.servlet.ServletContext
Deprecated.MIME type → encoding map that determines how static contents in the war file is served.Activated facets.Deprecated.removed without replacementDeprecated.Unused? -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Convenience maintenance method to clear all the cached information.void
clearScripts
(Class<? extends AbstractTearOff> clazz) Deprecated.Unused?static WebApp
get
(jakarta.servlet.ServletContext context) Obtains theWebApp
associated with the givenServletContext
.static WebApp
get
(javax.servlet.ServletContext context) Deprecated.getApp()
Returns the 'app' object, which is the user-specified object that sits at the root of the URL hierarchy and handles the request to '/'.static WebApp
Gets the currentWebApp
that the calling thread is associated with.<T extends Facet>
TIf the facet of the given type exists, return it.Klass<?>
Obtains aMetaClass
that represents the type of the given object.getMetaClass
(Klass<?> c) jakarta.servlet.ServletContext
Gets a reference to someStapler
servlet in this webapp.void
void
setClassLoader
(ClassLoader classLoader) Sets the classloader used byStaplerRequest2.bindJSON(Class, JSONObject)
and its sibling methods.void
setCrumbIssuer
(CrumbIssuer crumbIssuer) void
setDispatchersFilter
(DispatchersFilter dispatchersFilter) void
setDispatchValidator
(DispatchValidator dispatchValidator) Sets the validator used with facet dispatchers.void
setFilteredDispatchTriggerListener
(FilteredDispatchTriggerListener filteredDispatchTriggerListener) Sets the event listener used for reacting to filtered dispatch requests.void
setFilteredDoActionTriggerListener
(FilteredDoActionTriggerListener filteredDoActionTriggerListener) void
setFilteredFieldTriggerListener
(FilteredFieldTriggerListener filteredFieldTriggerListener) void
setFilteredGetterTriggerListener
(FilteredGetterTriggerListener filteredGetterTriggerListener) void
setFilterForDoActions
(FunctionList.Filter filterForDoActions) Allow the underlying application to filter the doXxx actionsvoid
setFilterForFields
(FieldRef.Filter filterForFields) void
setFilterForGetMethods
(FunctionList.Filter filterForGetMethods) Allow the underlying application to filter the getXxx methodsvoid
setJsonInErrorMessageSanitizer
(JsonInErrorMessageSanitizer jsonInErrorMessageSanitizer) Allow the application to customize the way the JSON are rendered in the stack trace in case of binding exception.
-
Field Details
-
context
Deprecated. -
wrappers
Deprecated.Unused? -
defaultEncodingForStaticResources
MIME type → encoding map that determines how static contents in the war file is served. -
facets
Activated facets. TODO: is this really mutable? -
bindInterceptors
GlobalBindInterceptor
s. These are consulted afterStaplerRequest2.getBindInterceptor()
is consulted. Global bind interceptors are useful to register webapp-wide conversion logic local to the application.- Since:
- 1.220
-
mimeTypes
Deprecated.removed without replacementMIME type mapping from extensions (like "txt" or "jpg") to MIME types ("foo/bar"). This overrides whatever mappings given in the servlet as far as stapler is concerned. This is case insensitive, and should be normalized to lower case. -
boundObjectTable
Handles objects that are exported.
-
-
Constructor Details
-
WebApp
public WebApp(jakarta.servlet.ServletContext context)
-
-
Method Details
-
get
Obtains theWebApp
associated with the givenServletContext
. -
get
Deprecated. -
getApp
Returns the 'app' object, which is the user-specified object that sits at the root of the URL hierarchy and handles the request to '/'. -
setApp
-
getServletContext
public jakarta.servlet.ServletContext getServletContext() -
getCrumbIssuer
-
setCrumbIssuer
-
getResponseRenderers
-
getClassLoader
-
getFacet
If the facet of the given type exists, return it. Otherwise null. -
setClassLoader
Sets the classloader used byStaplerRequest2.bindJSON(Class, JSONObject)
and its sibling methods. -
getMetaClass
-
getMetaClass
-
getMetaClass
Obtains aMetaClass
that represents the type of the given object.This code consults all facets to handle scripting language objects correctly.
-
getKlass
-
clearScripts
Deprecated.Unused? -
clearMetaClassCache
public void clearMetaClassCache()Convenience maintenance method to clear all the cached information. It will force the MetaClass to be rebuilt.Take care that the generation of MetaClass information takes a bit of time and so this call should not be called too often
-
getSomeStapler
Gets a reference to someStapler
servlet in this webapp.Most Stapler webapps will have one
<servlet>
entry in web.xml and if that's the case, that'd be returned. In a fully general case, a webapp can have multiple servlets and more than one of them can beStapler
. This method returns one of those. Which one gets returned is unspecified.This method is useful if you are in a
Filter
and using Stapler to handle the current request. For example,WebApp.get(servletContext).getSomeStapler().invoke( request,response, someJavaObject, "/path/to/dispatch/request");
-
getCurrent
Gets the currentWebApp
that the calling thread is associated with. -
getFilterForGetMethods
-
setFilterForGetMethods
Allow the underlying application to filter the getXxx methods -
getFilterForDoActions
-
setFilterForDoActions
Allow the underlying application to filter the doXxx actions -
getFilterForFields
-
setFilterForFields
-
getDispatchersFilter
-
setDispatchersFilter
-
getFilteredDoActionTriggerListener
-
setFilteredDoActionTriggerListener
public void setFilteredDoActionTriggerListener(FilteredDoActionTriggerListener filteredDoActionTriggerListener) -
getFilteredGetterTriggerListener
-
setFilteredGetterTriggerListener
public void setFilteredGetterTriggerListener(FilteredGetterTriggerListener filteredGetterTriggerListener) -
getFilteredFieldTriggerListener
-
setFilteredFieldTriggerListener
public void setFilteredFieldTriggerListener(FilteredFieldTriggerListener filteredFieldTriggerListener) -
getJsonInErrorMessageSanitizer
-
setJsonInErrorMessageSanitizer
Allow the application to customize the way the JSON are rendered in the stack trace in case of binding exception. -
getDispatchValidator
-
setDispatchValidator
Sets the validator used with facet dispatchers. -
getFilteredDispatchTriggerListener
-
setFilteredDispatchTriggerListener
public void setFilteredDispatchTriggerListener(FilteredDispatchTriggerListener filteredDispatchTriggerListener) Sets the event listener used for reacting to filtered dispatch requests.
-
getServletContext()