Package org.kohsuke.stapler
Class AttributeKey<T>
java.lang.Object
org.kohsuke.stapler.AttributeKey<T>
Type-safe attribute accessor.
Servlet API has a bag of stuff in several scopes (such as request, session, ...) but the API is not type-safe. This object provides a convenient type-safe access to to such bags, as well as providing uniform API regardless of the actual scope.
Each instance of AttributeKey
gets an unique attribute name, which means
in the most typical case, these instances should be used as a singleton.
- Author:
- Kohsuke Kawaguchi
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> AttributeKey<T>
Creates a newServletContext
-scopedAttributeKey
.final T
get()
abstract T
get
(jakarta.servlet.http.HttpServletRequest req) final void
remove()
abstract void
remove
(jakarta.servlet.http.HttpServletRequest req) static <T> AttributeKey<T>
Creates a new request-scopedAttributeKey
.static <T> AttributeKey<T>
Creates a new session-scopedAttributeKey
.abstract void
final void
-
Field Details
-
name
-
-
Constructor Details
-
AttributeKey
public AttributeKey() -
AttributeKey
-
-
Method Details
-
get
-
set
-
remove
public abstract void remove(jakarta.servlet.http.HttpServletRequest req) -
get
-
set
-
remove
public final void remove() -
requestScoped
Creates a new request-scopedAttributeKey
. -
sessionScoped
Creates a new session-scopedAttributeKey
. -
appScoped
Creates a newServletContext
-scopedAttributeKey
.
-