use of org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder in project mule by mulesoft.
the class AbstractDeploymentTestCase method createHelloExtensionV2PluginFileBuilder.
private ArtifactPluginFileBuilder createHelloExtensionV2PluginFileBuilder() {
MulePluginModelBuilder mulePluginModelBuilder = new MulePluginModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName("helloExtensionPlugin").setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader("helloExtensionPlugin", MULE_EXTENSION_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID, "2.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", "2.0.0");
return new ArtifactPluginFileBuilder("helloExtensionPlugin-2.0.0").dependingOn(new JarFileBuilder("helloExtensionV2", helloExtensionV2JarFile)).describedBy((mulePluginModelBuilder.build()));
}
use of org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder in project mule by mulesoft.
the class AbstractDeploymentTestCase method createExceptionThrowingPluginFileBuilder.
private ArtifactPluginFileBuilder createExceptionThrowingPluginFileBuilder() {
final String pluginName = "exceptionPlugin";
MulePluginModel.MulePluginModelBuilder mulePluginModelBuilder = new MulePluginModel.MulePluginModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName(pluginName).setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(pluginName, MULE_PLUGIN_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID, "1.0.0"));
mulePluginModelBuilder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId(MULE_LOADER_ID).addProperty(EXPORTED_RESOURCES, asList("/META-INF/mule-exception.xsd", "/META-INF/mule.schemas")).build());
File exceptionTestClassFile = null;
File serviceTestClassFile = null;
try {
exceptionTestClassFile = new CompilerUtils.SingleClassCompiler().compile(getResourceFile("/org/exception/CustomException.java"));
serviceTestClassFile = new CompilerUtils.SingleClassCompiler().compile(getResourceFile("/org/exception/ExceptionComponentBuildingDefinitionProvider.java"));
} catch (URISyntaxException e) {
fail(e.getMessage());
}
ArtifactPluginFileBuilder exceptionPluginFileBuilder = new ArtifactPluginFileBuilder("exceptionPlugin").containingResource("exception/META-INF/mule.schemas", "META-INF/mule.schemas").containingResource("exception/META-INF/mule-exception.xsd", "META-INF/mule-exception.xsd").containingResource("exception/META-INF/services/org.mule.runtime.dsl.api.component.ComponentBuildingDefinitionProvider", "META-INF/services/org.mule.runtime.dsl.api.component.ComponentBuildingDefinitionProvider").containingClass(exceptionTestClassFile, "org/exception/CustomException.class").containingClass(serviceTestClassFile, "org/exception/ExceptionComponentBuildingDefinitionProvider.class").configuredWith(EXPORTED_RESOURCE_PROPERTY, "META-INF/mule-exception.xsd,META-INF/mule.schemas").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.exception").describedBy(mulePluginModelBuilder.build());
return exceptionPluginFileBuilder;
}
use of org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder in project mule by mulesoft.
the class MulePluginDescriptorGenerator method generateResource.
/**
* {@inheritDoc}
*/
@Override
public Optional<GeneratedResource> generateResource(ExtensionModel extensionModel) {
final Optional<ExtensionTypeDescriptorModelProperty> typeProperty = extensionModel.getModelProperty(ExtensionTypeDescriptorModelProperty.class);
if (!typeProperty.isPresent()) {
return empty();
}
final ExportedArtifactsCollector exportCollector = new ExportedArtifactsCollector(extensionModel, new DefaultClassPackageFinder(processingEnvironment));
final MulePluginModelBuilder builder = new MulePluginModelBuilder();
// Set only for testing purposes, the value will be reset by the plugin packager.
builder.setName(extensionModel.getName());
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId(MULE_LOADER_ID).addProperty(EXPORTED_PACKAGES, exportCollector.getExportedPackages()).addProperty(EXPORTED_RESOURCES, exportCollector.getExportedResources()).addProperty(PRIVILEGED_EXPORTED_PACKAGES, exportCollector.getPrivilegedExportedPackages()).addProperty(PRIVILEGED_ARTIFACTS_IDS, exportCollector.getPrivilegedArtifacts()).build());
builder.withExtensionModelDescriber().setId(getLoaderId(extensionModel)).addProperty(TYPE_PROPERTY_NAME, typeProperty.get().getType().getTypeName()).addProperty("version", extensionModel.getVersion());
builder.withBundleDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
final Optional<LicenseModelProperty> licenseModelPropertyOptional = extensionModel.getModelProperty(LicenseModelProperty.class);
builder.setRequiredProduct(extensionModel.getCategory().equals(COMMUNITY) ? MULE : MULE_EE);
licenseModelPropertyOptional.ifPresent(licenseModelProperty -> {
builder.setRequiredProduct(licenseModelProperty.requiresEeLicense() ? MULE_EE : MULE);
if (licenseModelProperty.requiresEeLicense()) {
builder.withLicenseModel().setAllowsEvaluationLicense(licenseModelProperty.isAllowsEvaluationLicense());
licenseModelProperty.getRequiredEntitlement().ifPresent(requiredEntitlement -> builder.withLicenseModel().setProvider(extensionModel.getVendor()).setRequiredEntitlement(requiredEntitlement));
}
});
final String descriptorJson = new MulePluginModelJsonSerializer().serialize(builder.build());
return of(new GeneratedResource(AUTO_GENERATED_MULE_ARTIFACT_DESCRIPTOR, descriptorJson.getBytes()));
}
use of org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder in project mule by mulesoft.
the class PluginResourcesResolverTestCase method resolvePluginResourcesForMulePlugin.
@Test
public void resolvePluginResourcesForMulePlugin() throws Exception {
MulePluginModelBuilder builder = new MulePluginModelBuilder();
builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptorBuilder().setId("mule").addProperty(EXPORTED_PACKAGES, newArrayList(ORG_MULE_TEST_RUNNER, ORG_MULE_TEST_RUNNER_API)).addProperty(EXPORTED_RESOURCES, newArrayList(META_INF_RESOURCE_PROPERTIES, META_INF_ANOTHER_RESOURCE_PROPERTIES)).build());
builder.withBundleDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
MulePluginModel mulePluginModel = builder.setName("samplePlugin").setMinMuleVersion("4.0.0").build();
String mulePluginModelJson = new MulePluginModelJsonSerializer().serialize(mulePluginModel);
File pluginPropertiesFile = new File(new File(new File(temporaryFolder.getRoot(), "META-INF"), "mule-artifact"), MULE_ARTIFACT_JSON_DESCRIPTOR);
writeStringToFile(pluginPropertiesFile, mulePluginModelJson);
URL classPathUrl = temporaryFolder.getRoot().toURI().toURL();
List<URL> urls = newArrayList(classPathUrl);
PluginUrlClassification mulePluginClassification = newPluginUrlClassification(urls);
PluginResourcesResolver resolver = new PluginResourcesResolver();
PluginUrlClassification result = resolver.resolvePluginResourcesFor(mulePluginClassification);
assertResolvedResources(mulePluginClassification, result);
}
use of org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder 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()));
}
Aggregations