Search in sources :

Example 1 with LoaderDescriber

use of org.mule.runtime.deployment.model.api.plugin.LoaderDescriber in project mule by mulesoft.

the class ExtensionModelDiscoverer method discoverPluginsExtensionModels.

/**
 * For each artifactPlugin discovers the {@link ExtensionModel}.
 *
 * @param loaderRepository {@link ExtensionModelLoaderRepository} with the available extension loaders.
 * @param artifactPlugins {@link Pair} of {@link ArtifactPluginDescriptor} and {@link ArtifactClassLoader} for artifact plugins
 *        deployed inside the artifact. Non null.
 * @param parentArtifactExtensions {@link Set} of {@link ExtensionModel} to also take into account when parsing extensions
 * @return {@link Set} of {@link Pair} carrying the {@link ArtifactPluginDescriptor} and it's corresponding
 *         {@link ExtensionModel}.
 */
public Set<Pair<ArtifactPluginDescriptor, ExtensionModel>> discoverPluginsExtensionModels(ExtensionModelLoaderRepository loaderRepository, List<Pair<ArtifactPluginDescriptor, ArtifactClassLoader>> artifactPlugins, Set<ExtensionModel> parentArtifactExtensions) {
    final Set<Pair<ArtifactPluginDescriptor, ExtensionModel>> descriptorsWithExtensions = new HashSet<>();
    artifactPlugins.forEach(artifactPlugin -> {
        Set<ExtensionModel> extensions = descriptorsWithExtensions.stream().map(Pair::getSecond).collect(toSet());
        extensions.addAll(parentArtifactExtensions);
        final ArtifactPluginDescriptor artifactPluginDescriptor = artifactPlugin.getFirst();
        Optional<LoaderDescriber> loaderDescriber = artifactPluginDescriptor.getExtensionModelDescriptorProperty();
        ClassLoader artifactClassloader = artifactPlugin.getSecond().getClassLoader();
        String artifactName = artifactPluginDescriptor.getName();
        ExtensionModel extension = loaderDescriber.map(describer -> discoverExtensionThroughJsonDescriber(loaderRepository, describer, extensions, artifactClassloader, artifactName)).orElse(null);
        if (extension != null) {
            descriptorsWithExtensions.add(new Pair<>(artifactPluginDescriptor, extension));
        }
    });
    return descriptorsWithExtensions;
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) ExtensionModelLoaderRepository(org.mule.runtime.module.extension.internal.loader.ExtensionModelLoaderRepository) ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) Collection(java.util.Collection) Set(java.util.Set) String.format(java.lang.String.format) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) SpiServiceRegistry(org.mule.runtime.core.api.registry.SpiServiceRegistry) RuntimeExtensionModelProvider(org.mule.runtime.core.api.extension.RuntimeExtensionModelProvider) HashSet(java.util.HashSet) List(java.util.List) LoaderDescriber(org.mule.runtime.deployment.model.api.plugin.LoaderDescriber) Optional(java.util.Optional) Pair(org.mule.runtime.api.util.Pair) DslResolvingContext.getDefault(org.mule.runtime.api.dsl.DslResolvingContext.getDefault) ExtensionModelLoader(org.mule.runtime.extension.api.loader.ExtensionModelLoader) Collectors.toSet(java.util.stream.Collectors.toSet) MulePluginModel(org.mule.runtime.api.deployment.meta.MulePluginModel) ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) LoaderDescriber(org.mule.runtime.deployment.model.api.plugin.LoaderDescriber) Pair(org.mule.runtime.api.util.Pair) HashSet(java.util.HashSet)

Example 2 with LoaderDescriber

use of org.mule.runtime.deployment.model.api.plugin.LoaderDescriber in project mule by mulesoft.

the class ArtifactPluginDescriptorFactory method doDescriptorConfig.

@Override
protected void doDescriptorConfig(MulePluginModel artifactModel, ArtifactPluginDescriptor descriptor, File artifactLocation) {
    artifactModel.getExtensionModelLoaderDescriptor().ifPresent(extensionModelDescriptor -> {
        final LoaderDescriber loaderDescriber = new LoaderDescriber(extensionModelDescriptor.getId());
        loaderDescriber.addAttributes(extensionModelDescriptor.getAttributes());
        descriptor.setExtensionModelDescriptorProperty(loaderDescriber);
    });
    artifactModel.getLicense().ifPresent(descriptor::setLicenseModel);
}
Also used : LoaderDescriber(org.mule.runtime.deployment.model.api.plugin.LoaderDescriber)

Aggregations

LoaderDescriber (org.mule.runtime.deployment.model.api.plugin.LoaderDescriber)2 String.format (java.lang.String.format)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 MulePluginModel (org.mule.runtime.api.deployment.meta.MulePluginModel)1 DslResolvingContext.getDefault (org.mule.runtime.api.dsl.DslResolvingContext.getDefault)1 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)1 Pair (org.mule.runtime.api.util.Pair)1 RuntimeExtensionModelProvider (org.mule.runtime.core.api.extension.RuntimeExtensionModelProvider)1 SpiServiceRegistry (org.mule.runtime.core.api.registry.SpiServiceRegistry)1 ArtifactPluginDescriptor (org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor)1 ExtensionModelLoader (org.mule.runtime.extension.api.loader.ExtensionModelLoader)1 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)1 ExtensionModelLoaderRepository (org.mule.runtime.module.extension.internal.loader.ExtensionModelLoaderRepository)1