Class ComponentCollector<F extends ComponentFactory>
- Type Parameters:
F
- the component factory type
- All Implemented Interfaces:
Iterable<ComponentType>
,Channel
,ComponentType
,Eligible
,Manager
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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jgrapes.core.Channel
Channel.Default
-
Field Summary
Fields inherited from class org.jgrapes.util.ComponentProvider
COMPONENT_NAME, COMPONENT_TYPE
-
Constructor Summary
ConstructorDescriptionComponentCollector
(Class<F> factoryClass, Channel componentChannel) Utility constructor that uses each factory to create a single instance, using an empty map as properties.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. -
Method Summary
Methods inherited from class org.jgrapes.util.ComponentProvider
componentConfigurations, factories, onConfigurationUpdate, pinned, providerConfiguration, setComponentsEntry, setFactories, setPinned
Methods inherited from class org.jgrapes.core.Component
channel, component, defaultCriterion, isEligibleFor, setName
Methods inherited from class org.jgrapes.core.internal.ComponentVertex
activeEventPipeline, addHandler, attach, channelReplacements, children, componentPath, componentVertex, detach, fire, initComponentsHandlers, iterator, name, newEventPipeline, newEventPipeline, parent, registerAsGenerator, root, toString, unregisterAsGenerator
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
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 toComponentFactory.create(Channel, Map)
.- Parameters:
factoryClass
- the factory classcomponentChannel
- this component’s channelconfigurator
- the configurator function
-
ComponentCollector
Utility constructor that uses each factory to create a single instance, using an empty map as properties.- Parameters:
factoryClass
- the factory classcomponentChannel
- this component’s channel
-