public class VaadinServletContext extends Object implements VaadinContext
VaadinContext
that goes with VaadinServletService
.Constructor and Description |
---|
VaadinServletContext(javax.servlet.ServletContext context)
Creates an instance of this context with given
ServletContext . |
Modifier and Type | Method and Description |
---|---|
<T> T |
getAttribute(Class<T> type,
Supplier<T> defaultValueSupplier)
Returns value of the specified attribute, creating and storing a default
value if attribute not present.
|
javax.servlet.ServletContext |
getContext()
Returns the underlying context.
|
String |
getContextParameter(String name)
Returns the value for the requested parameter, or
null if
the parameter does not exist. |
Enumeration<String> |
getContextParameterNames()
Returns the names of the initialization parameters as an
Enumeration , or an empty Enumeration if there
are o initialization parameters. |
void |
removeAttribute(Class<?> clazz)
Removes an attribute identified by the given type.
|
<T> void |
setAttribute(Class<T> clazz,
T value)
Sets the attribute value for the give type, overriding previously
existing one.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAttribute, setAttribute
public VaadinServletContext(javax.servlet.ServletContext context)
ServletContext
.context
- the servlet context to usepublic javax.servlet.ServletContext getContext()
ServletContext
.public <T> T getAttribute(Class<T> type, Supplier<T> defaultValueSupplier)
VaadinContext
If attribute is not yet available the defaultValueSupplier
is
used to get the default value which is set as the attribute value and the
value is returned. The operation is executed atomically.
getAttribute
in interface VaadinContext
type
- Type of the attribute.defaultValueSupplier
- Supplier
of the default value, called when there is no
value already present. May be null
.public <T> void setAttribute(Class<T> clazz, T value)
VaadinContext
setAttribute
in interface VaadinContext
clazz
- the type to associate the value with, not null
value
- the attribute value to set, or null
to remove the
current valuepublic void removeAttribute(Class<?> clazz)
VaadinContext
removeAttribute
in interface VaadinContext
clazz
- Attribute type.for setting attributes.
public Enumeration<String> getContextParameterNames()
VaadinContext
Enumeration
, or an empty Enumeration
if there
are o initialization parameters.getContextParameterNames
in interface VaadinContext
Enumeration
public String getContextParameter(String name)
VaadinContext
null
if
the parameter does not exist.getContextParameter
in interface VaadinContext
name
- name of the parameter whose value is requestedString
or null
for
no parameterCopyright © 2000–2024 Vaadin Ltd. All rights reserved.