Search in sources :

Example 1 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.

the class AbstractDeploymentTestCase method createPolicyIncludingDependantPluginFileBuilder.

private PolicyFileBuilder createPolicyIncludingDependantPluginFileBuilder() {
    MulePolicyModelBuilder mulePolicyModelBuilder = new MulePolicyModelBuilder().setMinMuleVersion(MIN_MULE_VERSION).setName(BAZ_POLICY_NAME).setRequiredProduct(Product.MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(BAZ_POLICY_NAME, MULE_POLICY_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
    ArtifactPluginFileBuilder dependantPlugin;
    try {
        dependantPlugin = new ArtifactPluginFileBuilder("dependantPlugin").configuredWith(EXPORTED_CLASS_PACKAGES_PROPERTY, "org.foo.echo").containingClass(new SingleClassCompiler().compile(getResourceFile("/org/foo/echo/Plugin3Echo.java")), "org/foo/echo/Plugin3Echo.class").dependingOn(helloExtensionV1Plugin);
    } catch (URISyntaxException e) {
        throw new RuntimeException(e);
    }
    return new PolicyFileBuilder(BAZ_POLICY_NAME).describedBy(mulePolicyModelBuilder.build()).dependingOn(dependantPlugin);
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) PolicyFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder) MulePolicyModelBuilder(org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder) URISyntaxException(java.net.URISyntaxException) SingleClassCompiler(org.mule.tck.util.CompilerUtils.SingleClassCompiler)

Example 2 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.

the class ApplicationDeploymentTestCase method failsToDeployWithExtensionThatHasNonExistingIdForExtensionModel.

@Test
public void failsToDeployWithExtensionThatHasNonExistingIdForExtensionModel() throws Exception {
    String extensionName = "extension-with-extension-model-id-non-existing";
    MulePluginModel.MulePluginModelBuilder builder = new MulePluginModel.MulePluginModelBuilder().setName(extensionName).setMinMuleVersion(MIN_MULE_VERSION);
    builder.withExtensionModelDescriber().setId("a-non-existing-ID-describer").addProperty("aProperty", "aValue");
    builder.withBundleDescriptorLoader(createBundleDescriptorLoader(extensionName, MULE_EXTENSION_CLASSIFIER, PROPERTIES_BUNDLE_DESCRIPTOR_LOADER_ID));
    builder.withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(MULE_LOADER_ID, emptyMap()));
    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());
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) ApplicationFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ApplicationFileBuilder) MulePluginModel(org.mule.runtime.api.deployment.meta.MulePluginModel) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 3 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor 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()));
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) ExportedArtifactsCollector(org.mule.runtime.module.extension.internal.resources.manifest.ExportedArtifactsCollector) MuleArtifactLoaderDescriptorBuilder(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder) ExtensionTypeDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionTypeDescriptorModelProperty) MulePluginModelJsonSerializer(org.mule.runtime.api.deployment.persistence.MulePluginModelJsonSerializer) DefaultClassPackageFinder(org.mule.runtime.module.extension.internal.resources.manifest.DefaultClassPackageFinder) GeneratedResource(org.mule.runtime.extension.api.resources.GeneratedResource) MulePluginModelBuilder(org.mule.runtime.api.deployment.meta.MulePluginModel.MulePluginModelBuilder) LicenseModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.LicenseModelProperty)

Example 4 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor 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;
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) MuleDomainModelJsonSerializer(org.mule.runtime.api.deployment.persistence.MuleDomainModelJsonSerializer) MuleArtifactLoaderDescriptorBuilder(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder) FileWriter(java.io.FileWriter) IOException(java.io.IOException) MuleRuntimeException(org.mule.runtime.api.exception.MuleRuntimeException) File(java.io.File) MuleDomainModel(org.mule.runtime.api.deployment.meta.MuleDomainModel)

Example 5 with MuleArtifactLoaderDescriptor

use of org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor in project mule by mulesoft.

the class ArtifactPluginDescriptorFactoryTestCase method detectsInvalidBundleDescriptorModelLoaderId.

@Test
public void detectsInvalidBundleDescriptorModelLoaderId() throws Exception {
    MulePluginModel.MulePluginModelBuilder pluginModelBuilder = new MulePluginModel.MulePluginModelBuilder().setName(PLUGIN_NAME).setMinMuleVersion(MIN_MULE_VERSION).setRequiredProduct(MULE).withBundleDescriptorLoader(createBundleDescriptorLoader(INVALID_LOADER_ID)).withClassLoaderModelDescriptorLoader(new MuleArtifactLoaderDescriptor(FILE_SYSTEM_POLICY_MODEL_LOADER_ID, emptyMap()));
    ArtifactPluginFileBuilder pluginFileBuilder = new ArtifactPluginFileBuilder(PLUGIN_NAME).tempFolder(pluginsTempFolder.newFolder()).describedBy(pluginModelBuilder.build());
    File pluginJarLocation = pluginFileBuilder.getArtifactFile();
    expectedException.expect(ArtifactDescriptorCreateException.class);
    expectedException.expectMessage(invalidBundleDescriptorLoaderIdError(pluginJarLocation, pluginModelBuilder.getBundleDescriptorLoader()));
    descriptorFactory.create(pluginJarLocation, empty());
}
Also used : MuleArtifactLoaderDescriptor(org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor) ArtifactPluginFileBuilder(org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder) MulePluginModel(org.mule.runtime.api.deployment.meta.MulePluginModel) File(java.io.File) Test(org.junit.Test)

Aggregations

MuleArtifactLoaderDescriptor (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptor)22 File (java.io.File)13 Test (org.junit.Test)12 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)8 ArtifactPluginFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.ArtifactPluginFileBuilder)8 PolicyFileBuilder (org.mule.runtime.module.deployment.impl.internal.builder.PolicyFileBuilder)8 MulePolicyModelBuilder (org.mule.runtime.api.deployment.meta.MulePolicyModel.MulePolicyModelBuilder)7 SmallTest (org.mule.tck.size.SmallTest)7 MuleArtifactLoaderDescriptorBuilder (org.mule.runtime.api.deployment.meta.MuleArtifactLoaderDescriptorBuilder)6 File.createTempFile (java.io.File.createTempFile)5 FileUtils.toFile (org.apache.commons.io.FileUtils.toFile)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)3 MuleServiceModelJsonSerializer (org.mule.runtime.api.deployment.persistence.MuleServiceModelJsonSerializer)3 FileWriter (java.io.FileWriter)2 URISyntaxException (java.net.URISyntaxException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 Collections.emptyList (java.util.Collections.emptyList)2 List (java.util.List)2