Class DefaultInstantiator

    • Constructor Detail

      • DefaultInstantiator

        public DefaultInstantiator​(VaadinService service)
        Creates a new instantiator for the given service.
        Parameters:
        service - the service to use
    • Method Detail

      • init

        public boolean init​(VaadinService service)
        Description copied from interface: Instantiator
        Initializes this instantiator. This method is run only once and before running any other method. An implementation can opt-out from being used by returning false. It is recommended that all implementations provide a way for application developers to disable an implementation so that it can be present on the classpath without preventing the application from being deployed in cases when multiple candidates are available.
        Specified by:
        init in interface Instantiator
        Parameters:
        service - the Vaadin service for which this instance is initialized
        Returns:
        true if this instance should be considered as a candidate for usage for the provided service; false to opt-out from the selection process
      • 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