Class MockInstantiator

java.lang.Object
com.vaadin.browserless.mocks.MockInstantiator
All Implemented Interfaces:
Instantiator, Serializable

@Deprecated(forRemoval=true) public class MockInstantiator extends Object implements Instantiator
Deprecated, for removal: This API element is subject to removal in a future version.
Wrapping the instantiator of the mocked environment has no effect; use that instantiator directly. Scheduled for removal.
An Instantiator wrapping the one the mocked environment provides.

The wrapper does not mock anything any more: the getOrCreate(java.lang.Class<T>) special cases it was written for are long gone, so every member simply forwards to delegate. The mocked services therefore use the environment's own instantiator directly, and this class is kept for source compatibility only.

The forwarding is spelled out by hand on purpose. A wrapper that leaves a method out inherits Flow's default implementation instead of reaching the delegate, which is how a Spring PageTitleGenerator bean used to be dropped in browserless tests. Since a wrapper can always fall behind a method added to Instantiator later, create(Instantiator) hands back the delegate itself instead of wrapping it.

The list of forwarders below is deliberately not guarded by a test: pinning it would fail the build whenever Flow adds a method to Instantiator, which is not worth it for a class scheduled for removal and used by nothing here. A method missing from the list is therefore silently dropped for callers who construct this class themselves — one more reason not to.

For internal use only. May be renamed or removed in a future release.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates a wrapper forwarding to the given instantiator.
  • Method Summary

    Modifier and Type
    Method
    Description
    create(Instantiator delegate)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns delegate as is: wrapping it changes nothing, and a wrapper risks dropping methods added to Instantiator in the future.
    <T extends Component>
    T
    createComponent(Class<T> componentClass)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates an instance of a component by its componentClass.
    <T extends HasElement>
    T
    createRouteTarget(Class<T> routeTargetType, NavigationEvent event)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Creates an instance of a navigation target or router layout.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the application-defined class for the given class: usually simply the given class, but the original class in case of a runtime generated subclass.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the application-defined class for the given instance: usually simply the class of the given instance, but the original class in case of a runtime generated subclass.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns the instantiator every member of this class forwards to.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Processes the available dependency filters.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the I18NProvider if one has been defined.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Processes the available Index HTML request listeners.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the MenuAccessControl.
    <T> T
    getOrCreate(Class<T> type)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Provides an instance of any given type, this is an abstraction that allows to make use of DI-frameworks from add-ons.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the application-wide default PageTitleGenerator, if one has been defined.
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets all service init listeners to use.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MockInstantiator

      public MockInstantiator(Instantiator delegate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Creates a wrapper forwarding to the given instantiator.
      Parameters:
      delegate - the instantiator to forward to
  • Method Details

    • getDelegate

      public Instantiator getDelegate()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns the instantiator every member of this class forwards to.
      Returns:
      the delegate
    • getOrCreate

      public <T> T getOrCreate(Class<T> type)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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
    • getServiceInitListeners

      public Stream<VaadinServiceInitListener> getServiceInitListeners()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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 DefaultInstantiator.getServiceInitListeners() in the returned stream.
      Specified by:
      getServiceInitListeners in interface Instantiator
      Returns:
      stream of service init listeners, not null
    • getIndexHtmlRequestListeners

      public Stream<IndexHtmlRequestListener> getIndexHtmlRequestListeners(Stream<IndexHtmlRequestListener> indexHtmlRequestListeners)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Instantiator
      Processes the available Index HTML request listeners. This method can supplement the set of Index HTML request listeners provided by VaadinServiceInitListener implementations.

      The default implementation returns the original listeners without changes.

      Specified by:
      getIndexHtmlRequestListeners in interface Instantiator
      Parameters:
      indexHtmlRequestListeners - a stream of Index HTML request listeners provided by service init listeners, not null
      Returns:
      a stream of all Index HTML request listeners to use, not null
    • getDependencyFilters

      public Stream<DependencyFilter> getDependencyFilters(Stream<DependencyFilter> serviceInitFilters)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Instantiator
      Processes the available dependency filters. This method can supplement the set of dependency filters provided by VaadinServiceInitListener implementations.

      The default implementation returns the original handlers without changes.

      The order of the filters inside the stream defines the order of the execution of those listeners by the UidlWriter.createUidl(UI, boolean) method.

      Specified by:
      getDependencyFilters in interface Instantiator
      Parameters:
      serviceInitFilters - a stream of dependency filters provided by service init listeners, not null
      Returns:
      a stream of all dependency filters to use, not null
    • getApplicationClass

      public Class<?> getApplicationClass(Object instance)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Instantiator
      Return the application-defined class for the given instance: usually simply the class of the given instance, but the original class in case of a runtime generated subclass.
      Specified by:
      getApplicationClass in interface Instantiator
      Parameters:
      instance - the instance to check
      Returns:
      the user-defined class
    • getApplicationClass

      public Class<?> getApplicationClass(Class<?> clazz)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Instantiator
      Return the application-defined class for the given class: usually simply the given class, but the original class in case of a runtime generated subclass.
      Specified by:
      getApplicationClass in interface Instantiator
      Parameters:
      clazz - the class to check
      Returns:
      the user-defined class
    • createRouteTarget

      public <T extends HasElement> T createRouteTarget(Class<T> routeTargetType, NavigationEvent event)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Instantiator
      Creates an instance of a navigation target or router layout. This method is not called in cases when a component instance is reused when navigating.
      Specified by:
      createRouteTarget in interface Instantiator
      Type Parameters:
      T - the route target type
      Parameters:
      routeTargetType - the instance type to create, not null
      event - the navigation event for which the instance is created, not null
      Returns:
      the created instance, not null
    • createComponent

      public <T extends Component> T createComponent(Class<T> componentClass)
      Deprecated, for removal: This API element is subject to removal in a future version.
      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
    • getI18NProvider

      public I18NProvider getI18NProvider()
      Deprecated, for removal: This API element is subject to removal in a future version.
      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()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Instantiator
      Get the MenuAccessControl.
      Specified by:
      getMenuAccessControl in interface Instantiator
      Returns:
      MenuAccessControl instance
    • getPageTitleGenerator

      public PageTitleGenerator getPageTitleGenerator()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from interface: Instantiator
      Gets the application-wide default PageTitleGenerator, if one has been defined.

      Used to resolve route titles without a per-route DynamicPageTitle, for example a single generator that turns the declared PageTitle value into a translated title for every route.

      Specified by:
      getPageTitleGenerator in interface Instantiator
      Returns:
      the default page title generator, or null if none has been defined
    • create

      public static Instantiator create(Instantiator delegate)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns delegate as is: wrapping it changes nothing, and a wrapper risks dropping methods added to Instantiator in the future.
      Parameters:
      delegate - the instantiator to return
      Returns:
      the given instantiator, unwrapped