Search in sources :

Example 1 with LoaderNotFoundException

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;
}
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)

Example 2 with LoaderNotFoundException

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));
}
Also used : DeployableMavenClassLoaderModelLoader(org.mule.runtime.module.deployment.impl.internal.application.DeployableMavenClassLoaderModelLoader) LoaderNotFoundException(org.mule.runtime.module.artifact.api.descriptor.LoaderNotFoundException) MavenClientProvider(org.mule.maven.client.api.MavenClientProvider) Before(org.junit.Before)

Example 3 with LoaderNotFoundException

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());
}
Also used : PropertiesBundleDescriptorLoader(org.mule.runtime.module.deployment.impl.internal.policy.PropertiesBundleDescriptorLoader) FileSystemPolicyClassLoaderModelLoader(org.mule.runtime.module.deployment.impl.internal.policy.FileSystemPolicyClassLoaderModelLoader) LoaderNotFoundException(org.mule.runtime.module.artifact.api.descriptor.LoaderNotFoundException) Before(org.junit.Before)

Aggregations

LoaderNotFoundException (org.mule.runtime.module.artifact.api.descriptor.LoaderNotFoundException)3 Before (org.junit.Before)2 MavenClientProvider (org.mule.maven.client.api.MavenClientProvider)1 BundleDescriptorLoader (org.mule.runtime.module.artifact.api.descriptor.BundleDescriptorLoader)1 DescriptorLoader (org.mule.runtime.module.artifact.api.descriptor.DescriptorLoader)1 DeployableMavenClassLoaderModelLoader (org.mule.runtime.module.deployment.impl.internal.application.DeployableMavenClassLoaderModelLoader)1 FileSystemPolicyClassLoaderModelLoader (org.mule.runtime.module.deployment.impl.internal.policy.FileSystemPolicyClassLoaderModelLoader)1 PropertiesBundleDescriptorLoader (org.mule.runtime.module.deployment.impl.internal.policy.PropertiesBundleDescriptorLoader)1