Search in sources :

Example 1 with BeanDeploymentArchiveServicesProvider

use of org.jboss.as.weld.spi.BeanDeploymentArchiveServicesProvider in project wildfly by wildfly.

the class ServiceLoaders method loadBeanDeploymentArchiveServices.

/**
     *
     * @param clazz
     * @param archive
     * @return
     */
public static Map<Class<? extends Service>, Service> loadBeanDeploymentArchiveServices(Class<?> clazz, BeanDeploymentArchive archive) {
    ServiceLoader<BeanDeploymentArchiveServicesProvider> serviceLoader = ServiceLoader.load(BeanDeploymentArchiveServicesProvider.class, WildFlySecurityManager.getClassLoaderPrivileged(clazz));
    List<Service> services = new ArrayList<>();
    for (BeanDeploymentArchiveServicesProvider provider : serviceLoader) {
        services.addAll(provider.getServices(archive));
    }
    Map<Class<? extends Service>, Service> servicesMap = new HashMap<>();
    for (Service service : services) {
        for (Class<? extends Service> serviceInterface : identifyServiceInterfaces(service.getClass(), new HashSet<>())) {
            servicesMap.put(serviceInterface, service);
        }
    }
    return servicesMap;
}
Also used : HashMap(java.util.HashMap) BeanDeploymentArchiveServicesProvider(org.jboss.as.weld.spi.BeanDeploymentArchiveServicesProvider) ArrayList(java.util.ArrayList) Service(org.jboss.weld.bootstrap.api.Service) BootstrapService(org.jboss.weld.bootstrap.api.BootstrapService)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 BeanDeploymentArchiveServicesProvider (org.jboss.as.weld.spi.BeanDeploymentArchiveServicesProvider)1 BootstrapService (org.jboss.weld.bootstrap.api.BootstrapService)1 Service (org.jboss.weld.bootstrap.api.Service)1