Search in sources :

Example 1 with ApplicationDescriptor

use of org.mule.runtime.deployment.model.api.application.ApplicationDescriptor in project mule by mulesoft.

the class MuleApplicationClassLoaderFactoryTestCase method createAppClassLoader.

@Before
public void createAppClassLoader() throws IOException {
    // Creates folder structure
    previousMuleHome = setProperty(MULE_HOME_DIRECTORY_PROPERTY, tempMuleHome.getRoot().getAbsolutePath());
    // Add jar file on application's lib folder
    File libDir = getAppLibFolder(APP_NAME);
    assertThat(libDir.mkdirs(), is(true));
    final File appLibrary = new File(libDir, "appLibrary.jar");
    stringToFile(appLibrary.getAbsolutePath(), "Some text");
    when(classLoaderLookupPolicy.getClassLookupStrategy(anyString())).thenReturn(PARENT_FIRST);
    when(parentArtifactClassLoader.getClassLoaderLookupPolicy()).thenReturn(classLoaderLookupPolicy);
    when(parentArtifactClassLoader.getClassLoader()).thenReturn(getClass().getClassLoader());
    when(classLoaderLookupPolicy.extend(anyMap())).thenReturn(classLoaderLookupPolicy);
    descriptor = new ApplicationDescriptor(APP_NAME);
    descriptor.setArtifactLocation(new File(tempMuleHome.newFolder(), APP_NAME));
}
Also used : File(java.io.File) FileUtils.stringToFile(org.mule.runtime.core.api.util.FileUtils.stringToFile) ApplicationDescriptor(org.mule.runtime.deployment.model.api.application.ApplicationDescriptor) Before(org.junit.Before)

Example 2 with ApplicationDescriptor

use of org.mule.runtime.deployment.model.api.application.ApplicationDescriptor in project mule by mulesoft.

the class ArtifactAwareContextSelectorTestCase method returnsMuleLoggerContextForInternalArtifactClassLoader.

@Test
public void returnsMuleLoggerContextForInternalArtifactClassLoader() {
    ArtifactClassLoader serviceClassLoader = new MuleArtifactClassLoader("test", new ApplicationDescriptor("test"), new URL[0], this.getClass().getClassLoader(), mock(ClassLoaderLookupPolicy.class));
    LoggerContext systemContext = selector.getContext("", this.getClass().getClassLoader(), true);
    LoggerContext serviceCtx = selector.getContext("", serviceClassLoader.getClassLoader(), true);
    assertThat(serviceCtx, instanceOf(MuleLoggerContext.class));
    assertThat(serviceCtx, sameInstance(systemContext));
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) MuleArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.MuleArtifactClassLoader) ClassLoaderLookupPolicy(org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy) MuleArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.MuleArtifactClassLoader) LoggerContext(org.apache.logging.log4j.core.LoggerContext) ApplicationDescriptor(org.mule.runtime.deployment.model.api.application.ApplicationDescriptor) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 3 with ApplicationDescriptor

use of org.mule.runtime.deployment.model.api.application.ApplicationDescriptor in project mule by mulesoft.

the class DefaultToolingService method doCreateApplication.

