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