Search in sources :

Example 1 with DescriptorLoader

use of org.mule.runtime.module.artifact.api.descriptor.DescriptorLoader in project mule by mulesoft.

the class ServiceRegistryDescriptorLoaderRepository method findBundleDescriptorLoaders.

private List<DescriptorLoader> findBundleDescriptorLoaders(Class<? extends DescriptorLoader> descriptorLoaderClass) {
    List<DescriptorLoader> descriptorLoaders = new ArrayList<>();
    Collection<? extends DescriptorLoader> providers = serviceRegistry.lookupProviders(descriptorLoaderClass, this.getClass().getClassLoader());
    for (DescriptorLoader loader : providers) {
        descriptorLoaders.add(loader);
    }
    return descriptorLoaders;
}
Also used : ArrayList(java.util.ArrayList) BundleDescriptorLoader(org.mule.runtime.module.artifact.api.descriptor.BundleDescriptorLoader) DescriptorLoader(org.mule.runtime.module.artifact.api.descriptor.DescriptorLoader)

Example 2 with DescriptorLoader

use of org.mule.runtime.module.artifact.api.descriptor.DescriptorLoader in project mule by mulesoft.

the class ServiceRegistryDescriptorLoaderRepository method get.

@Override
public synchronized <T extends DescriptorLoader> T get(String id, ArtifactType artifactType, Class<T> loaderClass) throws LoaderNotFoundException {
    if (descriptorLoaders == null) {
        initializeDescriptorLoaders();
    }
    DescriptorLoader descriptorLoader = null;
    List<DescriptorLoader> registeredDescriptorLoaders = descriptorLoaders.get(loaderClass);
    if (registeredDescriptorLoaders != null) {
        for (DescriptorLoader loader : registeredDescriptorLoaders) {
            if (loader.getId().equals(id) && loader.supportsArtifactType(artifactType)) {
                descriptorLoader = loader;
            }
        }
    }
    if (descriptorLoader == null) {
        throw new LoaderNotFoundException(noRegisteredLoaderError(id, loaderClass));
    }
    return (T) descriptorLoader;
}
Also used : LoaderNotFoundException(org.mule.runtime.module.artifact.api.descriptor.LoaderNotFoundException) BundleDescriptorLoader(org.mule.runtime.module.artifact.api.descriptor.BundleDescriptorLoader) DescriptorLoader(org.mule.runtime.module.artifact.api.descriptor.DescriptorLoader)

Aggregations

BundleDescriptorLoader (org.mule.runtime.module.artifact.api.descriptor.BundleDescriptorLoader)2 DescriptorLoader (org.mule.runtime.module.artifact.api.descriptor.DescriptorLoader)2 ArrayList (java.util.ArrayList)1 LoaderNotFoundException (org.mule.runtime.module.artifact.api.descriptor.LoaderNotFoundException)1