Package com.vaadin.flow.server
Class VaadinServletContext
- java.lang.Object
-
- com.vaadin.flow.server.VaadinServletContext
-
- All Implemented Interfaces:
VaadinContext,Serializable
public class VaadinServletContext extends Object implements VaadinContext
VaadinContextthat goes withVaadinServletService.- Since:
- 2.0.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VaadinServletContext(javax.servlet.ServletContext context)Creates an instance of this context with givenServletContext.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> TgetAttribute(Class<T> type, Supplier<T> defaultValueSupplier)Returns value of the specified attribute, creating and storing a default value if attribute not present.javax.servlet.ServletContextgetContext()Returns the underlying context.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.-
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: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- 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
public <T> void setAttribute(Class<T> clazz, T value)
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- Parameters:
clazz- the type to associate the value with, notnullvalue- the attribute value to set, ornullto remove the current value
-
removeAttribute
public void removeAttribute(Class<?> clazz)
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:
for setting attributes.
-
getContextParameterNames
public Enumeration<String> 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
public String getContextParameter(String name)
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
-
-