use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor 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.ArtifactPluginDescriptor in project mule by mulesoft.
the class DefaultDomainFactory method doCreateArtifact.
@Override
protected Domain doCreateArtifact(File domainLocation, Optional<Properties> deploymentProperties) throws IOException {
String domainName = domainLocation.getName();
Domain domain = domainManager.getDomain(domainName);
if (domain != null) {
throw new IllegalArgumentException(format("Domain '%s' already exists", domainName));
}
if (domainName.contains(" ")) {
throw new IllegalArgumentException("Mule domain name may not contain spaces: " + domainName);
}
DomainDescriptor domainDescriptor = findDomain(domainName, domainLocation, deploymentProperties);
List<ArtifactPluginDescriptor> resolvedArtifactPluginDescriptors = pluginDependenciesResolver.resolve(emptySet(), domainDescriptor.getPlugins().stream().collect(toList()));
DomainClassLoaderBuilder artifactClassLoaderBuilder = domainClassLoaderBuilderFactory.createArtifactClassLoaderBuilder();
MuleDeployableArtifactClassLoader domainClassLoader = artifactClassLoaderBuilder.addArtifactPluginDescriptors(resolvedArtifactPluginDescriptors.toArray(new ArtifactPluginDescriptor[resolvedArtifactPluginDescriptors.size()])).setArtifactId(domainDescriptor.getName()).setArtifactDescriptor(domainDescriptor).build();
List<ArtifactPlugin> artifactPlugins = createArtifactPluginList(domainClassLoader, resolvedArtifactPluginDescriptors);
DefaultMuleDomain defaultMuleDomain = new DefaultMuleDomain(domainDescriptor, domainClassLoader, classLoaderRepository, serviceRepository, artifactPlugins, extensionModelLoaderManager);
DomainWrapper domainWrapper = new DomainWrapper(defaultMuleDomain, this);
domainManager.addDomain(domainWrapper);
return domainWrapper;
}
use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor in project mule by mulesoft.
the class BundlePluginDependenciesResolverTestCase method resolvesPluginDependencyWithCompatibleMinorVersion.
@Test
public void resolvesPluginDependencyWithCompatibleMinorVersion() throws Exception {
ArtifactPluginDescriptor updatedFooPlugin = new ArtifactPluginDescriptor(FOO_PLUGIN);
updatedFooPlugin.setBundleDescriptor(createTestBundleDescriptor(FOO_PLUGIN, "1.1"));
final List<ArtifactPluginDescriptor> pluginDescriptors = createPluginDescriptors(updatedFooPlugin, barPlugin);
barPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(createBundleDependency(FOO_BUNDLE_DESCRIPTOR))).build());
final List<ArtifactPluginDescriptor> resolvedPluginDescriptors = dependenciesResolver.resolve(emptySet(), pluginDescriptors);
assertResolvedPlugins(resolvedPluginDescriptors, updatedFooPlugin, barPlugin);
}
use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor in project mule by mulesoft.
the class BundlePluginDependenciesResolverTestCase method sanitizesTransitiveDependantPluginExportedPackages.
@Test
public void sanitizesTransitiveDependantPluginExportedPackages() throws Exception {
fooPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().exportingPackages(getFooExportedPackages()).build());
bazPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().exportingPackages(getBazExportedPackages()).dependingOn(singleton(FOO_PLUGIN_DESCRIPTOR)).build());
barPlugin.setClassLoaderModel(new ClassLoaderModel.ClassLoaderModelBuilder().exportingPackages(getBarExportedPackages()).dependingOn(singleton(BAZ_PLUGIN_DESCRIPTOR)).build());
final List<ArtifactPluginDescriptor> pluginDescriptors = createPluginDescriptors(fooPlugin, barPlugin, bazPlugin);
final List<ArtifactPluginDescriptor> resolvedPluginDescriptors = dependenciesResolver.resolve(emptySet(), pluginDescriptors);
assertResolvedPlugins(resolvedPluginDescriptors, fooPlugin, bazPlugin, barPlugin);
assertPluginExportedPackages(fooPlugin, "org.foo", "org.foo.mule");
assertPluginExportedPackages(bazPlugin, "org.baz");
assertPluginExportedPackages(barPlugin, "org.bar", "org.bar.mule");
}
use of org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor in project mule by mulesoft.
the class BundlePluginDependenciesResolverTestCase method resolvesPluginWithNewestVersionOnDependency.
@Test
public void resolvesPluginWithNewestVersionOnDependency() throws Exception {
final List<ArtifactPluginDescriptor> pluginDescriptors = createPluginDescriptors(barPlugin, bazPlugin, fooPlugin);
barPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(LATEST_BAZ_PLUGIN_DESCRIPTOR)).build());
bazPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(FOO_PLUGIN_DESCRIPTOR)).build());
latestBazPlugin.setClassLoaderModel(new ClassLoaderModelBuilder().dependingOn(singleton(FOO_PLUGIN_DESCRIPTOR)).build());
when(artifactDescriptorFactory.create(argThat(hasProperty("absolutePath", endsWith(latestBazPlugin.getBundleDescriptor().getArtifactFileName()))), any(Optional.class))).thenReturn(latestBazPlugin);
final List<ArtifactPluginDescriptor> resolvedPluginDescriptors = dependenciesResolver.resolve(emptySet(), pluginDescriptors);
assertResolvedPlugins(resolvedPluginDescriptors, fooPlugin, bazPlugin, barPlugin);
}
Aggregations