Class 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.

Kohsuke Kawaguchi
See Also:
  • Field Details

    • context

      public final javax.servlet.ServletContext context
      ServletContext for this webapp.
    • wrappers

      @Deprecated public final Map<Class,Class[]> wrappers
    • defaultEncodingForStaticResources

      public final Map<String,String> defaultEncodingForStaticResources
      MIME type → encoding map that determines how static contents in the war file is served.
    • facets

      public final List<Facet> facets
      Activated facets. TODO: is this really mutable?
    • bindInterceptors

      public final List<BindInterceptor> bindInterceptors
      Global BindInterceptors. These are consulted after StaplerRequest.getBindInterceptor() is consulted. Global bind interceptors are useful to register webapp-wide conversion logic local to the application.
    • 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.
  • Constructor Details

    • WebApp

      public WebApp(javax.servlet.ServletContext context)
  • Method Details

    • get

      public static WebApp get(javax.servlet.ServletContext context)
      Obtains the WebApp associated with the given ServletContext.
    • 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 by StaplerRequest.bindJSON(Class, JSONObject) and its sibling methods.
    • getMetaClass

      public MetaClass getMetaClass(Class c)
    • getMetaClass

      public MetaClass getMetaClass(Klass<?> c)
    • getMetaClass

      public MetaClass getMetaClass(Object o)
      Obtains a MetaClass that represents the type of the given object.

      This code consults all facets to handle scripting language objects correctly.

    • getKlass

      public Klass<?> getKlass(Object o)
    • clearScripts

      @Deprecated public void clearScripts(Class<? extends AbstractTearOff> clazz)
    • 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 some Stapler 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 be Stapler. 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,

    • getCurrent

      public static WebApp getCurrent()
      Gets the current WebApp 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.