com.vaadin.flow.di.
Class DefaultInstantiator
All Implemented Interfaces:
Direct Known Subclasses:
Default instantiator that is used if no other instantiator has been
registered. This implementation uses vanilla Java mechanisms such as
Class.newInstance()
and ServiceLoader
.
Since:
1.0
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultInstantiator
(VaadinService service) Creates a new instantiator for the given service.
-
Method Summary
Modifier and TypeMethodDescription<T extends Component>
TcreateComponent
(Class<T> componentClass) Creates an instance of a component by its
componentClass
.protected ClassLoader
Get the I18NProvider if one has been defined.
protected String
getInitProperty
(String propertyName) Get property value from the session configurator or try to load it from application.properties property file.
Get the MenuAccessControl.
<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.
Gets all service init listeners to use.
static Stream<VaadinServiceInitListener>
getServiceLoaderListeners
(ClassLoader classloader) Helper for finding service init listeners using
ServiceLoader
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.di.Instantiator
createRouteTarget, getApplicationClass, getApplicationClass, getDependencyFilters, getIndexHtmlRequestListeners
-
Constructor Details
-
DefaultInstantiator
Creates a new instantiator for the given service.
Parameters:
service
- the service to use
-
-
Method Details
-
getServiceInitListeners
Description copied from interface:
Instantiator
Gets all service init listeners to use. In addition to listeners defined in some way native to a specific instantiator, it is also recommended to support the default
ServiceLoader
convention. This can be done by including the items fromgetServiceInitListeners()
in the returned stream.Specified by:
getServiceInitListeners
in interfaceInstantiator
Returns:
stream of service init listeners, not
null
-
getOrCreate
Description copied from interface:
Instantiator
Provides an instance of any given type, this is an abstraction that allows to make use of DI-frameworks from add-ons.
How the object is created and whether it is being cached or not is up to the implementation.
Specified by:
getOrCreate
in interfaceInstantiator
Type Parameters:
T
- the type of the instance to createParameters:
type
- the instance type to create, notnull
Returns:
an instance of the given type
-
createComponent
Description copied from interface:
Instantiator
Creates an instance of a component by its
componentClass
.Specified by:
createComponent
in interfaceInstantiator
Type Parameters:
T
- the component typeParameters:
componentClass
- the instance type to create, notnull
Returns:
the created instance, not
null
-
getServiceLoaderListeners
Helper for finding service init listeners using
ServiceLoader
.Parameters:
classloader
- the classloader to use for finding the listenersReturns:
a stream of service init listeners
-
getI18NProvider
Description copied from interface:
Instantiator
Get the I18NProvider if one has been defined.
Specified by:
getI18NProvider
in interfaceInstantiator
Returns:
I18NProvider instance
-
getMenuAccessControl
Description copied from interface:
Instantiator
Get the MenuAccessControl.
Specified by:
getMenuAccessControl
in interfaceInstantiator
Returns:
MenuAccessControl instance
-
getClassLoader
-
getInitProperty
Get property value from the session configurator or try to load it from application.properties property file.
Returns:
parameter value or null if not found
-