Search in sources :

Example 1 with ArtifactPluginDescriptorLoader

use of org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader in project mule by mulesoft.

the class TestDomainFactory method createDomainFactory.

public static TestDomainFactory createDomainFactory(DomainClassLoaderFactory domainClassLoaderFactory, ArtifactClassLoader containerClassLoader, ServiceRepository serviceRepository, ModuleRepository moduleRepository, DescriptorLoaderRepository descriptorLoaderRepository) {
    ArtifactPluginDescriptorFactory artifactPluginDescriptorFactory = new ArtifactPluginDescriptorFactory();
    ArtifactPluginDescriptorLoader artifactPluginDescriptorLoader = new ArtifactPluginDescriptorLoader(artifactPluginDescriptorFactory);
    DomainDescriptorFactory domainDescriptorFactory = new DomainDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
    final DefaultClassLoaderManager artifactClassLoaderManager = new DefaultClassLoaderManager();
    PluginDependenciesResolver pluginDependenciesResolver = new BundlePluginDependenciesResolver(artifactPluginDescriptorFactory);
    DomainClassLoaderBuilderFactory domainClassLoaderBuilderFactory = new DomainClassLoaderBuilderFactory(containerClassLoader, domainClassLoaderFactory, new DefaultRegionPluginClassLoadersFactory(new TrackingArtifactClassLoaderFactory<>(artifactClassLoaderManager, new ArtifactPluginClassLoaderFactory()), moduleRepository));
    return new TestDomainFactory(artifactClassLoaderManager, serviceRepository, domainDescriptorFactory, pluginDependenciesResolver, domainClassLoaderBuilderFactory, new MuleExtensionModelLoaderManager(containerClassLoader));
}
Also used : BundlePluginDependenciesResolver(org.mule.runtime.deployment.model.internal.plugin.BundlePluginDependenciesResolver) DefaultRegionPluginClassLoadersFactory(org.mule.runtime.deployment.model.internal.DefaultRegionPluginClassLoadersFactory) TrackingArtifactClassLoaderFactory(org.mule.runtime.module.artifact.api.classloader.TrackingArtifactClassLoaderFactory) ArtifactPluginClassLoaderFactory(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginClassLoaderFactory) ArtifactPluginDescriptorLoader(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader) DomainDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.domain.DomainDescriptorFactory) DomainClassLoaderBuilderFactory(org.mule.runtime.module.deployment.impl.internal.domain.DomainClassLoaderBuilderFactory) MuleExtensionModelLoaderManager(org.mule.runtime.module.deployment.impl.internal.plugin.MuleExtensionModelLoaderManager) ArtifactPluginDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory) DefaultClassLoaderManager(org.mule.runtime.module.deployment.impl.internal.artifact.DefaultClassLoaderManager) PluginDependenciesResolver(org.mule.runtime.deployment.model.internal.plugin.PluginDependenciesResolver) BundlePluginDependenciesResolver(org.mule.runtime.deployment.model.internal.plugin.BundlePluginDependenciesResolver)

Example 2 with ArtifactPluginDescriptorLoader

use of org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader in project mule by mulesoft.

the class PolicyTemplateDescriptorFactoryTestCase method readsPlugin.

