use of org.mule.runtime.deployment.model.api.domain.DomainDescriptor 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.api.domain.DomainDescriptor 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.deployment.model.api.domain.DomainDescriptor in project mule by mulesoft.
the class DomainClassLoaderFactoryTestCase method validateDomainBeforeCreatingClassLoader.
@Test(expected = DeploymentException.class)
public void validateDomainBeforeCreatingClassLoader() {
DomainDescriptor descriptor = getTestDescriptor("someDomain");
descriptor.setRootFolder(new File("unexistent"));
new DomainClassLoaderFactory(getClass().getClassLoader()).create(null, containerClassLoader, descriptor, emptyList());
}
use of org.mule.runtime.deployment.model.api.domain.DomainDescriptor 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.deployment.model.api.domain.DomainDescriptor in project mule by mulesoft.
the class DefaultApplicationFactoryTestCase method createDomain.
private Domain createDomain(String name) {
final Domain domain = mock(Domain.class);
final ArtifactClassLoader domainArtifactClassLoader = mock(ArtifactClassLoader.class);
when(domainArtifactClassLoader.getClassLoader()).thenReturn(mock(ClassLoader.class));
final ClassLoaderLookupPolicy domainLookupPolicy = mock(ClassLoaderLookupPolicy.class);
when(domainArtifactClassLoader.getClassLoaderLookupPolicy()).thenReturn(domainLookupPolicy);
when(domainRepository.getDomain(DOMAIN_ARTIFACT_FILE_NAME)).thenReturn(domain);
when(domain.getArtifactClassLoader()).thenReturn(domainArtifactClassLoader);
when(domain.getDescriptor()).thenReturn(new DomainDescriptor(name));
return domain;
}
Aggregations