Search in sources :

Example 1 with DomainDescriptor

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;
}
Also used : ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) MuleDeployableArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.MuleDeployableArtifactClassLoader) DomainClassLoaderBuilder(org.mule.runtime.deployment.model.internal.domain.DomainClassLoaderBuilder) Domain(org.mule.runtime.deployment.model.api.domain.Domain) DomainDescriptor(org.mule.runtime.deployment.model.api.domain.DomainDescriptor) DefaultArtifactPlugin(org.mule.runtime.module.deployment.impl.internal.plugin.DefaultArtifactPlugin) ArtifactPlugin(org.mule.runtime.deployment.model.api.plugin.ArtifactPlugin)

Example 2 with DomainDescriptor

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));
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) DomainDescriptor(org.mule.runtime.deployment.model.api.domain.DomainDescriptor) Test(org.junit.Test)

Example 3 with DomainDescriptor

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());
}
Also used : DomainDescriptor(org.mule.runtime.deployment.model.api.domain.DomainDescriptor) File(java.io.File) Test(org.junit.Test)

Example 4 with DomainDescriptor

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));
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) DomainDescriptor(org.mule.runtime.deployment.model.api.domain.DomainDescriptor) Test(org.junit.Test)

Example 5 with DomainDescriptor

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;
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) ClassLoaderLookupPolicy(org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy) ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) MuleApplicationClassLoader(org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoader) Domain(org.mule.runtime.deployment.model.api.domain.Domain) DomainDescriptor(org.mule.runtime.deployment.model.api.domain.DomainDescriptor)

Aggregations

DomainDescriptor (org.mule.runtime.deployment.model.api.domain.DomainDescriptor)12 Test (org.junit.Test)5 Domain (org.mule.runtime.deployment.model.api.domain.Domain)4 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)4 File (java.io.File)3 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)3 HashMap (java.util.HashMap)2 ApplicationDescriptor (org.mule.runtime.deployment.model.api.application.ApplicationDescriptor)2 MuleApplicationClassLoader (org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoader)2 DomainClassLoaderBuilder (org.mule.runtime.deployment.model.internal.domain.DomainClassLoaderBuilder)2 LookupStrategy (org.mule.runtime.module.artifact.api.classloader.LookupStrategy)2 URL (java.net.URL)1 LinkedList (java.util.LinkedList)1 Before (org.junit.Before)1 Application (org.mule.runtime.deployment.model.api.application.Application)1 ArtifactPlugin (org.mule.runtime.deployment.model.api.plugin.ArtifactPlugin)1 MuleSharedDomainClassLoader (org.mule.runtime.deployment.model.internal.domain.MuleSharedDomainClassLoader)1 ClassLoaderLookupPolicy (org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy)1 MuleDeployableArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.MuleDeployableArtifactClassLoader)1 ClassLoaderModel (org.mule.runtime.module.artifact.api.descriptor.ClassLoaderModel)1