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> TgetAttribute(Class<T> type, Supplier<T> defaultValueSupplier) Returns value of the specified attribute, creating and storing a default value if attribute not present.jakarta.servlet.ServletContextReturns the underlying context.getContextParameter(String name) Returns the value for the requested parameter, ornullif the parameter does not exist.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.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:VaadinContextReturns 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.- Specified by:
getAttributein interfaceVaadinContext- Type Parameters:
T- the type of the attribute value- 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.
-
setAttribute
Description copied from interface:VaadinContextSets 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:
setAttributein interfaceVaadinContext- Type Parameters:
T- the type of the attribute value- Parameters:
clazz- the type to associate the value with, notnullvalue- the attribute value to set, ornullto remove the current value
-
removeAttribute
Description copied from interface:VaadinContextRemoves an attribute identified by the given type. If the attribute does not exist, no action will be taken.- Specified by:
removeAttributein interfaceVaadinContext- Parameters:
clazz- Attribute type.- See Also:
-
getContextParameterNames
Description copied from interface:VaadinContextReturns the names of the initialization parameters as anEnumeration, or an emptyEnumerationif there are o initialization parameters.- Specified by:
getContextParameterNamesin interfaceVaadinContext- Returns:
- initialization parameters as a
Enumeration
-
getContextParameter
Description copied from interface:VaadinContextReturns the value for the requested parameter, ornullif the parameter does not exist.- Specified by:
getContextParameterin interfaceVaadinContext- Parameters:
name- name of the parameter whose value is requested- Returns:
- parameter value as
Stringornullfor no parameter
-