@Test
public void readsPlugin() throws Exception {
    MulePolicyModelBuilder policyModelBuilder = new MulePolicyModelBuilder().setName(POLICY_NAME).setMinMuleVersion("4.0.0").setRequiredProduct(MULE).withBundleDescriptorLoader(createPolicyBundleDescriptorLoader(PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
    ArtifactPluginFileBuilder plugin1 = new ArtifactPluginFileBuilder("plugin1");
    ArtifactPluginFileBuilder plugin2 = new ArtifactPluginFileBuilder("plugin2");
    PolicyFileBuilder policyFileBuilder = new PolicyFileBuilder(POLICY_NAME).describedBy(policyModelBuilder.build()).dependingOn(plugin1).dependingOn(plugin2);
    File tempFolder = createTempFolder();
    unzip(policyFileBuilder.getArtifactFile(), tempFolder);
    final ArtifactPluginDescriptorFactory pluginDescriptorFactory = mock(ArtifactPluginDescriptorFactory.class);
    final PolicyTemplateDescriptorFactory policyTemplateDescriptorFactory = new PolicyTemplateDescriptorFactory(new ArtifactPluginDescriptorLoader(pluginDescriptorFactory), descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
    final ArtifactPluginDescriptor expectedPluginDescriptor1 = new ArtifactPluginDescriptor("plugin1");
    final ArtifactPluginDescriptor expectedPluginDescriptor2 = new ArtifactPluginDescriptor("plugin2");
    when(pluginDescriptorFactory.create(any(), any())).thenReturn(expectedPluginDescriptor1).thenReturn(expectedPluginDescriptor2);
    PolicyTemplateDescriptor descriptor = policyTemplateDescriptorFactory.create(tempFolder, empty());
    Set<ArtifactPluginDescriptor> plugins = descriptor.getPlugins();
    assertThat(plugins.size(), equalTo(2));
    assertThat(plugins, hasItem(equalTo(expectedPluginDescriptor1)));
    assertThat(plugins, hasItem(equalTo(expectedPluginDescriptor2)));
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) ArtifactPluginDescriptorLoader(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader) MulePolicyModelBuilder(org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder) ArtifactPluginDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory) PolicyTemplateDescriptor(org.mule.runtime.deployment.model.api.policy.PolicyTemplateDescriptor) File.createTempFile(java.io.File.createTempFile) FileUtils.toFile(org.apache.commons.io.FileUtils.toFile) File(java.io.File) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 3 with ArtifactPluginDescriptorLoader

use of org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader in project mule by mulesoft.

the class PropertyOverridesTestCase method testOverrides.

@Test
public void testOverrides() throws Exception {
    File tempProps = File.createTempFile("property", "overrides");
    InputStream input = getClass().getClassLoader().getResourceAsStream("overridden.properties");
    FileOutputStream output = new FileOutputStream(tempProps);
    copy(input, output);
    input.close();
    output.close();
    ApplicationDescriptor descriptor = new ApplicationDescriptor("app");
    ApplicationDescriptorFactory applicationDescriptorFactory = new ApplicationDescriptorFactory(new ArtifactPluginDescriptorLoader(new ArtifactPluginDescriptorFactory()), new ServiceRegistryDescriptorLoaderRepository(new SpiServiceRegistry()), ArtifactDescriptorValidatorBuilder.builder());
    applicationDescriptorFactory.setApplicationProperties(descriptor, tempProps);
    Map<String, String> appProps = descriptor.getAppProperties();
    assertEquals("state", appProps.get("texas"));
    assertEquals("country", appProps.get("peru"));
    assertEquals("austin", appProps.get("texas.capital"));
    assertEquals("4", appProps.get("peru.capital.numberOfletters"));
    assertEquals("runtime", appProps.get("mule"));
    assertEquals("ipaas", appProps.get("mule.ion"));
    try {
        setSystemProperties();
        descriptor = new ApplicationDescriptor("app");
        applicationDescriptorFactory.setApplicationProperties(descriptor, tempProps);
        appProps = descriptor.getAppProperties();
        assertEquals("state", appProps.get("texas"));
        assertEquals("nation", appProps.get("peru"));
        assertEquals("austin", appProps.get("texas.capital"));
        assertEquals("4", appProps.get("peru.capital.numberOfletters"));
        assertEquals("wayCool", appProps.get("mule"));
        assertEquals("ipaas", appProps.get("mule.ion"));
        assertEquals("evenCooler", appProps.get("mule.mmc"));
        descriptor = new ApplicationDescriptor("app");
        applicationDescriptorFactory.setApplicationProperties(descriptor, new File("nonexistent.nonexistent"));
        appProps = descriptor.getAppProperties();
        assertNull(appProps.get("texas"));
        assertEquals("nation", appProps.get("peru"));
        assertNull(appProps.get("texas.capital"));
        assertNull(appProps.get("peru.capital.numberOfletters"));
        assertEquals("wayCool", appProps.get("mule"));
        assertNull(appProps.get("mule.ion"));
        assertEquals("evenCooler", appProps.get("mule.mmc"));
    } finally {
        resetSystemProperties();
    }
}
Also used : InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) ArtifactPluginDescriptorLoader(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader) ArtifactPluginDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) File(java.io.File) ApplicationDescriptor(org.mule.runtime.deployment.model.api.application.ApplicationDescriptor) ServiceRegistryDescriptorLoaderRepository(org.mule.runtime.module.deployment.impl.internal.artifact.ServiceRegistryDescriptorLoaderRepository) Test(org.junit.Test)

Example 4 with ArtifactPluginDescriptorLoader

use of org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader in project mule by mulesoft.

the class TestApplicationFactory method createTestApplicationFactory.

