com.vaadin.flow.server.webcomponent.
Class WebComponentConfigurationRegistry
- java.lang.Object
-
- com.vaadin.flow.server.webcomponent.WebComponentConfigurationRegistry
-
All Implemented Interfaces:
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 Summary
Constructors Modifier Constructor Description protected
WebComponentConfigurationRegistry()
Protected constructor for internal OSGi extensions.
-
Method Summary
All Methods Modifier and Type Method Description Optional<WebComponentConfiguration<? extends Component>>
getConfiguration(String tag)
Get a web component configuration for given custom element tag if one is registered.
Set<WebComponentConfiguration<? extends Component>>
getConfigurations()
Get an unmodifiable set containing all registered web component configurations.
<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.<T extends Annotation>
Optional<T>getEmbeddedApplicationAnnotation(Class<T> type)
Returns configuration annotation for embedded application.
static WebComponentConfigurationRegistry
getInstance(VaadinContext context)
Get WebComponentRegistry instance for given servlet context.
List<Element>
getShadowDomElements()
Get a copy of the elements that should be added to the shadow dom hosting the embedded web component.
boolean
hasConfigurations()
Checks whether the registry contains any web component configurations.
boolean
setConfigurations(Set<WebComponentConfiguration<? extends Component>> configurations)
Registers all available web component configurations to the registry.
void
setShadowDomElements(List<Element> elements)
Set the elements that should be added to each shadow dom hosting an embedded web component.
protected void
updateRegistry(Set<WebComponentConfiguration<? extends Component>> configurations)
Internal method for updating registry.
-
-
-
Method Detail
-
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 tagReturns:
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
- componentParameters:
componentClass
- type of the exportedComponent
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 orfalse
if not set
-
hasConfigurations
public boolean hasConfigurations()
Checks whether the registry contains any web component configurations.
Returns:
true
ifsetConfigurations(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 typeReturns:
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 inReturns:
WebComponentRegistry instance
-
-