com.vaadin.flow.di.

Class DefaultInstantiator

java.lang.Object
com.vaadin.flow.di.DefaultInstantiator

All Implemented Interfaces:

Instantiator, Serializable

Direct Known Subclasses:

SpringInstantiator

public class DefaultInstantiator extends Object implements Instantiator

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 Details

    • DefaultInstantiator

      public DefaultInstantiator(VaadinService service)

      Creates a new instantiator for the given service.

      Parameters:

      service - the service to use

  • Method Details

    • getServiceInitListeners

      public Stream<VaadinServiceInitListener> 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 from getServiceInitListeners() in the returned stream.

      Specified by:

      getServiceInitListeners in interface Instantiator

      Returns:

      stream of service init listeners, not null

    • getOrCreate

      public <T> T getOrCreate(Class<T> type)

      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 interface Instantiator

      Type Parameters:

      T - the type of the instance to create

      Parameters:

      type - the instance type to create, not null

      Returns:

      an instance of the given type

    • createComponent

      public <T extends Component> T createComponent(Class<T> componentClass)

      Description copied from interface: Instantiator

      Creates an instance of a component by its componentClass.

      Specified by:

      createComponent in interface Instantiator

      Type Parameters:

      T - the component type

      Parameters:

      componentClass - the instance type to create, not null

      Returns:

      the created instance, not null

    • getServiceLoaderListeners

      public static Stream<VaadinServiceInitListener> getServiceLoaderListeners(ClassLoader classloader)

      Helper for finding service init listeners using ServiceLoader.

      Parameters:

      classloader - the classloader to use for finding the listeners

      Returns:

      a stream of service init listeners

    • getI18NProvider

      public I18NProvider getI18NProvider()

      Description copied from interface: Instantiator

      Get the I18NProvider if one has been defined.

      Specified by:

      getI18NProvider in interface Instantiator

      Returns:

      I18NProvider instance

    • getMenuAccessControl

      public MenuAccessControl getMenuAccessControl()

      Description copied from interface: Instantiator

      Get the MenuAccessControl.

      Specified by:

      getMenuAccessControl in interface Instantiator

      Returns:

      MenuAccessControl instance

    • getClassLoader

      protected ClassLoader getClassLoader()
    • getInitProperty

      protected String getInitProperty(String propertyName)

      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