use of org.apache.aries.application.modelling.ModelledResource in project aries by apache.
the class OBRResolverTest method generateOBRRepoXML.
private void generateOBRRepoXML(String... bundleFiles) throws Exception {
Set<ModelledResource> mrs = new HashSet<ModelledResource>();
FileOutputStream fout = new FileOutputStream("repository.xml");
RepositoryGenerator repositoryGenerator = context().getService(RepositoryGenerator.class);
ModelledResourceManager modelledResourceManager = context().getService(ModelledResourceManager.class);
for (String fileName : bundleFiles) {
File bundleFile = new File(fileName);
IDirectory jarDir = FileSystem.getFSRoot(bundleFile);
mrs.add(modelledResourceManager.getModelledResource(bundleFile.toURI().toString(), jarDir));
}
repositoryGenerator.generateRepository("Test repo description", mrs, fout);
fout.close();
}
use of org.apache.aries.application.modelling.ModelledResource in project aries by apache.
the class DeployedBundlesTest method testGetRequiredUseBundle_Valid.
@Test
public void testGetRequiredUseBundle_Valid() throws Exception {
// Get a valid set of deployment information.
DeployedBundles deployedBundles = validDeployedBundles();
packagesResolve(deployedBundles);
// Check all the use-bundle entries are required.
Collection<ModelledResource> requiredUseBundle = null;
try {
requiredUseBundle = deployedBundles.getRequiredUseBundle();
} catch (ResolverException e) {
e.printStackTrace();
Assert.fail(e.toString());
}
Assert.assertTrue("RequiredUseBundle=" + requiredUseBundle, requiredUseBundle.size() == 2);
}
use of org.apache.aries.application.modelling.ModelledResource in project aries by apache.
the class DeployedBundlesImpl method getDeployedImportService.
/**
* Get the Deployed-ImportService header.
* this.deployedImportService contains all the service import filters for every
* blueprint component within the application. We will only write an entry
* to Deployed-ImportService if
* a) the reference isMultiple(), or
* b) the service was not available internally when the app was first deployed
*
*/
public String getDeployedImportService() {
logger.debug(LOG_ENTRY, "getDeployedImportService");
String result = cachedDeployedImportService;
if (result == null) {
Collection<ImportedService> deployedBundleServiceImports = new ArrayList<ImportedService>();
Collection<ExportedService> servicesExportedWithinIsolatedContent = new ArrayList<ExportedService>();
for (ModelledResource mRes : getDeployedContent()) {
servicesExportedWithinIsolatedContent.addAll(mRes.getExportedServices());
}
for (ModelledResource mRes : fakeDeployedBundles) {
servicesExportedWithinIsolatedContent.addAll(mRes.getExportedServices());
}
for (ImportedService impService : deployedImportService) {
if (impService.isMultiple()) {
deployedBundleServiceImports.add(impService);
} else {
boolean serviceProvidedWithinIsolatedContent = false;
Iterator<ExportedService> it = servicesExportedWithinIsolatedContent.iterator();
while (!serviceProvidedWithinIsolatedContent && it.hasNext()) {
ExportedService svc = it.next();
serviceProvidedWithinIsolatedContent |= impService.isSatisfied(svc);
}
if (!serviceProvidedWithinIsolatedContent) {
deployedBundleServiceImports.add(impService);
}
}
}
result = createManifestString(deployedBundleServiceImports);
cachedDeployedImportService = result;
}
logger.debug(LOG_EXIT, "getDeployedImportService", result);
return result;
}
use of org.apache.aries.application.modelling.ModelledResource in project aries by apache.
the class DeployedBundlesImpl method getRequiredUseBundle.
/**
* Get the subset of bundles specified in use-bundle that are actually required to
* satisfy direct requirements of deployed content.
* @return a set of bundle metadata.
* @throws ResolverException if the requirements could not be resolved.
*/
public Collection<ModelledResource> getRequiredUseBundle() throws ResolverException {
logger.debug(LOG_ENTRY, "getRequiredUseBundle");
Collection<ModelledResource> usedUseBundles = cachedRequiredUseBundle;
if (usedUseBundles == null) {
Collection<ImportedPackage> externalReqs = getExternalPackageRequirements();
usedUseBundles = new HashSet<ModelledResource>();
for (ImportedPackage req : externalReqs) {
// Find a match from the supplied bundle capabilities.
ExportedPackage match = getPackageMatch(req, deployedUseBundle);
if (match != null) {
usedUseBundles.add(match.getBundle());
}
}
cachedRequiredUseBundle = usedUseBundles;
}
logger.debug(LOG_EXIT, "getRequiredUseBundle", usedUseBundles);
return usedUseBundles;
}
use of org.apache.aries.application.modelling.ModelledResource in project aries by apache.
the class DeployedBundlesImpl method getPackageMatch.
/**
* Get a package match between the specified requirement and a capability of the supplied
* bundles. The resulting match object might not refer to any matching capability.
* @param requirement the {@link ImportedPackageImpl} to be matched.
* @param bundles the bundles to be searched for matching capabilities.
* @return an ExportedPackageImpl or null if no match is found.
*/
private ExportedPackage getPackageMatch(ImportedPackage requirement, Collection<ModelledResource> bundles) {
logger.debug(LOG_ENTRY, "getPackageMatch", new Object[] { requirement, bundles });
ExportedPackage result = null;
outer: for (ModelledResource bundle : bundles) {
for (ExportedPackage pkg : bundle.getExportedPackages()) {
if (requirement.isSatisfied(pkg)) {
result = pkg;
break outer;
}
}
}
logger.debug(LOG_EXIT, "getPackageMatch", new Object[] { result });
return result;
}
Aggregations