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;
}
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);
}
Aggregations