Class VaadinServletContext

java.lang.Object
com.vaadin.flow.server.VaadinServletContext
All Implemented Interfaces:
VaadinContext, Serializable

public class VaadinServletContext extends Object implements VaadinContext
Since:
2.0.0
See Also:
  • Constructor Details

    • VaadinServletContext

      public VaadinServletContext(jakarta.servlet.ServletContext context)
      Creates an instance of this context with given ServletContext.
      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

      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 interface VaadinContext
      Parameters:
      type - Type of the attribute.
      defaultValueSupplier - Supplier of the default value, called when there is no value already present. May be null.
      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 interface VaadinContext
      Parameters:
      clazz - the type to associate the value with, not null
      value - the attribute value to set, or null 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 interface VaadinContext
      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 empty Enumeration if there are o initialization parameters.
      Specified by:
      getContextParameterNames in interface VaadinContext
      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 interface VaadinContext
      Parameters:
      name - name of the parameter whose value is requested
      Returns:
      parameter value as String or null for no parameter