use of org.apache.aries.application.management.spi.repository.ContextException in project aries by apache.
the class SharedBundleFramework method createSharedBundleFramework.
/**
* create using any bundle context in EBA App framework as we want to create
* a child framework under EBA App framework
*
* @param bc
* @throws BundleException
* @throws InvalidSyntaxException
*/
private static void createSharedBundleFramework(BundleContext bc, BundleFrameworkConfigurationFactory bundleFrameworkConfigFactory, BundleFrameworkFactory bundleFrameworkFactory) throws ContextException {
LOGGER.debug(LOG_ENTRY, "createSharedBundleFramework", new Object[] { bc, bundleFrameworkFactory });
try {
BundleFrameworkConfiguration config = new SharedBundleFrameworkConfiguration(bundleFrameworkConfigFactory.createBundleFrameworkConfig(BundleFramework.SHARED_BUNDLE_FRAMEWORK, bc));
sharedFramework = bundleFrameworkFactory.createBundleFramework(bc, config);
sharedFramework.start();
} catch (BundleException e) {
LOGGER.debug(LOG_EXIT, "createSharedBundleFramework", e);
throw new ContextException("Unable to create or start the shared framework composite bundle " + sharedFramework, e);
}
LOGGER.debug(LOG_EXIT, "createSharedBundleFramework");
}
use of org.apache.aries.application.management.spi.repository.ContextException in project aries by apache.
the class BundleRepositoryManagerImpl method getBundleSuggestions.
public Map<DeploymentContent, BundleSuggestion> getBundleSuggestions(Collection<BundleRepository> providers, Collection<DeploymentContent> content) throws ContextException {
LOGGER.debug(LOG_ENTRY, "getBundleSuggestions", new Object[] { content, providers });
Map<DeploymentContent, BundleSuggestion> urlToBeInstalled = new HashMap<DeploymentContent, BundleSuggestion>();
Iterator<DeploymentContent> it = content.iterator();
while (it.hasNext()) {
DeploymentContent bundleToFind = it.next();
Map<Version, List<BundleSuggestion>> bundlesuggestions = new HashMap<Version, List<BundleSuggestion>>();
for (BundleRepository obj : providers) {
BundleSuggestion suggestion = obj.suggestBundleToUse(bundleToFind);
if (suggestion != null) {
List<BundleSuggestion> suggestions = bundlesuggestions.get(suggestion.getVersion());
if (suggestions == null) {
suggestions = new ArrayList<BundleSuggestion>();
bundlesuggestions.put(suggestion.getVersion(), suggestions);
}
suggestions.add(suggestion);
}
}
BundleSuggestion suggestion = null;
if (!!!bundlesuggestions.isEmpty()) {
List<BundleSuggestion> thoughts = bundlesuggestions.get(bundleToFind.getExactVersion());
if (thoughts != null) {
Collections.sort(thoughts, new Comparator<BundleSuggestion>() {
public int compare(BundleSuggestion o1, BundleSuggestion o2) {
return o1.getCost() - o2.getCost();
}
});
suggestion = thoughts.get(0);
}
}
// add the suggestion to the list
if (suggestion != null) {
urlToBeInstalled.put(bundleToFind, suggestion);
} else {
throw new ContextException("Unable to find bundle " + bundleToFind.getContentName() + "/" + bundleToFind.getExactVersion());
}
}
LOGGER.debug(LOG_EXIT, "getBundleSuggestions", new Object[] { urlToBeInstalled });
return urlToBeInstalled;
}
Aggregations