use of org.mule.runtime.api.deployment.persistence.MuleDomainModelJsonSerializer in project mule by mulesoft.
the class DomainFileBuilder method createDomainJsonDescriptorFile.
private File createDomainJsonDescriptorFile(Optional<Boolean> redeploymentEnabled, Optional<String> configResources, Optional<String> exportedResources) {
File domainDescriptor = new File(getTempFolder(), getArtifactId() + "domain.json");
domainDescriptor.deleteOnExit();
MuleDomainModel.MuleDomainModelBuilder muleDomainModelBuilder = new MuleDomainModel.MuleDomainModelBuilder();
muleDomainModelBuilder.setName(getArtifactId()).setMinMuleVersion("4.0.0").setRequiredProduct(MULE);
redeploymentEnabled.ifPresent(muleDomainModelBuilder::setRedeploymentEnabled);
configResources.ifPresent(configs -> {
String[] configFiles = configs.split(",");
muleDomainModelBuilder.setConfigs(new HashSet<>(asList(configFiles)));
});
MuleArtifactLoaderDescriptorBuilder muleArtifactClassLoaderDescriptorBuilder = new MuleArtifactLoaderDescriptorBuilder().setId(MULE_LOADER_ID);
exportedResources.ifPresent(resources -> {
muleArtifactClassLoaderDescriptorBuilder.addProperty(EXPORTED_RESOURCES, resources.split(","));
});
muleDomainModelBuilder.withClassLoaderModelDescriptorLoader(muleArtifactClassLoaderDescriptorBuilder.build());
muleDomainModelBuilder.withBundleDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
String applicationDescriptorContent = new MuleDomainModelJsonSerializer().serialize(muleDomainModelBuilder.build());
try (FileWriter fileWriter = new FileWriter(domainDescriptor)) {
fileWriter.write(applicationDescriptorContent);
} catch (IOException e) {
throw new MuleRuntimeException(e);
}
return domainDescriptor;
}
Aggregations