Package org.kohsuke.stapler
Class WebApp
- java.lang.Object
-
- org.kohsuke.stapler.WebApp
-
public class WebApp extends Object
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:
get(ServletContext)
,getCurrent()
,Stapler.getWebApp()
-
-
Field Summary
Fields Modifier and Type Field Description List<BindInterceptor>
bindInterceptors
GlobalBindInterceptor
s.BoundObjectTable
boundObjectTable
Handles objects that are exported.javax.servlet.ServletContext
context
ServletContext
for this webapp.Map<String,String>
defaultEncodingForStaticResources
MIME type → encoding map that determines how static contents in the war file is served.List<Facet>
facets
Activated facets.Map<String,String>
mimeTypes
MIME type mapping from extensions (like "txt" or "jpg") to MIME types ("foo/bar").Map<Class,Class[]>
wrappers
Deprecated.Unused?
-
Constructor Summary
Constructors Constructor Description WebApp(javax.servlet.ServletContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
clearMetaClassCache()
Convenience maintenance method to clear all the cached information.void
clearScripts(Class<? extends AbstractTearOff> clazz)
Deprecated.Unused?static WebApp
get(javax.servlet.ServletContext context)
Obtains theWebApp
associated with the givenServletContext
.Object
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 '/'.ClassLoader
getClassLoader()
CrumbIssuer
getCrumbIssuer()
static WebApp
getCurrent()
Gets the currentWebApp
that the calling thread is associated with.DispatchersFilter
getDispatchersFilter()
DispatchValidator
getDispatchValidator()
<T extends Facet>
TgetFacet(Class<T> type)
If the facet of the given type exists, return it.FilteredDispatchTriggerListener
getFilteredDispatchTriggerListener()
FilteredDoActionTriggerListener
getFilteredDoActionTriggerListener()
FilteredFieldTriggerListener
getFilteredFieldTriggerListener()
FilteredGetterTriggerListener
getFilteredGetterTriggerListener()
FunctionList.Filter
getFilterForDoActions()
FieldRef.Filter
getFilterForFields()
FunctionList.Filter
getFilterForGetMethods()
JsonInErrorMessageSanitizer
getJsonInErrorMessageSanitizer()
Klass<?>
getKlass(Object o)
MetaClass
getMetaClass(Class c)
MetaClass
getMetaClass(Object o)
Obtains aMetaClass
that represents the type of the given object.MetaClass
getMetaClass(Klass<?> c)
CopyOnWriteArrayList<HttpResponseRenderer>
getResponseRenderers()
Stapler
getSomeStapler()
Gets a reference to someStapler
servlet in this webapp.void
setApp(Object app)
void
setClassLoader(ClassLoader classLoader)
Sets the classloader used byStaplerRequest.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 Detail
-
context
public final javax.servlet.ServletContext context
ServletContext
for this webapp.
-
wrappers
@Deprecated public final Map<Class,Class[]> wrappers
Deprecated.Unused?
-
defaultEncodingForStaticResources
public final Map<String,String> defaultEncodingForStaticResources
MIME type → encoding map that determines how static contents in the war file is served.
-
bindInterceptors
public final List<BindInterceptor> bindInterceptors
GlobalBindInterceptor
s. These are consulted afterStaplerRequest.getBindInterceptor()
is consulted. Global bind interceptors are useful to register webapp-wide conversion logic local to the application.- Since:
- 1.220
-
mimeTypes
public final Map<String,String> mimeTypes
MIME 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
public final BoundObjectTable boundObjectTable
Handles objects that are exported.
-
-
Method Detail
-
get
public static WebApp get(javax.servlet.ServletContext context)
Obtains theWebApp
associated with the givenServletContext
.
-
getApp
public Object 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
public void setApp(Object app)
-
getCrumbIssuer
public CrumbIssuer getCrumbIssuer()
-
setCrumbIssuer
public void setCrumbIssuer(CrumbIssuer crumbIssuer)
-
getResponseRenderers
public CopyOnWriteArrayList<HttpResponseRenderer> getResponseRenderers()
-
getClassLoader
public ClassLoader getClassLoader()
-
getFacet
public <T extends Facet> T getFacet(Class<T> type)
If the facet of the given type exists, return it. Otherwise null.
-
setClassLoader
public void setClassLoader(ClassLoader classLoader)
Sets the classloader used byStaplerRequest.bindJSON(Class, JSONObject)
and its sibling methods.
-
getMetaClass
public MetaClass getMetaClass(Object o)
Obtains aMetaClass
that represents the type of the given object.This code consults all facets to handle scripting language objects correctly.
-
clearScripts
@Deprecated public void clearScripts(Class<? extends AbstractTearOff> clazz)
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
public Stapler 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
public static WebApp getCurrent()
Gets the currentWebApp
that the calling thread is associated with.
-
getFilterForGetMethods
public FunctionList.Filter getFilterForGetMethods()
-
setFilterForGetMethods
public void setFilterForGetMethods(FunctionList.Filter filterForGetMethods)
Allow the underlying application to filter the getXxx methods
-
getFilterForDoActions
public FunctionList.Filter getFilterForDoActions()
-
setFilterForDoActions
public void setFilterForDoActions(FunctionList.Filter filterForDoActions)
Allow the underlying application to filter the doXxx actions
-
getFilterForFields
public FieldRef.Filter getFilterForFields()
-
setFilterForFields
public void setFilterForFields(FieldRef.Filter filterForFields)
-
getDispatchersFilter
public DispatchersFilter getDispatchersFilter()
-
setDispatchersFilter
public void setDispatchersFilter(DispatchersFilter dispatchersFilter)
-
getFilteredDoActionTriggerListener
public FilteredDoActionTriggerListener getFilteredDoActionTriggerListener()
-
setFilteredDoActionTriggerListener
public void setFilteredDoActionTriggerListener(FilteredDoActionTriggerListener filteredDoActionTriggerListener)
-
getFilteredGetterTriggerListener
public FilteredGetterTriggerListener getFilteredGetterTriggerListener()
-
setFilteredGetterTriggerListener
public void setFilteredGetterTriggerListener(FilteredGetterTriggerListener filteredGetterTriggerListener)
-
getFilteredFieldTriggerListener
public FilteredFieldTriggerListener getFilteredFieldTriggerListener()
-
setFilteredFieldTriggerListener
public void setFilteredFieldTriggerListener(FilteredFieldTriggerListener filteredFieldTriggerListener)
-
getJsonInErrorMessageSanitizer
public JsonInErrorMessageSanitizer getJsonInErrorMessageSanitizer()
-
setJsonInErrorMessageSanitizer
public void setJsonInErrorMessageSanitizer(JsonInErrorMessageSanitizer jsonInErrorMessageSanitizer)
Allow the application to customize the way the JSON are rendered in the stack trace in case of binding exception.
-
getDispatchValidator
public DispatchValidator getDispatchValidator()
-
setDispatchValidator
public void setDispatchValidator(DispatchValidator dispatchValidator)
Sets the validator used with facet dispatchers.
-
getFilteredDispatchTriggerListener
public FilteredDispatchTriggerListener getFilteredDispatchTriggerListener()
-
setFilteredDispatchTriggerListener
public void setFilteredDispatchTriggerListener(FilteredDispatchTriggerListener filteredDispatchTriggerListener)
Sets the event listener used for reacting to filtered dispatch requests.
-
-