use of org.mule.runtime.module.artifact.api.descriptor.BundleDependency in project mule by mulesoft.
the class DefaultApplicationFactoryTestCase method createClassLoaderModelWithDomain.
private ClassLoaderModel createClassLoaderModelWithDomain() {
BundleDescriptor domainDescriptor = new BundleDescriptor.Builder().setArtifactId(DOMAIN_NAME).setGroupId("test").setVersion("1.0.0").setClassifier(MULE_DOMAIN_CLASSIFIER).build();
Set<BundleDependency> domainDependency = Collections.singleton(new BundleDependency.Builder().setDescriptor(domainDescriptor).build());
return new ClassLoaderModel.ClassLoaderModelBuilder().dependingOn(domainDependency).build();
}
use of org.mule.runtime.module.artifact.api.descriptor.BundleDependency in project mule by mulesoft.
the class AbstractDeployableDescriptorFactory method createArtifactPluginDescriptors.
private Set<ArtifactPluginDescriptor> createArtifactPluginDescriptors(ClassLoaderModel classLoaderModel) throws IOException {
Set<ArtifactPluginDescriptor> pluginDescriptors = new HashSet<>();
for (BundleDependency bundleDependency : classLoaderModel.getDependencies()) {
if (bundleDependency.getDescriptor().isPlugin()) {
File pluginFile = new File(bundleDependency.getBundleUri());
pluginDescriptors.add(artifactPluginDescriptorLoader.load(pluginFile));
}
}
return pluginDescriptors;
}
use of org.mule.runtime.module.artifact.api.descriptor.BundleDependency in project mule by mulesoft.
the class AbstractMavenClassLoaderModelLoader method createLightPackageClassLoaderModel.
private ClassLoaderModel createLightPackageClassLoaderModel(File artifactFile, Map<String, Object> attributes, ArtifactType artifactType) {
File containerRepository;
if (isStandalone() && !getBoolean("mule.mode.embedded")) {
containerRepository = new File(getMuleHomeFolder(), "repository");
if (!containerRepository.exists()) {
if (!containerRepository.mkdirs()) {
// check again since it may have been created already.
if (!containerRepository.exists()) {
throw new MuleRuntimeException(I18nMessageFactory.createStaticMessage("Failure creating repository folder in MULE_HOME folder " + containerRepository.getAbsolutePath()));
}
}
}
}
File localMavenRepositoryLocation = mavenClient.getMavenConfiguration().getLocalMavenRepositoryLocation();
Supplier<File> compositeRepoLocationSupplier = localRepositorySupplierFactory.composeSuppliers(localRepositorySupplierFactory.artifactFolderRepositorySupplier(artifactFile, localMavenRepositoryLocation), localRepositorySupplierFactory.fixedFolderSupplier(localMavenRepositoryLocation));
File mavenRepository = compositeRepoLocationSupplier.get();
File temporaryDirectory = createTempDir();
try {
List<org.mule.maven.client.api.model.BundleDependency> dependencies = mavenClient.resolveArtifactDependencies(artifactFile, includeTestDependencies(attributes), includeProvidedDependencies(artifactType), of(mavenRepository), ofNullable((MavenReactorResolver) attributes.get(CLASSLOADER_MODEL_MAVEN_REACTOR_RESOLVER)), of(temporaryDirectory));
final ClassLoaderModel.ClassLoaderModelBuilder classLoaderModelBuilder = new ClassLoaderModel.ClassLoaderModelBuilder();
classLoaderModelBuilder.exportingPackages(new HashSet<>(getAttribute(attributes, EXPORTED_PACKAGES))).exportingPrivilegedPackages(new HashSet<>(getAttribute(attributes, PRIVILEGED_EXPORTED_PACKAGES)), new HashSet<>(getAttribute(attributes, PRIVILEGED_ARTIFACTS_IDS))).exportingResources(new HashSet<>(getAttribute(attributes, EXPORTED_RESOURCES))).includeTestDependencies(valueOf(getSimpleAttribute(attributes, INCLUDE_TEST_DEPENDENCIES, "false")));
Set<BundleDependency> bundleDependencies = dependencies.stream().filter(mavenClientDependency -> !mavenClientDependency.getScope().equals(PROVIDED)).map(mavenClientDependency -> convertBundleDependency(mavenClientDependency)).collect(toSet());
loadUrls(artifactFile, classLoaderModelBuilder, bundleDependencies);
Set<BundleDependency> allBundleDependencies = dependencies.stream().map(mavenClientDependency -> convertBundleDependency(mavenClientDependency)).collect(toSet());
classLoaderModelBuilder.dependingOn(allBundleDependencies);
return classLoaderModelBuilder.build();
} finally {
deleteQuietly(temporaryDirectory);
}
}
use of org.mule.runtime.module.artifact.api.descriptor.BundleDependency in project mule by mulesoft.
the class DefaultRegionPluginClassLoadersFactoryTestCase method createsDependantPlugins.
@Test
public void createsDependantPlugins() throws Exception {
BundleDependency pluginDependency = new BundleDependency.Builder().setScope(BundleScope.COMPILE).setDescriptor(PLUGIN1_BUNDLE_DESCRIPTOR).setBundleUri(new File("test").toURI()).build();
plugin2Descriptor.setClassLoaderModel(new ClassLoaderModel.ClassLoaderModelBuilder().dependingOn(singleton(pluginDependency)).build());
List<ArtifactPluginDescriptor> artifactPluginDescriptors = new ArrayList<>();
artifactPluginDescriptors.add(plugin1Descriptor);
artifactPluginDescriptors.add(plugin2Descriptor);
when(regionOwnerLookupPolicy.extend(argThat(any(Map.class)))).thenReturn(pluginLookupPolicy);
List<ArtifactClassLoader> pluginClassLoaders = factory.createPluginClassLoaders(regionClassLoader, artifactPluginDescriptors, regionOwnerLookupPolicy);
assertThat(pluginClassLoaders, contains(pluginClassLoader1, pluginClassLoader2));
}
use of org.mule.runtime.module.artifact.api.descriptor.BundleDependency in project mule by mulesoft.
the class DefaultRegionPluginClassLoadersFactoryTestCase method createsPluginWithPrivilegedPluginAccess.
@Test
public void createsPluginWithPrivilegedPluginAccess() throws Exception {
ClassLoaderModel plugin1ClassLoaderModel = new ClassLoaderModel.ClassLoaderModelBuilder().exportingPrivilegedPackages(singleton(PRIVILEGED_PACKAGE), singleton(PLUGIN_ARTIFACT_ID2)).build();
plugin1Descriptor.setClassLoaderModel(plugin1ClassLoaderModel);
BundleDependency pluginDependency = new BundleDependency.Builder().setScope(BundleScope.COMPILE).setDescriptor(PLUGIN1_BUNDLE_DESCRIPTOR).setBundleUri(new File("test").toURI()).build();
plugin2Descriptor.setClassLoaderModel(new ClassLoaderModel.ClassLoaderModelBuilder().dependingOn(singleton(pluginDependency)).build());
List<ArtifactPluginDescriptor> artifactPluginDescriptors = new ArrayList<>();
artifactPluginDescriptors.add(plugin1Descriptor);
artifactPluginDescriptors.add(plugin2Descriptor);
ArgumentCaptor<Map> argumentCaptor = forClass(Map.class);
when(regionOwnerLookupPolicy.extend(argumentCaptor.capture())).thenReturn(pluginLookupPolicy);
List<ArtifactClassLoader> pluginClassLoaders = factory.createPluginClassLoaders(regionClassLoader, artifactPluginDescriptors, regionOwnerLookupPolicy);
assertThat(pluginClassLoaders, contains(pluginClassLoader1, pluginClassLoader2));
assertThat((Map<String, LookupStrategy>) argumentCaptor.getAllValues().get(0), not(hasEntry(equalTo(PRIVILEGED_PACKAGE), instanceOf(DelegateOnlyLookupStrategy.class))));
assertThat((Map<String, LookupStrategy>) argumentCaptor.getAllValues().get(1), hasEntry(equalTo(PRIVILEGED_PACKAGE), instanceOf(DelegateOnlyLookupStrategy.class)));
}
Aggregations