public static TestApplicationFactory createTestApplicationFactory(MuleApplicationClassLoaderFactory applicationClassLoaderFactory, DomainManager domainManager, ServiceRepository serviceRepository, ExtensionModelLoaderRepository extensionModelLoaderRepository, ModuleRepository moduleRepository, DescriptorLoaderRepository descriptorLoaderRepository) {
    ArtifactPluginDescriptorFactory artifactPluginDescriptorFactory = new ArtifactPluginDescriptorFactory();
    ArtifactPluginDescriptorLoader artifactPluginDescriptorLoader = new ArtifactPluginDescriptorLoader(artifactPluginDescriptorFactory);
    ApplicationDescriptorFactory applicationDescriptorFactory = new ApplicationDescriptorFactory(artifactPluginDescriptorLoader, descriptorLoaderRepository, ArtifactDescriptorValidatorBuilder.builder());
    final DefaultClassLoaderManager artifactClassLoaderManager = new DefaultClassLoaderManager();
    PluginDependenciesResolver pluginDependenciesResolver = new BundlePluginDependenciesResolver(artifactPluginDescriptorFactory);
    ApplicationClassLoaderBuilderFactory applicationClassLoaderBuilderFactory = new ApplicationClassLoaderBuilderFactory(applicationClassLoaderFactory, new TrackingArtifactClassLoaderFactory<>(artifactClassLoaderManager, new ArtifactPluginClassLoaderFactory()), new DefaultRegionPluginClassLoadersFactory(new ArtifactPluginClassLoaderFactory(), moduleRepository));
    return new TestApplicationFactory(applicationClassLoaderBuilderFactory, applicationDescriptorFactory, domainManager, serviceRepository, extensionModelLoaderRepository, artifactClassLoaderManager, mock(PolicyTemplateClassLoaderBuilderFactory.class), pluginDependenciesResolver, artifactPluginDescriptorLoader);
}
Also used : BundlePluginDependenciesResolver(org.mule.runtime.deployment.model.internal.plugin.BundlePluginDependenciesResolver) PolicyTemplateClassLoaderBuilderFactory(org.mule.runtime.module.deployment.impl.internal.policy.PolicyTemplateClassLoaderBuilderFactory) DefaultRegionPluginClassLoadersFactory(org.mule.runtime.deployment.model.internal.DefaultRegionPluginClassLoadersFactory) ArtifactPluginClassLoaderFactory(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginClassLoaderFactory) ApplicationDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.application.ApplicationDescriptorFactory) ArtifactPluginDescriptorLoader(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader) ApplicationClassLoaderBuilderFactory(org.mule.runtime.module.deployment.impl.internal.application.ApplicationClassLoaderBuilderFactory) ArtifactPluginDescriptorFactory(org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory) DefaultClassLoaderManager(org.mule.runtime.module.deployment.impl.internal.artifact.DefaultClassLoaderManager) PluginDependenciesResolver(org.mule.runtime.deployment.model.internal.plugin.PluginDependenciesResolver) BundlePluginDependenciesResolver(org.mule.runtime.deployment.model.internal.plugin.BundlePluginDependenciesResolver)

Aggregations

ArtifactPluginDescriptorFactory (org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorFactory)4 ArtifactPluginDescriptorLoader (org.mule.runtime.module.deployment.impl.internal.plugin.ArtifactPluginDescriptorLoader)4 File (java.io.File)2 Test (org.junit.Test)2 ArtifactPluginClassLoaderFactory (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginClassLoaderFactory)2 DefaultRegionPluginClassLoadersFactory (org.mule.runtime.deployment.model.internal.DefaultRegionPluginClassLoadersFactory)2 BundlePluginDependenciesResolver (org.mule.runtime.deployment.model.internal.plugin.BundlePluginDependenciesResolver)2 PluginDependenciesResolver (org.mule.runtime.deployment.model.internal.plugin.PluginDependenciesResolver)2 DefaultClassLoaderManager (org.mule.runtime.module.deployment.impl.internal.artifact.DefaultClassLoaderManager)2 File.createTempFile (java.io.File.createTempFile)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 FileUtils.toFile (org.apache.commons.io.FileUtils.toFile)1 MuleArtifactLoaderDescriptor (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor)1 MulePolicyModelBuilder (org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder)1 SpiServiceRegistry (org.mule.runtime.core.api.registry.SpiServiceRegistry)1 ApplicationDescriptor (org.mule.runtime.deployment.model.api.application.ApplicationDescriptor)1 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)1 PolicyTemplateDescriptor (org.mule.runtime.deployment.model.api.policy.PolicyTemplateDescriptor)1 TrackingArtifactClassLoaderFactory (org.mule.runtime.module.artifact.api.classloader.TrackingArtifactClassLoaderFactory)1