public class DefaultInstantiator extends Object implements Instantiator
Class.newInstance()
and ServiceLoader
.Constructor and Description |
---|
DefaultInstantiator(VaadinService service)
Creates a new instantiator for the given service.
|
Modifier and Type | Method and Description |
---|---|
<T extends Component> |
createComponent(Class<T> componentClass)
Creates an instance of a component by its
componentClass . |
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.
|
static Stream<VaadinServiceInitListener> |
getServiceLoaderListeners(ClassLoader classloader)
Helper for finding service init listeners using
ServiceLoader . |
boolean |
init(VaadinService service)
Initializes this instantiator.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
createRouteTarget, get, getBootstrapListeners, getDependencyFilters, getTemplateParser
public DefaultInstantiator(VaadinService service)
service
- the service to usepublic boolean init(VaadinService service)
Instantiator
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.init
in interface Instantiator
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 processpublic Stream<VaadinServiceInitListener> getServiceInitListeners()
Instantiator
ServiceLoader
convention. This can be done by
including the items from
getServiceInitListeners()
in the returned
stream.getServiceInitListeners
in interface Instantiator
null
public <T> T getOrCreate(Class<T> type)
Instantiator
How the object is created and whether it is being cached or not is up to the implementation.
getOrCreate
in interface Instantiator
T
- the type of the instance to createtype
- the instance type to create, not null
public <T extends Component> T createComponent(Class<T> componentClass)
Instantiator
componentClass
.createComponent
in interface Instantiator
T
- the component typecomponentClass
- the instance type to create, not null
null
public static Stream<VaadinServiceInitListener> getServiceLoaderListeners(ClassLoader classloader)
ServiceLoader
.classloader
- the classloader to use for finding the listenerspublic I18NProvider getI18NProvider()
Instantiator
getI18NProvider
in interface Instantiator
Copyright © 2025. All rights reserved.