com.vaadin.flow.spring.
Class SpringInstantiator
All Implemented Interfaces:
Default Spring instantiator that is used if no other instantiator has been registered. This implementation uses Spring beans.
Author:
Vaadin Ltd
See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSpringInstantiator
(VaadinService service, org.springframework.context.ApplicationContext context) Creates a new spring instantiator instance.
-
Method Summary
Modifier and TypeMethodDescription<T extends Component>
TcreateComponent
(Class<T> componentClass) Class<?>
getApplicationClass
(Class<?> clazz) <T> T
getOrCreate
(Class<T> type) Hands over an existing bean or tries to instantiate one with the following rules: If exactly one bean is present in the context, it returns this bean.
Gets all service init listeners to use.
Methods inherited from class com.vaadin.flow.di.DefaultInstantiator
getClassLoader, getInitProperty, getServiceLoaderListeners
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, getDependencyFilters, getIndexHtmlRequestListeners
-
Constructor Details
-
SpringInstantiator
public SpringInstantiator(VaadinService service, org.springframework.context.ApplicationContext context) Creates a new spring instantiator instance.
Parameters:
service
- the service to usecontext
- the application context
-
-
Method Details
-
getServiceInitListeners
Gets all service init listeners to use. Registers by default an init listener that publishes ServiceInitEvent to application context.
Specified by:
getServiceInitListeners
in interfaceInstantiator
Overrides:
getServiceInitListeners
in classDefaultInstantiator
Returns:
stream of service init listeners, not
null
-
createComponent
Specified by:
createComponent
in interfaceInstantiator
Overrides:
createComponent
in classDefaultInstantiator
-
getI18NProvider
Specified by:
getI18NProvider
in interfaceInstantiator
Overrides:
getI18NProvider
in classDefaultInstantiator
-
getMenuAccessControl
Specified by:
getMenuAccessControl
in interfaceInstantiator
Overrides:
getMenuAccessControl
in classDefaultInstantiator
-
getOrCreate
Hands over an existing bean or tries to instantiate one with the following rules:
- If exactly one bean is present in the context, it returns this bean.
- If no bean is present, it tries to instantiate one.
- If more than one bean is present, it tries to instantiate one but in case of a Bean instantiation exception this exception is catched and rethrown with a hint. Reason for this is, that users may expect it to "use" a bean but have multiple in the context. So the hint helps them find the problem.
Specified by:
getOrCreate
in interfaceInstantiator
Overrides:
getOrCreate
in classDefaultInstantiator
-
getApplicationClass
-