use of org.mule.runtime.module.artifact.api.descriptor.LoaderNotFoundException 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;
}
use of org.mule.runtime.module.artifact.api.descriptor.LoaderNotFoundException in project mule by mulesoft.
the class PolicyTemplateDescriptorFactoryTestCase method setUp.
@Before
public void setUp() throws Exception {
when(descriptorLoaderRepository.get(FILE_SYSTEM_POLICY_MODEL_LOADER_ID, POLICY, ClassLoaderModelLoader.class)).thenReturn(new FileSystemPolicyClassLoaderModelLoader());
when(descriptorLoaderRepository.get(INVALID_LOADER_ID, POLICY, ClassLoaderModelLoader.class)).thenThrow(new LoaderNotFoundException(INVALID_LOADER_ID));
MavenClientProvider mavenClientProvider = MavenClientProvider.discoverProvider(currentThread().getContextClassLoader());
when(descriptorLoaderRepository.get(MULE_LOADER_ID, POLICY, ClassLoaderModelLoader.class)).thenReturn(new DeployableMavenClassLoaderModelLoader(mavenClientProvider.createMavenClient(newMavenConfigurationBuilder().localMavenRepositoryLocation(mavenClientProvider.getLocalRepositorySuppliers().environmentMavenRepositorySupplier().get()).build()), mavenClientProvider.getLocalRepositorySuppliers()));
when(descriptorLoaderRepository.get(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID, POLICY, BundleDescriptorLoader.class)).thenReturn(new PropertiesBundleDescriptorLoader());
when(descriptorLoaderRepository.get(INVALID_LOADER_ID, POLICY, BundleDescriptorLoader.class)).thenThrow(new LoaderNotFoundException(INVALID_LOADER_ID));
}
use of org.mule.runtime.module.artifact.api.descriptor.LoaderNotFoundException in project mule by mulesoft.
the class ArtifactPluginDescriptorFactoryTestCase method setUp.
@Before
public void setUp() throws Exception {
when(classLoaderFilterFactory.create(null, null)).thenReturn(NULL_CLASSLOADER_FILTER);
when(descriptorLoaderRepository.get(MULE_LOADER_ID, PLUGIN, ClassLoaderModelLoader.class)).thenReturn(new PluginMavenClassLoaderModelLoader(mavenClientProvider.createMavenClient(newMavenConfigurationBuilder().localMavenRepositoryLocation(mavenClientProvider.getLocalRepositorySuppliers().environmentMavenRepositorySupplier().get()).build()), mavenClientProvider.getLocalRepositorySuppliers()));
when(descriptorLoaderRepository.get(FILE_SYSTEM_POLICY_MODEL_LOADER_ID, PLUGIN, ClassLoaderModelLoader.class)).thenReturn(new FileSystemPolicyClassLoaderModelLoader());
when(descriptorLoaderRepository.get(INVALID_LOADER_ID, PLUGIN, ClassLoaderModelLoader.class)).thenThrow(new LoaderNotFoundException(INVALID_LOADER_ID));
when(descriptorLoaderRepository.get(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID, PLUGIN, BundleDescriptorLoader.class)).thenReturn(new PropertiesBundleDescriptorLoader());
when(descriptorLoaderRepository.get(INVALID_LOADER_ID, PLUGIN, BundleDescriptorLoader.class)).thenThrow(new LoaderNotFoundException(INVALID_LOADER_ID));
descriptorFactory = new ArtifactPluginDescriptorFactory(descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
}
Aggregations