public interface Instantiator extends Serializable
VaadinService will by default use ServiceLoader for finding
an instantiator implementation. Deployment will fail if multiple candidates
are returning true from init(VaadinService). If no
candidate is found, DefaultInstantiator will be used. It is possible
to override this mechanism by overriding
VaadinService.createInstantiator().
| Modifier and Type | Method and Description |
|---|---|
<T extends Component> |
createComponent(Class<T> componentClass)
Creates an instance of a component by its
componentClass. |
default <T extends HasElement> |
createRouteTarget(Class<T> routeTargetType,
NavigationEvent event)
Creates an instance of a navigation target or router layout.
|
static Instantiator |
get(UI ui)
Gets the instantiator to use for the given UI.
|
default Stream<BootstrapListener> |
getBootstrapListeners(Stream<BootstrapListener> serviceInitListeners)
Processes the available bootstrap listeners.
|
default Stream<DependencyFilter> |
getDependencyFilters(Stream<DependencyFilter> serviceInitFilters)
Processes the available dependency filters.
|
default I18NProvider |
getI18NProvider()
Get the I18NProvider if one has been defined.
|
<T> T |
getOrCreate(Class<T> type)
Provides an instance of any given type, this is an abstraction that
allows to make use of DI-frameworks from add-ons.
|
Stream<VaadinServiceInitListener> |
getServiceInitListeners()
Gets all service init listeners to use.
|
default TemplateParser |
getTemplateParser()
Returns
TemplateParser for this service. |
boolean |
init(VaadinService service)
Deprecated.
The
Instantiator instance should be created by an
InstantiatorFactory which should just return
null if the provided service can't be handled
by it |
@Deprecated boolean init(VaadinService service)
Instantiator instance should be created by an
InstantiatorFactory which should just return
null if the provided service can't be handled
by itfalse. It is recommended that all
implementations provide a way for application developers to disable an
implementation so that it can be present on the classpath without
preventing the application from being deployed in cases when multiple
candidates are available.service - the Vaadin service for which this instance is initializedtrue if this instance should be considered as a
candidate for usage for the provided service; false
to opt-out from the selection processStream<VaadinServiceInitListener> getServiceInitListeners()
ServiceLoader convention. This can be done by
including the items from
DefaultInstantiator.getServiceInitListeners() in the returned
stream.nulldefault Stream<BootstrapListener> getBootstrapListeners(Stream<BootstrapListener> serviceInitListeners)
VaadinServiceInitListener implementations.
The default implementation returns the original listeners without changes.
The order of the listeners inside the stream defines the order of the
execution of those listeners by the
VaadinService.modifyBootstrapPage(BootstrapPageResponse) method.
serviceInitListeners - a stream of bootstrap listeners provided by service init
listeners, not nullnulldefault Stream<DependencyFilter> getDependencyFilters(Stream<DependencyFilter> serviceInitFilters)
VaadinServiceInitListener implementations.
The default implementation returns the original handlers without changes.
The order of the filters inside the stream defines the order of the
execution of those listeners by the
UidlWriter.createUidl(UI, boolean) method.
serviceInitFilters - a stream of dependency filters provided by service init
listeners, not nullnull<T> T getOrCreate(Class<T> type)
How the object is created and whether it is being cached or not is up to the implementation.
T - the type of the instance to createtype - the instance type to create, not nulldefault <T extends HasElement> T createRouteTarget(Class<T> routeTargetType, NavigationEvent event)
T - the route target typerouteTargetType - the instance type to create, not nullevent - the navigation event for which the instance is created, not
nullnull<T extends Component> T createComponent(Class<T> componentClass)
componentClass.T - the component typecomponentClass - the instance type to create, not nullnullstatic Instantiator get(UI ui)
ui - the attached UI for which to find an instantiator, not
nullnulldefault I18NProvider getI18NProvider()
default TemplateParser getTemplateParser()
TemplateParser for this service.Copyright © 2025. All rights reserved.