Skip to content

Commit

Permalink
recreate 0.3 release branch
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe Slattery committed Jan 19, 2011
2 parents 5adac36 + 365390a commit 9b4a190
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.apache.aries.application.management.BundleInfo;
import org.apache.aries.application.management.ResolveConstraint;
import org.apache.aries.application.management.ResolverException;
import org.apache.aries.application.management.spi.repository.PlatformRepository;
import org.apache.aries.application.modelling.ModelledResource;
import org.osgi.framework.Version;

Expand Down Expand Up @@ -94,4 +95,20 @@ public interface AriesApplicationResolver {
*/
Collection<ModelledResource> resolve(String appName, String appVersion, Collection<ModelledResource> byValueBundles, Collection<Content> inputs) throws ResolverException;

/**
* Resolve an AriesApplication against a given platform repository. The resolving process will build a repository from by-value bundles.
* It then scans all the required bundles and pull the dependencies required to resolve the bundles.
*
*
* Return a collect of modelled resources. This method is called when installing an application
* @param appName Application name
* @param appVersion application version
* @param byValueBundles by value bundles
* @param inputs bundle requirement
* @param platformRepository a platform repository to resolve against instead of the default
* @return a collection of modelled resource required by this application.
* @throws ResolverException
*/
Collection<ModelledResource> resolve(String appName, String appVersion, Collection<ModelledResource> byValueBundles, Collection<Content> inputs, PlatformRepository platformRepository) throws ResolverException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import org.apache.aries.application.management.BundleInfo;
import org.apache.aries.application.management.ResolveConstraint;
import org.apache.aries.application.management.ResolverException;
import org.apache.aries.application.management.spi.repository.PlatformRepository;
import org.apache.aries.application.management.spi.resolve.AriesApplicationResolver;
import org.apache.aries.application.management.spi.runtime.LocalPlatform;
import org.apache.aries.application.modelling.DeployedBundles;
Expand Down Expand Up @@ -128,6 +129,15 @@ public void addResult (Collection<ModelledResource> result) {
_nextResults.add(result);
}

public Collection<ModelledResource> resolve(String appName,
String appVersion, Collection<ModelledResource> byValueBundles,
Collection<Content> inputs,
PlatformRepository platformRepository) throws ResolverException
{

return resolve(appName, appVersion, byValueBundles, inputs);
}

public BundleInfo getBundleInfo(String bundleSymbolicName, Version bundleVersion)
{
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.apache.aries.application.management.spi.convert.BundleConversion;
import org.apache.aries.application.management.spi.convert.BundleConverter;
import org.apache.aries.application.management.spi.convert.ConversionException;
import org.apache.aries.application.management.spi.repository.PlatformRepository;
import org.apache.aries.application.management.spi.resolve.AriesApplicationResolver;
import org.apache.aries.application.management.spi.resolve.DeploymentManifestManager;
import org.apache.aries.application.management.spi.runtime.AriesApplicationContextManager;
Expand Down Expand Up @@ -185,6 +186,15 @@ public Collection<ModelledResource> resolve(String appName, String appVersion,

return byValueBundles;
}

public Collection<ModelledResource> resolve(String appName, String appVersion,
Collection<ModelledResource> byValueBundles, Collection<Content> inputs, PlatformRepository platformRepository)
throws ResolverException
{

return byValueBundles;
}

}

static class DummyLocalPlatform implements LocalPlatform {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.apache.aries.application.management.BundleInfo;
import org.apache.aries.application.management.ResolveConstraint;
import org.apache.aries.application.management.ResolverException;
import org.apache.aries.application.management.spi.repository.PlatformRepository;
import org.apache.aries.application.management.spi.resolve.AriesApplicationResolver;
import org.apache.aries.application.modelling.ModelledResource;
import org.osgi.framework.Version;
Expand Down Expand Up @@ -71,6 +72,14 @@ public Collection<ModelledResource> resolve(String appName, String appVersion,

return byValueBundles;
}

public Collection<ModelledResource> resolve(String appName, String appVersion,
Collection<ModelledResource> byValueBundles, Collection<Content> inputs, PlatformRepository platformRepository)
throws ResolverException
{

return byValueBundles;
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,26 +130,34 @@ public boolean getReturnOptionalResources()
return returnOptionalResources;
}

/**
public Collection<ModelledResource> resolve(String appName,
String appVersion, Collection<ModelledResource> byValueBundles,
Collection<Content> inputs) throws ResolverException {
return resolve(appName, appVersion, byValueBundles,
inputs, this.platformRepository);
}

/**
* Resolve a list of resources from the OBR bundle repositories by OBR
* resolver.
*
* @param appName - application name
* @param appVersion - application version
* @param byValueBundles - by value bundles
* @param inputs - other constraints
* @param platformRepository - a platform repository to use instead of the one provided as a service
* @return a collection of modelled resources required by this application
* @throws ResolverException
*/
@Override
public Collection<ModelledResource> resolve(String appName, String appVersion,
Collection<ModelledResource> byValueBundles, Collection<Content> inputs) throws ResolverException
{
public Collection<ModelledResource> resolve(String appName, String appVersion,
Collection<ModelledResource> byValueBundles, Collection<Content> inputs, PlatformRepository platformRepository)
throws ResolverException {
log.debug(LOG_ENTRY, "resolve", new Object[]{appName, appVersion,byValueBundles, inputs});
Collection<ImportedBundle> importedBundles = toImportedBundle(inputs);
Collection<ModelledResource> toReturn = new ArrayList<ModelledResource>();

Resolver obrResolver = getConfiguredObrResolver(appName, appVersion, byValueBundles);
Resolver obrResolver = getConfiguredObrResolver(appName, appVersion, byValueBundles, platformRepository);
// add a resource describing the requirements of the application metadata.
obrResolver.add(createApplicationResource( appName, appVersion, importedBundles));

Expand Down Expand Up @@ -192,7 +200,7 @@ public Collection<ModelledResource> resolve(String appName, String appVersion,
List<String> unsatisfiedRequirements = new LinkedList<String>();

for (Map.Entry<String, Set<String>> filterEntry : refinedReqs.entrySet()) {
log.debug("unable to satisfied the filter , filter = " + filterEntry.getKey() + "required by "+filterEntry.getValue());
log.debug("unable to satisfy the filter , filter = " + filterEntry.getKey() + "required by "+filterEntry.getValue());

String reason = extractConsumableMessageInfo(filterEntry.getKey(),filterEntry.getValue());

Expand All @@ -212,7 +220,14 @@ public Collection<ModelledResource> resolve(String appName, String appVersion,
}

private Resolver getConfiguredObrResolver(String appName, String appVersion,
Collection<ModelledResource> byValueBundles) throws ResolverException
Collection<ModelledResource> byValueBundles) throws ResolverException
{

return getConfiguredObrResolver(appName, appVersion, byValueBundles, platformRepository);
}

private Resolver getConfiguredObrResolver(String appName, String appVersion,
Collection<ModelledResource> byValueBundles, PlatformRepository platformRepository) throws ResolverException
{
log.debug(LOG_ENTRY, "getConfiguredObrResolver", new Object[]{appName, appVersion,byValueBundles });
DataModelHelper helper = repositoryAdmin.getHelper();
Expand Down Expand Up @@ -241,7 +256,7 @@ private Resolver getConfiguredObrResolver(String appName, String appVersion,
resolveRepos.add(r);
}
Resolver obrResolver = repositoryAdmin.resolver(resolveRepos.toArray(new Repository[resolveRepos.size()]));
addPlatformRepositories (obrResolver, appName);
addPlatformRepositories (obrResolver, appName, platformRepository);
log.debug(LOG_EXIT, "getConfiguredObrResolver", obrResolver);
return obrResolver;
}
Expand Down Expand Up @@ -339,7 +354,7 @@ public BundleInfo getBundleInfo(String bundleSymbolicName, Version bundleVersion
* These should be added to the resolver without being listed as coming from a particular
* repository or bundle.
*/
private void addPlatformRepositories (Resolver obrResolver, String appName)
private void addPlatformRepositories (Resolver obrResolver, String appName, PlatformRepository platformRepository)
{
log.debug(LOG_ENTRY, "addPlatformRepositories", new Object[]{obrResolver, appName});
DataModelHelper helper = repositoryAdmin.getHelper();
Expand All @@ -360,7 +375,7 @@ private void addPlatformRepositories (Resolver obrResolver, String appName)
}
}
} catch (Exception e) {
// no a big problem
// not a big problem
log.error(MessageUtil.getMessage("RESOLVER_UNABLE_TO_READ_REPOSITORY_EXCEPTION", new Object[]{appName, uri}) );
} finally {
IOUtils.close(is);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,21 +103,21 @@ RESOLVER_UNABLE_TO_RESOLVE_SERVICE_WITH_ATTRS_WITH_VERSION_LOWEX=The service dep
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_WITH_ATTRS_WITH_VERSION_LOWEX_UP=The service dependency with attributes {0} and the version greater than {1} and less than or equal to {2} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_WITH_ATTRS_WITH_VERSION_LOWEX_UPEX=The service dependency with attributes {0} and the version greater than {1} and less than {2} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE=The service dependency required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS=The service dependency with attributes {0} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION=The service dependency with the version {0} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOW=The service dependency with the version greater than or equal to {0} required by bundle {2} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOW_UP=The service dependency with the version greater than or equal to {0} and less than or equal to {2} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOW_UPEX=The service dependency with the version greater than or equal to {0} and less than {2} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOWEX=The service dependency with the version greater than {0} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOWEX_UP=The service dependency with the version greater than {0} and less than or equal to {2} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOWEX_UPEX=The service dependency with the version greater than {0} and less than {2} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION=The service dependency with attributes {0} and the version {2} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOW=The service dependency with attributes {0} and the version greater than or equal to {2} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOW_UP=The service dependency with attributes {0} and the version greater than or equal to {2} and less than or equal to {3} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOW_UPEX=The service dependency with attributes {0} and the version greater than or equal to {2} and less than {3} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOWEX=The service dependency with attributes {0} and the version greater than {2} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOWEX_UP=The service dependency with attributes {0} and the version greater than {2} and less than or equal to {3} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOWEX_UPEX=The service dependency with attributes {0} and the version greater than {2} and less than {3} required by bundle {1} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS=The service dependency with attributes {1} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION=The service dependency with the version {1} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOW=The service dependency with the version greater than or equal to {1} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOW_UP=The service dependency with the version greater than or equal to {2} and less than or equal to {1} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOW_UPEX=The service dependency with the version greater than or equal to {2} and less than {1} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOWEX=The service dependency with the version greater than {1} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOWEX_UP=The service dependency with the version greater than {2} and less than or equal to {1} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_VERSION_LOWEX_UPEX=The service dependency with the version greater than {2} and less than {1} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION=The service dependency with attributes {1} and the version {2} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOW=The service dependency with attributes {1} and the version greater than or equal to {2} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOW_UP=The service dependency with attributes {1} and the version greater than or equal to {3} and less than or equal to {2} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOW_UPEX=The service dependency with attributes {1} and the version greater than or equal to {3} and less than {2} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOWEX=The service dependency with attributes {1} and the version greater than {2} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOWEX_UP=The service dependency with attributes {1} and the version greater than {3} and less than or equal to {2} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_SERVICE_REQUIRED_BY_BUNDLE_WITH_ATTRS_WITH_VERSION_LOWEX_UPEX=The service dependency with attributes {1} and the version greater than {3} and less than {2} required by bundle {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_FILTER=A dependency of unspecified type with filter {0} cannot be resolved.
RESOLVER_UNABLE_TO_RESOLVE_FILTER_REQUIRED_BY_BUNDLE=A dependency of unspecified type with filter {0} required by bundle {1} cannot be resolved.
#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -58,7 +59,7 @@ public class BundleFrameworkManagerImpl implements BundleFrameworkManager
BundleFrameworkFactory _bundleFrameworkFactory;
BundleFrameworkConfigurationFactory _bundleFrameworkConfigurationFactory;
Map<Bundle, BundleFramework> _frameworks = new HashMap<Bundle, BundleFramework>();
Map<AriesApplication, BundleFramework> _frameworksByApp = new HashMap<AriesApplication, BundleFramework>();
Map<String, BundleFramework> _frameworksByAppScope = new HashMap<String, BundleFramework>();
private List<UpdateStrategy> _updateStrategies = Collections.emptyList();

public void setUpdateStrategies(List<UpdateStrategy> updateStrategies)
Expand Down Expand Up @@ -116,7 +117,7 @@ public Bundle installIsolatedBundles(Collection<BundleSuggestion> bundlesToInsta
.getIsolatedBundleContext(), app);

_frameworks.put(isolatedFramework.getFrameworkBundle(), isolatedFramework);
_frameworksByApp.put(app, isolatedFramework);
_frameworksByAppScope.put(app.getApplicationMetadata().getApplicationScope(), isolatedFramework);

frameworkBundle = isolatedFramework.getFrameworkBundle();
}
Expand Down Expand Up @@ -172,16 +173,24 @@ private BundleFramework isolatedInstall(Collection<BundleSuggestion> bundlesToBe
* Install the bundles into the new framework
*/

List<Bundle> installedBundles = new ArrayList<Bundle>();
BundleContext frameworkBundleContext = bundleFramework.getIsolatedBundleContext();
if (frameworkBundleContext != null) {
for (BundleSuggestion suggestion : bundlesToBeInstalled)
installedBundles.add(bundleFramework.install(suggestion, app));
try {
List<Bundle> installedBundles = new ArrayList<Bundle>();
BundleContext frameworkBundleContext = bundleFramework.getIsolatedBundleContext();
if (frameworkBundleContext != null) {
for (BundleSuggestion suggestion : bundlesToBeInstalled)
installedBundles.add(bundleFramework.install(suggestion, app));
}

// Finally, start the whole lot
if (!frameworkStarted)
bundleFramework.start();
} catch (BundleException be) {
bundleFramework.close();
throw be;
} catch (RuntimeException re) {
bundleFramework.close();
throw re;
}

// Finally, start the whole lot
if (!frameworkStarted)
bundleFramework.start();
}

LOGGER.debug(LOG_EXIT, "isolatedInstall", bundleFramework);
Expand All @@ -200,7 +209,16 @@ public void uninstallBundle(Bundle b) throws BundleException
{
synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
BundleFramework framework = getBundleFramework(b);
if (framework != null) framework.close();
if (framework != null) {
framework.close();

// clean up our maps so we don't leak memory
_frameworks.remove(b);
Iterator<BundleFramework> it = _frameworksByAppScope.values().iterator();
while (it.hasNext()) {
if (it.next().equals(framework)) it.remove();
}
}
}
}

Expand Down Expand Up @@ -260,7 +278,7 @@ public void updateBundles(final DeploymentMetadata newMetadata,
"No UpdateStrategy supports the supplied DeploymentMetadata changes.");

synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
final BundleFramework appFwk = _frameworksByApp.get(app);
final BundleFramework appFwk = _frameworksByAppScope.get(app.getApplicationMetadata().getApplicationScope());

strategy.update(new UpdateStrategy.UpdateInfo() {

Expand Down
Loading

0 comments on commit 9b4a190

Please sign in to comment.