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 |
---|---|
default <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.
|
boolean |
init(VaadinService service)
Initializes this instantiator.
|
boolean init(VaadinService service)
false
. 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.null
default 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 null
null
default 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 null
null
<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 null
default <T extends HasElement> T createRouteTarget(Class<T> routeTargetType, NavigationEvent event)
T
- the route target typerouteTargetType
- the instance type to create, not null
event
- the navigation event for which the instance is created, not
null
null
default <T extends Component> T createComponent(Class<T> componentClass)
componentClass
.T
- the component typecomponentClass
- the instance type to create, not null
null
static Instantiator get(UI ui)
ui
- the attached UI for which to find an instantiator, not
null
null
default I18NProvider getI18NProvider()
Copyright © 2018. All rights reserved.