
org.jgrapes.util.ComponentProvider Maven / Gradle / Ivy
/*
* JGrapes Event Driven Framework
* Copyright (C) 2022 Michael N. Lipp
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU 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 General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, see .
*/
package org.jgrapes.util;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.jgrapes.core.Channel;
import org.jgrapes.core.Component;
import org.jgrapes.core.ComponentFactory;
import org.jgrapes.core.Components;
import org.jgrapes.core.Event;
import org.jgrapes.core.Manager;
import org.jgrapes.core.annotation.Handler;
import org.jgrapes.util.events.ConfigurationUpdate;
/**
* Provides child components dynamically using {@link ComponentFactory}s.
*
* An instance is configured with a collection of {@link ComponentFactory}s
* (see {@link #setFactories(ComponentFactory...)}) and component
* configurations (see {@link #setPinned(List)} and
* {@link #onConfigurationUpdate(ConfigurationUpdate)}).
*
* For each configuration that references a known factory, a component is
* created and attached to this component provider as child.
*
* @since 1.3
*/
@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
public class ComponentProvider extends Component {
/** The entry name for the component's type. */
public static final String COMPONENT_TYPE = "componentType";
/** The entry name for the component's name. */
public static final String COMPONENT_NAME = "name";
private String componentsEntry = "components";
private Map factoryByType
= Collections.emptyMap();
private List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy