Search in sources :

Example 1 with ContainerClassLoaderFilterFactory

use of org.mule.runtime.container.internal.ContainerClassLoaderFilterFactory in project mule by mulesoft.

the class IsolatedClassLoaderFactory method createContainerArtifactClassLoader.

/**
 * Creates an {@link ArtifactClassLoader} for the container. The difference between a mule container {@link ArtifactClassLoader}
 * in standalone mode and this one is that it has to be aware that the parent class loader has all the URLs loaded in launcher
 * app class loader so it has to create a particular look policy to resolve classes as CHILD_FIRST.
 * <p/>
 * In order to do that a {@link FilteringArtifactClassLoader} resolve is created with and empty look policy (meaning that
 * CHILD_FIRST strategy will be used) for the {@link URL}s that are going to be exposed from the container class loader. This
 * would be the parent class loader for the container so instead of going directly the launcher application class loader that
 * has access to the whole classpath this filtering class loader will resolve only the classes for the {@link URL}s defined to
 * be in the container.
 *
 * @param testContainerClassLoaderFactory {@link TestContainerClassLoaderFactory} that has the logic to create a container class
 *        loader
 * @param artifactsUrlClassification the classifications to get plugins {@link URL}s
 * @return an {@link ArtifactClassLoader} for the container
 */
protected ArtifactClassLoader createContainerArtifactClassLoader(TestContainerClassLoaderFactory testContainerClassLoaderFactory, ArtifactsUrlClassification artifactsUrlClassification) {
    MuleArtifactClassLoader launcherArtifact = createLauncherArtifactClassLoader();
    final List<MuleModule> muleModules = emptyList();
    ClassLoaderFilter filteredClassLoaderLauncher = new ContainerClassLoaderFilterFactory().create(testContainerClassLoaderFactory.getBootPackages(), muleModules);
    logClassLoaderUrls("CONTAINER", artifactsUrlClassification.getContainerUrls());
    ArtifactClassLoader containerClassLoader = testContainerClassLoaderFactory.createContainerClassLoader(new FilteringArtifactClassLoader(launcherArtifact, filteredClassLoaderLauncher, emptyList()));
    return containerClassLoader;
}
Also used : FilteringArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.FilteringArtifactClassLoader) ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) MuleArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.MuleArtifactClassLoader) DefaultArtifactClassLoaderFilter(org.mule.runtime.module.artifact.api.classloader.DefaultArtifactClassLoaderFilter) ClassLoaderFilter(org.mule.runtime.module.artifact.api.classloader.ClassLoaderFilter) ArtifactClassLoaderFilter(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoaderFilter) FilteringArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.FilteringArtifactClassLoader) MuleArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.MuleArtifactClassLoader) ContainerClassLoaderFilterFactory(org.mule.runtime.container.internal.ContainerClassLoaderFilterFactory) MuleModule(org.mule.runtime.container.api.MuleModule)

Aggregations

MuleModule (org.mule.runtime.container.api.MuleModule)1 ContainerClassLoaderFilterFactory (org.mule.runtime.container.internal.ContainerClassLoaderFilterFactory)1 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)1 ArtifactClassLoaderFilter (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoaderFilter)1 ClassLoaderFilter (org.mule.runtime.module.artifact.api.classloader.ClassLoaderFilter)1 DefaultArtifactClassLoaderFilter (org.mule.runtime.module.artifact.api.classloader.DefaultArtifactClassLoaderFilter)1 FilteringArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.FilteringArtifactClassLoader)1 MuleArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.MuleArtifactClassLoader)1