Package com.vaadin.flow.server
Interface VaadinContext
-
- All Superinterfaces:
Serializable
- All Known Implementing Classes:
VaadinServletContext
public interface VaadinContext extends Serializable
Context in whichVaadinServiceis running. This is used to store service-scoped attributes and also works as a wrapper for context objects with properties e.g.ServletContextandPortletContext- Since:
- 2.0.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <T> TgetAttribute(Class<T> type)Returns value of the specified attribute.<T> TgetAttribute(Class<T> type, Supplier<T> defaultValueSupplier)Returns value of the specified attribute, creating and storing a default value if attribute not present.StringgetContextParameter(String name)Returns the value for the requested parameter, ornullif the parameter does not exist.Enumeration<String>getContextParameterNames()Returns the names of the initialization parameters as anEnumeration, or an emptyEnumerationif there are o initialization parameters.voidremoveAttribute(Class<?> clazz)Removes an attribute identified by the given type.<T> voidsetAttribute(Class<T> clazz, T value)Sets the attribute value for the give type, overriding previously existing one.default voidsetAttribute(Object value)Sets the attribute value, overriding previously existing one.
-
-
-
Method Detail
-
getAttribute
<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.If attribute is not yet available the
defaultValueSupplieris used to get the default value which is set as the attribute value and the value is returned. The operation is executed atomically.- Parameters:
type- Type of the attribute.defaultValueSupplier-Supplierof the default value, called when there is no value already present. May benull.- Returns:
- Value of the specified attribute.
-
getAttribute
default <T> T getAttribute(Class<T> type)
Returns value of the specified attribute.- Parameters:
type- Type of the attribute.- Returns:
- Value of the specified attribute.
-
setAttribute
<T> void setAttribute(Class<T> clazz, T value)
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.- Parameters:
clazz- the type to associate the value with, notnullvalue- the attribute value to set, ornullto remove the current value- Since:
-
setAttribute
default void setAttribute(Object value)
Sets the attribute value, overriding previously existing one. Values are based on exact type, meaning only one attribute of given type is possible at any given time.- Parameters:
value- attribute value, notnull.- See Also:
for removing attributes.
-
removeAttribute
void removeAttribute(Class<?> clazz)
Removes an attribute identified by the given type. If the attribute does not exist, no action will be taken.- Parameters:
clazz- Attribute type.- See Also:
for setting attributes.
-
getContextParameterNames
Enumeration<String> getContextParameterNames()
Returns the names of the initialization parameters as anEnumeration, or an emptyEnumerationif there are o initialization parameters.- Returns:
- initialization parameters as a
Enumeration
-
-