All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bridge.service.component.ComponentFactorySelector Maven / Gradle / Ivy

Go to download

Jadex bridge is a base package for kernels and platforms, i.e. it is used by both and provides commonly used interfaces and classes for active components and their management.

The newest version!
package jadex.bridge.service.component;

import jadex.bridge.FactoryFilter;
import jadex.bridge.IResourceIdentifier;
import jadex.bridge.service.IService;
import jadex.bridge.service.search.BasicResultSelector;
import jadex.bridge.service.types.factory.IComponentFactory;

import java.util.Collection;
import java.util.Map;

/**
 *  Result selector for finding a component factory. 
 */
public class ComponentFactorySelector extends BasicResultSelector
{	
	//-------- constructors --------
	
	/**
	 *  Find a matching component factory.
	 *  @param model	The model to be loaded.
	 *  @param imports	The imports (if any).
	 *  @param classloader	The class loader (if any).
	 */
	public ComponentFactorySelector(String model, String[] imports, IResourceIdentifier rid)
	{
		super(new FactoryFilter(model, imports, rid));
	}
	
	/**
	 *  Find a component factory for loading a specific component type.
	 *  @param type	The component type.
	 */
	public ComponentFactorySelector(String type)
	{
		super(new FactoryFilter(type));
	}
	
	//-------- IResultSelector interface --------
	
	/**
	 *  Get all services of the map as linear collection.
	 */
	public IService[] generateServiceArray(Map, Collection> servicemap)
	{
		Collection tmp = servicemap.get(IComponentFactory.class);
		return tmp==null? IService.EMPTY_SERVICES: (IService[])tmp.toArray(new IService[tmp.size()]);
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy