use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class DomainClassLoaderFactoryTestCase method createClassLoaderUsingCustomDomain.
@Test
public void createClassLoaderUsingCustomDomain() {
final String domainName = "custom-domain";
final String artifactId = getDomainId(domainName);
DomainDescriptor descriptor = getTestDescriptor(domainName);
descriptor.setRootFolder(createDomainDir(MULE_DOMAIN_FOLDER, domainName));
final ArtifactClassLoader domainClassLoader = new DomainClassLoaderFactory(getClass().getClassLoader()).create(null, containerClassLoader, descriptor, emptyList());
assertThat(domainClassLoader.getClassLoader(), instanceOf(MuleSharedDomainClassLoader.class));
assertThat(domainClassLoader.getArtifactId(), equalTo(artifactId));
}
use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class DomainClassLoaderFactoryTestCase method createClassLoaderFromDomainDescriptor.
@Test
public void createClassLoaderFromDomainDescriptor() {
final String domainName = "descriptor-domain";
final String artifactId = getDomainId(domainName);
DomainDescriptor descriptor = getTestDescriptor(domainName);
descriptor.setRootFolder(createDomainDir(MULE_DOMAIN_FOLDER, domainName));
ArtifactClassLoader domainClassLoader = new DomainClassLoaderFactory(getClass().getClassLoader()).create(null, containerClassLoader, descriptor, emptyList());
assertThat(domainClassLoader.getClassLoader(), instanceOf(MuleSharedDomainClassLoader.class));
assertThat(domainClassLoader.getArtifactId(), equalTo(artifactId));
}
use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class PolicyTemplateClassLoaderFactoryTestCase method createsClassLoaderWithPlugins.
@Test
public void createsClassLoaderWithPlugins() throws Exception {
ArtifactClassLoader pluginClassLoader1 = mock(ArtifactClassLoader.class);
ArtifactClassLoader pluginClassLoader2 = mock(ArtifactClassLoader.class);
List<ArtifactClassLoader> artifactPluginClassLoaders = new ArrayList<>();
artifactPluginClassLoaders.add(pluginClassLoader1);
artifactPluginClassLoaders.add(pluginClassLoader2);
final ArtifactClassLoader artifactClassLoader = factory.create(POLICY_ID, parentClassLoader, descriptor, artifactPluginClassLoaders);
final MuleDeployableArtifactClassLoader classLoader = (MuleDeployableArtifactClassLoader) artifactClassLoader.getClassLoader();
assertThat(classLoader.getArtifactPluginClassLoaders(), contains(pluginClassLoader1, pluginClassLoader2));
}
use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class ToolingApplicationClassLoaderBuilder method build.
/**
* Creates a new {@code ArtifactClassLoader} using the provided configuration. It will create the proper class loader hierarchy
* and filters so application classes, resources, plugins and it's domain resources are resolve correctly.
*
* @return a {@code MuleDeployableArtifactClassLoader} created from the provided configuration.
* @throws IOException exception cause when it was not possible to access the file provided as dependencies
*/
public ToolingArtifactClassLoader build() throws IOException {
ArtifactClassLoader ownerArtifactClassLoader = super.build();
ClassLoader parent = ownerArtifactClassLoader.getClassLoader().getParent();
if (!(parent instanceof RegionClassLoader)) {
throw new DeploymentException(createStaticMessage(format("The parent of the current owner must be of type '%s' but found '%s'", RegionClassLoader.class.getName(), parent.getClass().getName())));
}
final RegionClassLoader regionClassLoader = (RegionClassLoader) parent;
return new ToolingArtifactClassLoader(regionClassLoader, ownerArtifactClassLoader);
}
use of org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader in project mule by mulesoft.
the class ToolingDomainClassLoaderBuilder method build.
/**
* Creates a new {@code ArtifactClassLoader} using the provided configuration. It will create the proper class loader hierarchy
* and filters so domain classes, resources and plugins are resolve correctly.
*
* @return a {@code MuleDeployableArtifactClassLoader} created from the provided configuration.
* @throws IOException exception cause when it was not possible to access the file provided as dependencies
*/
public ToolingArtifactClassLoader build() throws IOException {
ArtifactClassLoader domainClassLoader = super.build();
ClassLoader parent = domainClassLoader.getClassLoader().getParent();
if (!(parent instanceof RegionClassLoader)) {
throw new DeploymentException(createStaticMessage(format("The parent of the current owner must be of type '%s' but found '%s'", RegionClassLoader.class.getName(), parent.getClass().getName())));
}
final RegionClassLoader regionClassLoader = (RegionClassLoader) parent;
return new ToolingArtifactClassLoader(regionClassLoader, domainClassLoader);
}
Aggregations