Package com.vaadin.flow.spring
Class SpringInstantiator
- java.lang.Object
-
- com.vaadin.flow.di.DefaultInstantiator
-
- com.vaadin.flow.spring.SpringInstantiator
-
- All Implemented Interfaces:
Instantiator,Serializable
public class SpringInstantiator extends DefaultInstantiator
Default Spring instantiator that is used if no other instantiator has been registered. This implementation uses Spring beans.- Author:
- Vaadin Ltd
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description SpringInstantiator(VaadinService service, org.springframework.context.ApplicationContext context)Creates a new spring instantiator instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends Component>
TcreateComponent(Class<T> componentClass)I18NProvidergetI18NProvider()<T> TgetOrCreate(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.Stream<VaadinServiceInitListener>getServiceInitListeners()-
Methods inherited from class com.vaadin.flow.di.DefaultInstantiator
getServiceLoaderListeners, init
-
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, getBootstrapListeners, getDependencyFilters, getIndexHtmlRequestListeners
-
-
-
-
Constructor Detail
-
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 Detail
-
getServiceInitListeners
public Stream<VaadinServiceInitListener> getServiceInitListeners()
- Specified by:
getServiceInitListenersin interfaceInstantiator- Overrides:
getServiceInitListenersin classDefaultInstantiator
-
createComponent
public <T extends Component> T createComponent(Class<T> componentClass)
- Specified by:
createComponentin interfaceInstantiator- Overrides:
createComponentin classDefaultInstantiator
-
getI18NProvider
public I18NProvider getI18NProvider()
- Specified by:
getI18NProviderin interfaceInstantiator- Overrides:
getI18NProviderin classDefaultInstantiator
-
getOrCreate
public <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.
- 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:
getOrCreatein interfaceInstantiator- Overrides:
getOrCreatein classDefaultInstantiator
-
-