Class ComponentCollector<F extends ComponentFactory>

Type Parameters:
F - the component factory type
All Implemented Interfaces:
Iterable<ComponentType>, Channel, ComponentType, Eligible, Manager

public class ComponentCollector<F extends ComponentFactory> extends ComponentProvider
A component that collects all component factory services of a given type and uses each to create one or more components that are then attached to the component collector instance.

Effectively, the component collector leverages the mechanism provided by the service loader to configure the component subtree rooted at the collector at “link time”.

This class uses ComponentProvider.setFactories(ComponentFactory...) and ComponentProvider.setPinned(List) for its implementation. As it inherits from ComponentProvider, it automatically supports the provisioning of additional components through ConfigurationUpdate events. If this is not desired, invoke ComponentProvider.setComponentsEntry(String) with null as argument.

  • Constructor Details

    • ComponentCollector

      public ComponentCollector(Class<F> factoryClass, Channel componentChannel, Function<String,List<Map<Object,Object>>> configurator)
      Creates a new collector that collects the factories of the given type and uses each to create one or more instances with this component’s (the component collector’s) channel.

      Before instances are created, the matcher function is invoked with the name of the class of the component to be created as argument. The list of maps returned is used to create components, passing each element in the list as parameter to ComponentFactory.create(Channel, Map).

      Parameters:
      factoryClass - the factory class
      componentChannel - this component’s channel
      configurator - the configurator function
    • ComponentCollector

      public ComponentCollector(Class<F> factoryClass, Channel componentChannel)
      Utility constructor that uses each factory to create a single instance, using an empty map as properties.
      Parameters:
      factoryClass - the factory class
      componentChannel - this component’s channel