use of org.apache.aries.application.management.ResolveConstraint in project aries by apache.
the class OBRAriesResolver method resolve.
@Deprecated
@Override
public Set<BundleInfo> resolve(AriesApplication app, ResolveConstraint... constraints) throws ResolverException {
log.trace("resolving {}", app);
ApplicationMetadata appMeta = app.getApplicationMetadata();
String appName = appMeta.getApplicationSymbolicName();
Version appVersion = appMeta.getApplicationVersion();
List<Content> appContent = appMeta.getApplicationContents();
Collection<Content> useBundleContent = appMeta.getUseBundles();
List<Content> contents = new ArrayList<Content>();
contents.addAll(appContent);
contents.addAll(useBundleContent);
if ((constraints != null) && (constraints.length > 0)) {
for (ResolveConstraint con : constraints) {
contents.add(ContentFactory.parseContent(con.getBundleName(), con.getVersionRange().toString()));
}
}
Resolver obrResolver = getConfiguredObrResolver(appName, appVersion.toString(), toModelledResource(app.getBundleInfo()), false);
// add a resource describing the requirements of the application metadata.
obrResolver.add(createApplicationResource(appName, appVersion, contents));
if (obrResolver.resolve()) {
Set<BundleInfo> result = new HashSet<BundleInfo>();
List<Resource> requiredResources = retrieveRequiredResources(obrResolver);
for (Resource resource : requiredResources) {
BundleInfo bundleInfo = toBundleInfo(resource, false);
result.add(bundleInfo);
}
if (returnOptionalResources) {
for (Resource resource : obrResolver.getOptionalResources()) {
BundleInfo bundleInfo = toBundleInfo(resource, true);
result.add(bundleInfo);
}
}
return result;
} else {
Reason[] reasons = obrResolver.getUnsatisfiedRequirements();
//refine the list by removing the indirect unsatisfied bundles that are caused by unsatisfied packages or other bundles
Map<String, Set<String>> refinedReqs = refineUnsatisfiedRequirements(obrResolver, reasons);
StringBuffer reqList = new StringBuffer();
Map<String, String> unsatisfiedRequirements = extractConsumableMessageInfo(refinedReqs);
for (String reason : unsatisfiedRequirements.keySet()) {
reqList.append('\n');
reqList.append(reason);
}
ResolverException re = new ResolverException(MessageUtil.getMessage("RESOLVER_UNABLE_TO_RESOLVE", new Object[] { app.getApplicationMetadata().getApplicationName(), reqList }));
re.setUnsatisfiedRequirementsAndReasons(unsatisfiedRequirements);
log.debug(LOG_EXIT, "resolve", re);
throw re;
}
}
use of org.apache.aries.application.management.ResolveConstraint in project aries by apache.
the class IsolatedRuntimeTest method testAppWithGlobalRepositoryBundle.
@Test
@Ignore
public void testAppWithGlobalRepositoryBundle() throws Exception {
AriesApplicationManager manager = context().getService(AriesApplicationManager.class);
AriesApplication app = manager.createApplication(FileSystem.getFSRoot(new File("test2.eba")));
IsolationTestUtils.prepareSampleBundleV2(bundleContext, context().getService(RepositoryGenerator.class), context().getService(RepositoryAdmin.class), context().getService(ModellingManager.class));
AriesApplication newApp = manager.resolve(app, new ResolveConstraint() {
@Override
public String getBundleName() {
return "org.apache.aries.isolated.sample";
}
@Override
public VersionRange getVersionRange() {
return ManifestHeaderProcessor.parseVersionRange("[2.0.0,2.0.0]", true);
}
});
AriesApplicationContext ctx = manager.install(newApp);
ctx.start();
assertHelloWorldService("org.apache.aries.sample2", "hello brave new world");
manager.uninstall(ctx);
}
use of org.apache.aries.application.management.ResolveConstraint in project aries by apache.
the class UpdateAppTest method updateApp.
private AriesApplicationContext updateApp(AriesApplicationManager manager, AriesApplication app) throws Exception {
IsolationTestUtils.prepareSampleBundleV2(bundleContext, context().getService(RepositoryGenerator.class), context().getService(RepositoryAdmin.class), context().getService(ModellingManager.class));
AriesApplication newApp = manager.resolve(app, new ResolveConstraint() {
public String getBundleName() {
return "org.apache.aries.isolated.sample";
}
public VersionRange getVersionRange() {
return ManifestHeaderProcessor.parseVersionRange("[2.0.0,2.0.0]", true);
}
});
return manager.update(app, newApp.getDeploymentMetadata());
}
use of org.apache.aries.application.management.ResolveConstraint in project aries by apache.
the class DeploymentManifestManagerImpl method generateDeploymentManifest.
/**
* Perform provisioning to work out the 'freeze dried list' of the eba
* @param app - Aries application
* @param ResolveConstraint - resolver constraint for limiting the resolving results
* @return manifest the generated deployment manifest
* @throws ResolverException
*/
@Override
public Manifest generateDeploymentManifest(AriesApplication app, ResolveConstraint... constraints) throws ResolverException {
_logger.debug(LOG_ENTRY, "generateDeploymentManifest", new Object[] { app, constraints });
ApplicationMetadata appMetadata = app.getApplicationMetadata();
Collection<ModelledResource> byValueBundles = null;
try {
// find out blueprint information
byValueBundles = getByValueBundles(app);
// find out by value bundles and then by reference bundles
} catch (Exception e) {
throw new ResolverException(e);
}
Collection<Content> bundlesToResolve = new ArrayList<Content>();
bundlesToResolve.addAll(appMetadata.getApplicationContents());
bundlesToResolve.addAll(app.getApplicationMetadata().getUseBundles());
//If we pass in provision bundles (e.g. import deployment manifest sanity check), we add them into our bundlesToResolve set.
// This is because we want to make sure all bundles we passed into resolver the same as what we are going to get from resolver.
List<Content> restrictedReqs = new ArrayList<Content>();
for (ResolveConstraint constraint : constraints) {
Content content = ContentFactory.parseContent(constraint.getBundleName(), constraint.getVersionRange().toString());
restrictedReqs.add(content);
}
DeployedBundles deployedBundles = generateDeployedBundles(appMetadata, byValueBundles, restrictedReqs);
Manifest man = generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
_logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] { man });
return man;
}
Aggregations