Search in sources :

Example 1 with DomainClassLoaderBuilder

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

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

Example 3 with DomainClassLoaderBuilder

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

Aggregations

Domain (org.mule.runtime.deployment.model.api.domain.Domain)3 DomainClassLoaderBuilder (org.mule.runtime.deployment.model.internal.domain.DomainClassLoaderBuilder)3 File (java.io.File)2 Test (org.junit.Test)2 DomainDescriptor (org.mule.runtime.deployment.model.api.domain.DomainDescriptor)2 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)2 MuleApplicationClassLoader (org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoader)2 ArtifactPlugin (org.mule.runtime.deployment.model.api.plugin.ArtifactPlugin)1 MuleDeployableArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.MuleDeployableArtifactClassLoader)1 DefaultArtifactPlugin (org.mule.runtime.module.deployment.impl.internal.plugin.DefaultArtifactPlugin)1