Search in sources :

Example 1 with ArtifactDescriptor

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

the class TrackingDeployableArtifactClassLoaderFactoryTestCase method setUp.

@Before
public void setUp() throws Exception {
    artifactClassLoaderManager = mock(ArtifactClassLoaderManager.class);
    delegateFactory = mock(DeployableArtifactClassLoaderFactory.class);
    factory = new TrackingDeployableArtifactClassLoaderFactory<>(artifactClassLoaderManager, delegateFactory);
    parent = mock(ArtifactClassLoader.class);
    descriptor = new ArtifactDescriptor(ARTIFACT_NAME);
    artifactPluginClassLoaders = emptyList();
    ClassLoaderLookupPolicy lookupPolicy = mock(ClassLoaderLookupPolicy.class);
    classLoader = new MuleArtifactClassLoader(ARTIFACT_NAME, descriptor, new URL[0], getClass().getClassLoader(), lookupPolicy);
    when(lookupPolicy.getClassLookupStrategy(any())).thenReturn(PARENT_FIRST);
    when(delegateFactory.create(ARTIFACT_ID, parent, descriptor, artifactPluginClassLoaders)).thenReturn(classLoader);
}
Also used : ArtifactDescriptor(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor) URL(java.net.URL) Before(org.junit.Before)

Example 2 with ArtifactDescriptor

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

the class ContainerClassLoaderFactory method createContainerClassLoader.

/**
 * Creates the classLoader to represent the Mule container.
 *
 * @param parentClassLoader parent classLoader. Can be null.
 * @return a non null {@link ArtifactClassLoader} containing container code that can be used as parent classloader for other
 *         mule artifacts.
 */
public ArtifactClassLoader createContainerClassLoader(final ClassLoader parentClassLoader) {
    final List<MuleModule> muleModules = moduleRepository.getModules();
    final ClassLoaderLookupPolicy containerLookupPolicy = getContainerClassLoaderLookupPolicy(parentClassLoader, muleModules);
    return createArtifactClassLoader(parentClassLoader, muleModules, containerLookupPolicy, new ArtifactDescriptor("mule"));
}
Also used : ArtifactDescriptor(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor) ClassLoaderLookupPolicy(org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy) MuleModule(org.mule.runtime.container.api.MuleModule)

Example 3 with ArtifactDescriptor

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

the class MuleSharedDomainClassLoaderTestCase method findResourcesInProvidedUrls.

@Test
public void findResourcesInProvidedUrls() throws Exception {
    createDomainFolder(DEFAULT_DOMAIN_NAME);
    final File resourceFile = createDomainResource(DEFAULT_DOMAIN_NAME, RESOURCE_FILE_NAME);
    final List<URL> urls = Collections.singletonList(resourceFile.toURI().toURL());
    MuleSharedDomainClassLoader classLoader = new MuleSharedDomainClassLoader(new ArtifactDescriptor(DEFAULT_DOMAIN_NAME), getClass().getClassLoader(), lookupPolicy, urls, emptyList());
    assertThat(classLoader.findResource(RESOURCE_FILE_NAME), notNullValue());
}
Also used : ArtifactDescriptor(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor) File(java.io.File) URL(java.net.URL) SmallTest(org.mule.tck.size.SmallTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with ArtifactDescriptor

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

the class AbstractToolingClassLoaderTestCase method createAppClassLoader.

@Before
public void createAppClassLoader() {
    final ClassLoaderLookupPolicy classLoaderLookupPolicy = mock(ClassLoaderLookupPolicy.class);
    // Mandatory to find a resource releaser instance when doing the dispose of a RegionClassLoader
    when(classLoaderLookupPolicy.getClassLookupStrategy(anyString())).thenReturn(PARENT_FIRST);
    regionClassLoader = new RegionClassLoader(TEST_REGION, new ArtifactDescriptor(REGION_NAME), getClass().getClassLoader(), classLoaderLookupPolicy);
    // Loading the additional classloader as the ToolingPluginClassLoaderBuilder does
    regionClassLoader.addClassLoader(mock(ArtifactClassLoader.class), mock(ArtifactClassLoaderFilter.class));
    artifactPluginDescriptor = new ArtifactPluginDescriptor(PLUGIN_NAME);
    pluginArtifactClassLoader = spy(new TestToolingPluginClassLoader(artifactPluginDescriptor));
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) TestArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.TestArtifactClassLoader) ArtifactDescriptor(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor) ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) ClassLoaderLookupPolicy(org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy) RegionClassLoader(org.mule.runtime.module.artifact.api.classloader.RegionClassLoader) ArtifactClassLoaderFilter(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoaderFilter) Before(org.junit.Before)

Example 5 with ArtifactDescriptor

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

the class LoggerContextConfigurer method shouldConfigureContext.

public boolean shouldConfigureContext(MuleLoggerContext context) {
    if (!context.isApplicationClassloader()) {
        return true;
    }
    ArtifactDescriptor descriptor = context.getArtifactDescriptor();
    if (descriptor == null || !descriptor.getDeploymentProperties().isPresent()) {
        return true;
    }
    Properties properties = descriptor.getDeploymentProperties().get();
    return !parseBoolean(properties.getProperty(MULE_MUTE_APP_LOGS_DEPLOYMENT_PROPERTY, "false"));
}
Also used : ArtifactDescriptor(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor) Properties(java.util.Properties)

Aggregations

ArtifactDescriptor (org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor)15 URL (java.net.URL)8 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)5 ClassLoaderLookupPolicy (org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy)5 MuleArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.MuleArtifactClassLoader)5 RegionClassLoader (org.mule.runtime.module.artifact.api.classloader.RegionClassLoader)4 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 MuleModule (org.mule.runtime.container.api.MuleModule)3 MuleClassLoaderLookupPolicy (org.mule.runtime.container.internal.MuleClassLoaderLookupPolicy)3 ArtifactClassLoaderFilter (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoaderFilter)3 FilteringArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.FilteringArtifactClassLoader)3 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 Test (org.junit.Test)2 ContainerClassLoaderFactory (org.mule.runtime.container.internal.ContainerClassLoaderFactory)2 ContainerOnlyLookupStrategy (org.mule.runtime.container.internal.ContainerOnlyLookupStrategy)2 DefaultModuleRepository (org.mule.runtime.container.internal.DefaultModuleRepository)2