com.vaadin.flow.server.
Class VaadinServletContext
- java.lang.Object
-
- com.vaadin.flow.server.VaadinServletContext
-
All Implemented Interfaces:
public class VaadinServletContext extends Object implements VaadinContext
VaadinContext
that goes withVaadinServletService
.Since:
2.0.0
See Also:
-
-
Constructor Summary
Constructors Constructor Description VaadinServletContext(javax.servlet.ServletContext context)
Creates an instance of this context with given
ServletContext
.
-
Method Summary
All Methods Modifier and Type Method 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 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
-
-
-
-
Method Detail
-
getContext
public javax.servlet.ServletContext getContext()
Returns the underlying context.
Returns:
A non-null
ServletContext
.
-
getAttribute
public <T> T getAttribute(Class<T> type, Supplier<T> defaultValueSupplier)
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
public <T> void setAttribute(Class<T> clazz, T value)
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
public void removeAttribute(Class<?> clazz)
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
public Enumeration<String> getContextParameterNames()
Description copied from interface:
VaadinContext
Returns the names of the initialization parameters as an
Enumeration
, or an emptyEnumeration
if there are o initialization parameters.Specified by:
getContextParameterNames
in interfaceVaadinContext
Returns:
initialization parameters as a
Enumeration
-
getContextParameter
public String getContextParameter(String name)
Description copied from interface:
VaadinContext
Returns the value for the requested parameter, or
null
if the parameter does not exist.Specified by:
getContextParameter
in interfaceVaadinContext
Parameters:
name
- name of the parameter whose value is requestedReturns:
parameter value as
String
ornull
for no parameter
-
-