Package com.vaadin.flow.server
Class VaadinServletContext
java.lang.Object
com.vaadin.flow.server.VaadinServletContext
- All Implemented Interfaces:
VaadinContext
,Serializable
VaadinContext
that goes with VaadinServletService
.- Since:
- 2.0.0
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionVaadinServletContext
(jakarta.servlet.ServletContext context) Creates an instance of this context with givenServletContext
. -
Method Summary
Modifier and TypeMethodDescription<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.jakarta.servlet.ServletContext
Returns the underlying context.getContextParameter
(String name) Returns the value for the requested parameter, ornull
if the parameter does not exist.Returns the names of the initialization parameters as anEnumeration
, or an emptyEnumeration
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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.server.VaadinContext
getAttribute, setAttribute
-
Constructor Details
-
VaadinServletContext
public VaadinServletContext(jakarta.servlet.ServletContext context) Creates an instance of this context with givenServletContext
.- Parameters:
context
- the servlet context to use
-
-
Method Details
-
getContext
public jakarta.servlet.ServletContext getContext()Returns the underlying context.- Returns:
- A non-null
ServletContext
.
-
getAttribute
Description copied from interface:VaadinContext
Returns value of the specified attribute, creating and storing a default value if attribute not present.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.- Specified by:
getAttribute
in interfaceVaadinContext
- Parameters:
type
- Type of the attribute.defaultValueSupplier
-Supplier
of the default value, called when there is no value already present. May benull
.- Returns:
- Value of the specified attribute.
-
setAttribute
Description copied from interface:VaadinContext
Sets the attribute value for the give type, overriding previously existing one. Values are based on exact type, meaning only one attribute of given type is possible at any given time.- Specified by:
setAttribute
in interfaceVaadinContext
- Parameters:
clazz
- the type to associate the value with, notnull
value
- the attribute value to set, ornull
to remove the current value
-
removeAttribute
Description copied from interface:VaadinContext
Removes an attribute identified by the given type. If the attribute does not exist, no action will be taken.- Specified by:
removeAttribute
in interfaceVaadinContext
- Parameters:
clazz
- Attribute type.- See Also:
-
getContextParameterNames
Description copied from interface:VaadinContext
Returns the names of the initialization parameters as anEnumeration
, or an emptyEnumeration
if there are o initialization parameters.- Specified by:
getContextParameterNames
in interfaceVaadinContext
- Returns:
- initialization parameters as a
Enumeration
-
getContextParameter
Description copied from interface:VaadinContext
Returns the value for the requested parameter, ornull
if the parameter does not exist.- Specified by:
getContextParameter
in interfaceVaadinContext
- Parameters:
name
- name of the parameter whose value is requested- Returns:
- parameter value as
String
ornull
for no parameter
-