Class SpringInstantiator

java.lang.Object
com.vaadin.flow.di.DefaultInstantiator
com.vaadin.flow.spring.SpringInstantiator
All Implemented Interfaces:
com.vaadin.flow.di.Instantiator, Serializable

public class SpringInstantiator extends com.vaadin.flow.di.DefaultInstantiator
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

    Constructors
    Constructor
    Description
    SpringInstantiator(com.vaadin.flow.server.VaadinService service, org.springframework.context.ApplicationContext context)
    Creates a new spring instantiator instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T extends com.vaadin.flow.component.Component>
    T
    createComponent(Class<T> componentClass)
     
     
    com.vaadin.flow.i18n.I18NProvider
     
    com.vaadin.flow.server.auth.MenuAccessControl
     
    <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.
    Stream<com.vaadin.flow.server.VaadinServiceInitListener>
    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(com.vaadin.flow.server.VaadinService service, org.springframework.context.ApplicationContext context)
      Creates a new spring instantiator instance.
      Parameters:
      service - the service to use
      context - the application context
  • Method Details

    • getServiceInitListeners

      public Stream<com.vaadin.flow.server.VaadinServiceInitListener> getServiceInitListeners()
      Gets all service init listeners to use. Registers by default an init listener that publishes ServiceInitEvent to application context.
      Specified by:
      getServiceInitListeners in interface com.vaadin.flow.di.Instantiator
      Overrides:
      getServiceInitListeners in class com.vaadin.flow.di.DefaultInstantiator
      Returns:
      stream of service init listeners, not null
    • createComponent

      public <T extends com.vaadin.flow.component.Component> T createComponent(Class<T> componentClass)
      Specified by:
      createComponent in interface com.vaadin.flow.di.Instantiator
      Overrides:
      createComponent in class com.vaadin.flow.di.DefaultInstantiator
    • getI18NProvider

      public com.vaadin.flow.i18n.I18NProvider getI18NProvider()
      Specified by:
      getI18NProvider in interface com.vaadin.flow.di.Instantiator
      Overrides:
      getI18NProvider in class com.vaadin.flow.di.DefaultInstantiator
    • getMenuAccessControl

      public com.vaadin.flow.server.auth.MenuAccessControl getMenuAccessControl()
      Specified by:
      getMenuAccessControl in interface com.vaadin.flow.di.Instantiator
      Overrides:
      getMenuAccessControl in class com.vaadin.flow.di.DefaultInstantiator
    • 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:
      getOrCreate in interface com.vaadin.flow.di.Instantiator
      Overrides:
      getOrCreate in class com.vaadin.flow.di.DefaultInstantiator
    • getApplicationClass

      public Class<?> getApplicationClass(Class<?> clazz)