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));
}
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));
}
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)));
}
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);
}
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;
}
Aggregations