use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder in project mule by mulesoft.
the class ArtifactPluginFileBuilder method getCustomResources.
@Override
protected List<ZipResource> getCustomResources() {
final List<ZipResource> customResources = new LinkedList<>();
if (!properties.isEmpty()) {
final MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder();
builder.setName(getArtifactId()).setMinMuleVersion("4.0.0").setRequiredProduct(MULE);
MuleArtifactLoaderDescriptorBuilder classLoaderModelDescriptorBuilder = new MuleArtifactLoaderDescriptorBuilder().setId(MULE_LOADER_ID);
if (properties.containsKey(EXPORTED_CLASS_PACKAGES_PROPERTY)) {
classLoaderModelDescriptorBuilder.addProperty(EXPORTED_PACKAGES, ((String) properties.get(EXPORTED_CLASS_PACKAGES_PROPERTY)).split(","));
}
if (properties.containsKey(PRIVILEGED_EXPORTED_CLASS_PACKAGES_PROPERTY)) {
classLoaderModelDescriptorBuilder.addProperty(PRIVILEGED_EXPORTED_PACKAGES, ((String) properties.get(PRIVILEGED_EXPORTED_CLASS_PACKAGES_PROPERTY)).split(","));
}
if (properties.containsKey(PRIVILEGED_ARTIFACTS_PROPERTY)) {
classLoaderModelDescriptorBuilder.addProperty(PRIVILEGED_ARTIFACTS_IDS, ((String) properties.get(PRIVILEGED_ARTIFACTS_PROPERTY)).split(","));
}
if (properties.containsKey(EXPORTED_RESOURCE_PROPERTY)) {
classLoaderModelDescriptorBuilder.addProperty(EXPORTED_RESOURCES, ((String) properties.get(EXPORTED_RESOURCE_PROPERTY)).split(","));
}
builder.withClassLoaderModelDescriptorLoader(classLoaderModelDescriptorBuilder.build());
builder.withBundleDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
mulePluginModel = builder.build();
}
if (mulePluginModel != null) {
final File jsonDescriptorFile = new File(getTempFolder(), MULE_ARTIFACT_FOLDER + separator + MULE_ARTIFACT_JSON_DESCRIPTOR);
jsonDescriptorFile.deleteOnExit();
String jsonDescriber = new MulePluginModelJsonSerializer().serialize(mulePluginModel);
try {
writeStringToFile(jsonDescriptorFile, jsonDescriber);
} catch (IOException e) {
throw new IllegalStateException("There was an issue generating the JSON file for " + this.getId(), e);
}
customResources.add(new ZipResource(jsonDescriptorFile.getAbsolutePath(), MULE_ARTIFACT_PATH_INSIDE_JAR + "/" + MULE_ARTIFACT_JSON_DESCRIPTOR));
}
return customResources;
}
use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder in project mule by mulesoft.
the class AbstractDeploymentTestCase method createModuleUsingByeXmlPluginFileBuilder.
private ArtifactPluginFileBuilder createModuleUsingByeXmlPluginFileBuilder() {
String moduleFileName = "module-using-bye.xml";
String extensionName = "using-bye-extension";
String moduleDestination = "org/mule/module/" + moduleFileName;
MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder().setName(extensionName).setMinMuleVersion(MIN_MULE_VERSION).setRequiredProduct(MULE);
builder.withExtensionModelDescriber().setId(XmlExtensionModelLoader.DESCRIBER_ID).addProperty(RESOURCE_XML, moduleDestination);
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().addProperty(EXPORTED_PACKAGES, asList("org.foo")).setId(MULE_LOADER_ID).build());
builder.withBundleDescriptorLoader(createBundleDescriptorLoader(extensionName, MULE_EXTENSION_CLASSIFIER, MULE_LOADER_ID));
return new ArtifactPluginFileBuilder(extensionName).containingResource("module-using-byeSource.xml", moduleDestination).dependingOn(byeXmlExtensionPlugin).describedBy(builder.build());
}
use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder in project mule by mulesoft.
the class AbstractDeploymentTestCase method createHelloExtensionV1PluginFileBuilder.
private ArtifactPluginFileBuilder createHelloExtensionV1PluginFileBuilder() {
MulePluginModelBuilder mulePluginModelBuilder = new MulePluginModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName("helloExtensionPlugin").setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader("helloExtensionPlugin", MULE_EXTENSION_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID, "1.0.0"));
mulePluginModelBuilder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId(MULE_LOADER_ID).build());
mulePluginModelBuilder.withExtensionModelDescriber().setId(JAVA_LOADER_ID).addProperty("type", "org.foo.hello.HelloExtension").addProperty("version", "1.0.0");
return new ArtifactPluginFileBuilder("helloExtensionPlugin-1.0.0").dependingOn(new JarFileBuilder("helloExtensionV1", helloExtensionV1JarFile)).describedBy((mulePluginModelBuilder.build()));
}
use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder in project mule by mulesoft.
the class ApplicationDeploymentTestCase method deploysWithExtensionXmlPluginWithDependencies.
@Test
public void deploysWithExtensionXmlPluginWithDependencies() throws Exception {
String moduleFileName = "module-using-java.xml";
String extensionName = "using-java-extension";
String moduleDestination = "org/mule/module/" + moduleFileName;
MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder().setName(extensionName).setMinMuleVersion(MIN_MULE_VERSION).setRequiredProduct(MULE);
builder.withExtensionModelDescriber().setId(XmlExtensionModelLoader.DESCRIBER_ID).addProperty(RESOURCE_XML, moduleDestination);
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().addProperty(EXPORTED_PACKAGES, asList("org.foo")).setId(MULE_LOADER_ID).build());
builder.withBundleDescriptorLoader(createBundleDescriptorLoader(extensionName, MULE_EXTENSION_CLASSIFIER, MULE_LOADER_ID));
builder.setRequiredProduct(MULE).setMinMuleVersion(MIN_MULE_VERSION);
final ArtifactPluginFileBuilder byeXmlExtensionPlugin = new ArtifactPluginFileBuilder(extensionName).describedBy(builder.build()).containingResource("module-using-javaSource.xml", moduleDestination).dependingOn(new JarFileBuilder("echoTestJar", echoTestJarFile)).describedBy(builder.build());
ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder("appWithExtensionXmlPluginWithDependencies").definedBy("app-with-extension-xml-plugin-module-using-java.xml").dependingOn(byeXmlExtensionPlugin);
addPackedAppFromBuilder(applicationFileBuilder);
final DefaultDomainManager domainManager = new DefaultDomainManager();
domainManager.addDomain(createDefaultDomain());
TestApplicationFactory appFactory = createTestApplicationFactory(new MuleApplicationClassLoaderFactory(new DefaultNativeLibraryFinderFactory()), domainManager, serviceManager, extensionModelLoaderManager, moduleRepository, createDescriptorLoaderRepository());
deploymentService.setAppFactory(appFactory);
startDeployment();
assertDeploymentSuccess(applicationDeploymentListener, applicationFileBuilder.getId());
}
use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder in project mule by mulesoft.
the class ApplicationDeploymentTestCase method failsToDeployWithExtensionThatHasNonExistingIdForClassLoaderModel.
@Test
public void failsToDeployWithExtensionThatHasNonExistingIdForClassLoaderModel() throws Exception {
String extensionName = "extension-with-classloader-model-id-non-existing";
MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder().setName(extensionName).setMinMuleVersion(MIN_MULE_VERSION);
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId("a-non-existing-ID-describer").addProperty("aProperty", "aValue").build());
builder.withBundleDescriptorLoader(createBundleDescriptorLoader(extensionName, MULE_EXTENSION_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID));
final ArtifactPluginFileBuilder byeXmlExtensionPlugin = new ArtifactPluginFileBuilder(extensionName).describedBy(builder.build());
ApplicationFileBuilder applicationFileBuilder = new ApplicationFileBuilder("appWithExtensionXmlPluginFails").definedBy("app-with-extension-xml-plugin-module-bye.xml").dependingOn(byeXmlExtensionPlugin);
addPackedAppFromBuilder(applicationFileBuilder);
startDeployment();
assertDeploymentFailure(applicationDeploymentListener, applicationFileBuilder.getId(), times(1));
}
Aggregations