use of org.mule.runtime.deployment.model.internal.domain.DomainClassLoaderBuilder in project mule by mulesoft.
the class DefaultDomainFactory method doCreateArtifact.
@Override
protected Domain doCreateArtifact(File domainLocation, Optional<Properties> deploymentProperties) throws IOException {
String domainName = domainLocation.getName();
Domain domain = domainManager.getDomain(domainName);
if (domain != null) {
throw new IllegalArgumentException(format("Domain '%s' already exists", domainName));
}
if (domainName.contains(" ")) {
throw new IllegalArgumentException("Mule domain name may not contain spaces: " + domainName);
}
DomainDescriptor domainDescriptor = findDomain(domainName, domainLocation, deploymentProperties);
List<ArtifactPluginDescriptor> resolvedArtifactPluginDescriptors = pluginDependenciesResolver.resolve(emptySet(), domainDescriptor.getPlugins().stream().collect(toList()));
DomainClassLoaderBuilder artifactClassLoaderBuilder = domainClassLoaderBuilderFactory.createArtifactClassLoaderBuilder();
MuleDeployableArtifactClassLoader domainClassLoader = artifactClassLoaderBuilder.addArtifactPluginDescriptors(resolvedArtifactPluginDescriptors.toArray(new ArtifactPluginDescriptor[resolvedArtifactPluginDescriptors.size()])).setArtifactId(domainDescriptor.getName()).setArtifactDescriptor(domainDescriptor).build();
List<ArtifactPlugin> artifactPlugins = createArtifactPluginList(domainClassLoader, resolvedArtifactPluginDescriptors);
DefaultMuleDomain defaultMuleDomain = new DefaultMuleDomain(domainDescriptor, domainClassLoader, classLoaderRepository, serviceRepository, artifactPlugins, extensionModelLoaderManager);
DomainWrapper domainWrapper = new DomainWrapper(defaultMuleDomain, this);
domainManager.addDomain(domainWrapper);
return domainWrapper;
}
use of org.mule.runtime.deployment.model.internal.domain.DomainClassLoaderBuilder in project mule by mulesoft.
the class DefaultDomainFactoryTestCase method createDefaultDomain.
@Test
public void createDefaultDomain() throws IOException {
final MuleApplicationClassLoader domainArtifactClassLoader = mock(MuleApplicationClassLoader.class);
when(domainArtifactClassLoader.getArtifactId()).thenReturn(DEFAULT_DOMAIN_NAME);
DomainClassLoaderBuilder domainClassLoaderBuilderMock = mock(DomainClassLoaderBuilder.class);
when(domainClassLoaderBuilderMock.setArtifactDescriptor(any())).thenReturn(domainClassLoaderBuilderMock);
when(domainClassLoaderBuilderMock.setArtifactId(any())).thenReturn(domainClassLoaderBuilderMock);
when(domainClassLoaderBuilderMock.addArtifactPluginDescriptors(new ArtifactPluginDescriptor[0])).thenReturn(domainClassLoaderBuilderMock);
when(domainClassLoaderBuilderMock.build()).thenReturn(domainArtifactClassLoader);
when(domainClassLoaderBuilderFactory.createArtifactClassLoaderBuilder()).thenReturn(domainClassLoaderBuilderMock);
Domain domain = domainFactory.createArtifact(new File(DEFAULT_DOMAIN_NAME), empty());
assertThat(domain.getArtifactName(), is(DEFAULT_DOMAIN_NAME));
assertThat(domain.getDescriptor(), instanceOf(EmptyDomainDescriptor.class));
assertThat(domain.getArtifactClassLoader(), is(domainArtifactClassLoader));
}
use of org.mule.runtime.deployment.model.internal.domain.DomainClassLoaderBuilder in project mule by mulesoft.
the class DefaultDomainFactoryTestCase method createCustomDomain.
@Test
public void createCustomDomain() throws IOException {
String domainName = "custom-domain";
final DomainDescriptor descriptor = new DomainDescriptor(domainName);
when(domainDescriptorFactory.create(any(), any())).thenReturn(descriptor);
final MuleApplicationClassLoader domainArtifactClassLoader = mock(MuleApplicationClassLoader.class);
when(domainArtifactClassLoader.getArtifactId()).thenReturn(domainName);
DomainClassLoaderBuilder domainClassLoaderBuilderMock = mock(DomainClassLoaderBuilder.class);
when(domainClassLoaderBuilderMock.setArtifactDescriptor(any())).thenReturn(domainClassLoaderBuilderMock);
when(domainClassLoaderBuilderMock.setArtifactId(any())).thenReturn(domainClassLoaderBuilderMock);
when(domainClassLoaderBuilderMock.addArtifactPluginDescriptors(descriptor.getPlugins().toArray(new ArtifactPluginDescriptor[0]))).thenReturn(domainClassLoaderBuilderMock);
when(domainClassLoaderBuilderMock.build()).thenReturn(domainArtifactClassLoader);
when(domainClassLoaderBuilderFactory.createArtifactClassLoaderBuilder()).thenReturn(domainClassLoaderBuilderMock);
Domain domain = domainFactory.createArtifact(new File(domainName), empty());
assertThat(domain.getArtifactName(), is(domainName));
assertThat(domain.getDescriptor(), is(descriptor));
assertThat(domain.getArtifactClassLoader(), is(domainArtifactClassLoader));
}
Aggregations