private Application doCreateApplication(File toolingApplicationContent, Optional<Properties> deploymentProperties) throws IOException {
    Optional<Properties> mergedDeploymentProperties = of(createDeploymentProperties(deploymentProperties));
    MuleApplicationModel.MuleApplicationModelBuilder applicationArtifactModelBuilder = applicationDescriptorFactory.createArtifactModelBuilder(toolingApplicationContent);
    String domainName = mergedDeploymentProperties.get().getProperty(DEPLOYMENT_DOMAIN_NAME_REF);
    if (domainName != null) {
        Domain domain = domainRepository.getDomain(domainName);
        if (domain == null) {
            throw new IllegalArgumentException(format("Domain '%s' is expected to be deployed", domainName));
        }
        MuleArtifactLoaderDescriptor classLoaderModelDescriptorLoader = applicationArtifactModelBuilder.getClassLoaderModelDescriptorLoader();
        Map<String, Object> extendedAttributes = new HashMap<>(classLoaderModelDescriptorLoader.getAttributes());
        extendedAttributes.put(CLASSLOADER_MODEL_MAVEN_REACTOR_RESOLVER, new DomainMavenReactorResolver(domain.getLocation(), domain.getDescriptor().getBundleDescriptor()));
        applicationArtifactModelBuilder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(classLoaderModelDescriptorLoader.getId(), extendedAttributes));
        ApplicationDescriptor applicationDescriptor = applicationDescriptorFactory.createArtifact(toolingApplicationContent, mergedDeploymentProperties, applicationArtifactModelBuilder.build());
        applicationDescriptor.setDomainName(domain.getArtifactName());
        return new ToolingApplicationWrapper(doCreateApplication(applicationDescriptor));
    }
    return new ToolingApplicationWrapper(doCreateApplication(applicationDescriptorFactory.create(toolingApplicationContent, mergedDeploymentProperties)));
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) HashMap(java.util.HashMap) Properties(java.util.Properties) ApplicationDescriptor(org.mule.runtime.deployment.model.api.application.ApplicationDescriptor) MuleApplicationModel(org.mule.runtime.api.deployment.meta.MuleApplicationModel) Domain(org.mule.runtime.deployment.model.api.domain.Domain)

Example 4 with ApplicationDescriptor

use of org.mule.runtime.deployment.model.api.application.ApplicationDescriptor in project mule by mulesoft.

the class DefaultApplicationFactory method doCreateArtifact.

@Override
protected Application doCreateArtifact(File artifactDir, Optional<Properties> properties) throws IOException {
    String appName = artifactDir.getName();
    if (appName.contains(" ")) {
        throw new IllegalArgumentException("Mule application name may not contain spaces: " + appName);
    }
    final ApplicationDescriptor descriptor = applicationDescriptorFactory.create(artifactDir, properties);
    return createArtifact(descriptor);
}
Also used : ApplicationDescriptor(org.mule.runtime.deployment.model.api.application.ApplicationDescriptor)

Example 5 with ApplicationDescriptor

use of org.mule.runtime.deployment.model.api.application.ApplicationDescriptor in project mule by mulesoft.

the class DefaultPolicyTemplateFactoryTestCase method createApplication.

private Application createApplication(RegionClassLoader regionClassLoader) {
    ApplicationDescriptor appDescriptor = mock(ApplicationDescriptor.class);
    when(appDescriptor.getPlugins()).thenReturn(emptySet());
    Application application = mock(Application.class);
    when(application.getRegionClassLoader()).thenReturn(regionClassLoader);
    when(application.getDescriptor()).thenReturn(appDescriptor);
    final Domain domain = mock(Domain.class);
    when(domain.getDescriptor()).thenReturn(new DomainDescriptor("testDomain"));
    when(application.getDomain()).thenReturn(domain);
    return application;
}
Also used : Domain(org.mule.runtime.deployment.model.api.domain.Domain) Application(org.mule.runtime.deployment.model.api.application.Application) DomainDescriptor(org.mule.runtime.deployment.model.api.domain.DomainDescriptor) ApplicationDescriptor(org.mule.runtime.deployment.model.api.application.ApplicationDescriptor)

Aggregations

ApplicationDescriptor (org.mule.runtime.deployment.model.api.application.ApplicationDescriptor)12 File (java.io.File)6 Test (org.junit.Test)5 Application (org.mule.runtime.deployment.model.api.application.Application)3 Domain (org.mule.runtime.deployment.model.api.domain.Domain)3 Before (org.junit.Before)2 DomainDescriptor (org.mule.runtime.deployment.model.api.domain.DomainDescriptor)2 MuleApplicationClassLoader (org.mule.runtime.deployment.model.internal.application.MuleApplicationClassLoader)2 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)2 ClassLoaderLookupPolicy (org.mule.runtime.module.artifact.api.classloader.ClassLoaderLookupPolicy)2 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1 LoggerContext (org.apache.logging.log4j.core.LoggerContext)1 MavenClientProvider (org.mule.maven.client.api.MavenClientProvider)1 MuleApplicationModel (org.mule.runtime.api.deployment.meta.MuleApplicationModel)1