Class WebComponentConfigurationRegistry

java.lang.Object
com.vaadin.flow.server.webcomponent.WebComponentConfigurationRegistry
All Implemented Interfaces:
Serializable

public class WebComponentConfigurationRegistry extends Object implements Serializable
Registry for storing available web component configuration implementations.

For internal use only. May be renamed or removed in a future release.

Since:
2.0
Author:
Vaadin Ltd.
See Also:
  • Constructor Details

    • WebComponentConfigurationRegistry

      protected WebComponentConfigurationRegistry()
      Protected constructor for internal OSGi extensions.
  • Method Details

    • getConfiguration

      public Optional<WebComponentConfiguration<? extends Component>> getConfiguration(String tag)
      Get a web component configuration for given custom element tag if one is registered.
      Parameters:
      tag - custom element tag
      Returns:
      Optional containing a web component configuration matching given tag
    • getConfigurationsByComponentType

      public <T extends Component> Set<WebComponentConfiguration<T>> getConfigurationsByComponentType(Class<T> componentClass)
      Get an unmodifiable set containing all registered web component configurations for a specific Component type.
      Type Parameters:
      T - component
      Parameters:
      componentClass - type of the exported Component
      Returns:
      set of WebComponentConfiguration or an empty set.
    • updateRegistry

      protected void updateRegistry(Set<WebComponentConfiguration<? extends Component>> configurations)
      Internal method for updating registry.
      Parameters:
      configurations - set of web component configurations to register
    • setConfigurations

      public boolean setConfigurations(Set<WebComponentConfiguration<? extends Component>> configurations)
      Registers all available web component configurations to the registry.

      This can be done only once and any following set should only return false.

      Parameters:
      configurations - set of web component configurations to register. These configurations must have both unique and valid tag names.
      Returns:
      true if set successfully or false if not set
    • hasConfigurations

      public boolean hasConfigurations()
      Checks whether the registry contains any web component configurations.
      Returns:
      true if setConfigurations(Set) has been called a non-empty set.
    • getEmbeddedApplicationAnnotation

      public <T extends Annotation> Optional<T> getEmbeddedApplicationAnnotation(Class<T> type)
      Returns configuration annotation for embedded application.

      WebComponentExporter classes may declare configuration annotations. If there are several different annotations declared for various exporter classes then an exception will be thrown during the servlet initialization (exporter classes discovering).

      Parameters:
      type - the configuration annotation type
      Returns:
      an optional configuration annotation, or an empty optional if there is no configuration annotation with the given type
    • getConfigurations

      public Set<WebComponentConfiguration<? extends Component>> getConfigurations()
      Get an unmodifiable set containing all registered web component configurations.
      Returns:
      unmodifiable set of web component configurations in registry or an empty set
    • setShadowDomElements

      public void setShadowDomElements(List<Element> elements)
      Set the elements that should be added to each shadow dom hosting an embedded web component.
      Parameters:
      elements - list of shadow dom elements
    • getShadowDomElements

      public List<Element> getShadowDomElements()
      Get a copy of the elements that should be added to the shadow dom hosting the embedded web component.
      Returns:
      copy of shadow dom elements
    • getInstance

      public static WebComponentConfigurationRegistry getInstance(VaadinContext context)
      Get WebComponentRegistry instance for given servlet context.
      Parameters:
      context - VaadinService to keep the instance in
      Returns:
      WebComponentRegistry instance