
org.jgrapes.util.ComponentCollector Maven / Gradle / Ivy
/*
* JGrapes Event Driven Framework
* Copyright (C) 2017-2018 Michael N. Lipp
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
* for more details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program; if not, see .
*/
package org.jgrapes.util;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.ServiceLoader.Provider;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.stream.Collectors;
import org.jgrapes.core.Channel;
import org.jgrapes.core.ComponentFactory;
import org.jgrapes.util.events.ConfigurationUpdate;
/**
* 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 {@link ComponentProvider#setFactories(ComponentFactory...)}
* and {@link ComponentProvider#setPinned(List)} for its implementation.
* As it inherits from {@link ComponentProvider}, it automatically
* supports the provisioning of additional components through
* {@link ConfigurationUpdate} events. If this is not desired, invoke
* {@link ComponentProvider#setComponentsEntry(String)} with `null` as
* argument.
*
* @param the component factory type
*/
public class ComponentCollector
extends ComponentProvider {
private static final List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy