You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by jb...@apache.org on 2010/12/13 19:26:35 UTC
svn commit: r1045274 [3/7] - in
/incubator/aries/sandbox/jbohn/interceptor-proto: ./ application/
application/application-api/src/main/java/org/apache/aries/application/
application/application-api/src/main/java/org/apache/aries/application/management/...
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/UpdateAppTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/UpdateAppTest.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/UpdateAppTest.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/UpdateAppTest.java Mon Dec 13 18:26:19 2010
@@ -45,6 +45,7 @@ import org.apache.aries.application.mana
import org.apache.aries.application.management.spi.update.UpdateStrategy;
import org.apache.aries.application.modelling.ModellingManager;
import org.apache.aries.application.runtime.itests.util.IsolationTestUtils;
+import org.apache.aries.application.utils.AppConstants;
import org.apache.aries.application.utils.filesystem.FileSystem;
import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
import org.apache.aries.isolated.sample.HelloWorld;
@@ -254,6 +255,8 @@ public class UpdateAppTest extends Abstr
// logging (logProfile)
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("DEBUG"),
+ // do not provision against the local runtime
+ systemProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP).value("true"),
// Bundles
mavenBundle("org.apache.aries.blueprint", "org.apache.aries.blueprint"),
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/util/IsolationTestUtils.java Mon Dec 13 18:26:19 2010
@@ -31,6 +31,7 @@ import java.util.jar.Attributes;
import org.apache.aries.application.Content;
import org.apache.aries.application.DeploymentContent;
import org.apache.aries.application.management.AriesApplication;
+import org.apache.aries.application.management.spi.framework.BundleFramework;
import org.apache.aries.application.management.spi.repository.BundleRepository;
import org.apache.aries.application.management.spi.repository.RepositoryGenerator;
import org.apache.aries.application.modelling.ModelledResource;
@@ -94,10 +95,10 @@ public class IsolationTestUtils {
if (content.getContentName().equals("org.apache.aries.isolated.sample")) {
return new BundleSuggestion() {
- public Bundle install(BundleContext ctx, AriesApplication app) throws BundleException {
+ public Bundle install(BundleFramework framework, AriesApplication app) throws BundleException {
File f = new File("sample_2.0.0.jar");
try {
- return ctx.installBundle(f.toURL().toString());
+ return framework.getIsolatedBundleContext().installBundle(f.toURL().toString());
} catch (MalformedURLException mue) {
throw new RuntimeException(mue);
}
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/resources/obr/aries.bundle1/expectedRepository.xml Mon Dec 13 18:26:19 2010
@@ -4,13 +4,14 @@
<p n="presentationname" v="Test Bundle"/>
<p n="Fragment-Host" v="aries.ws.eba.framework;bundle-version="[3.0,4.0]""/>
<p n="version" t="version" v="2.0.0"/>
+<p n="fragment-attachment:" v="always"/>
<p n="symbolicname" v="aries.ws.eba.bundle1"/>
<p n="Bundle-ManifestVersion" v="2"/>
-<p n="mandatory" v=""/>
+<p n="singleton:" v="true"/>
</capability>
<capability name="package">
<p n="security" v="false"/>
-<p n="mandatory" v="company,security"/>
+<p n="mandatory:" t="set" v="company,security"/>
<p n="package" v="aries.ws.eba.bundle1"/>
<p n="version" t="version" v="2.2.0"/>
<p n="bundle-symbolic-name" v="aries.ws.eba.bundle1"/>
@@ -22,13 +23,11 @@
<p n="osgi.service.blueprint.compname" v="helloWorldManager"/>
<p n="objectClass" t="set" v="org.apache.aries.sample.HelloWorldManager"/>
<p n="service.ranking" v="0"/>
-<p n="mandatory" v=""/>
</capability>
<capability name="service">
<p n="service" v="service"/>
<p n="objectClass" t="set" v="aries.ws.eba.export"/>
<p n="service.ranking" v="0"/>
-<p n="mandatory" v=""/>
</capability>
<require extend="false" filter="(&(package=org.osgi.framework)(version>=1.3.0))" multiple="false" name="package" optional="false">Requires package with attributes {package=org.osgi.framework, version=1.3.0}</require>
<require extend="false" filter="(&(package=aries.ws.event)(version>=1.0.0))" multiple="false" name="package" optional="false">Requires package with attributes {package=aries.ws.event, version=1.0.0}</require>
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/resources/obr/repository.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/resources/obr/repository.xml?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/resources/obr/repository.xml (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-itests/src/test/resources/obr/repository.xml Mon Dec 13 18:26:19 2010
@@ -13,7 +13,6 @@
<capability name="package">
<p v="org.apache.aries.sample.impl" n="package"/>
<p v="1.0" t="version" n="version"/>
- <p n='mandatory' v=''/>
</capability>
</resource>
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-management/src/main/java/org/apache/aries/application/management/repository/ApplicationRepository.java Mon Dec 13 18:26:19 2010
@@ -24,10 +24,10 @@ import org.apache.aries.application.Cont
import org.apache.aries.application.DeploymentContent;
import org.apache.aries.application.management.AriesApplication;
import org.apache.aries.application.management.BundleInfo;
+import org.apache.aries.application.management.spi.framework.BundleFramework;
import org.apache.aries.application.management.spi.repository.BundleRepository;
import org.apache.aries.application.management.spi.resolve.AriesApplicationResolver;
import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Version;
@@ -110,10 +110,10 @@ public class ApplicationRepository imple
}
- public Bundle install(BundleContext ctx, AriesApplication app) throws BundleException
+ public Bundle install(BundleFramework framework, AriesApplication app) throws BundleException
{
if (bundleInfo != null ) {
- return ctx.installBundle(bundleInfo.getLocation());
+ return framework.getIsolatedBundleContext().installBundle(bundleInfo.getLocation());
} else {
throw new BundleException("Unable to install the bundle, as the BundleInfo is null.");
}
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/OBRAriesResolver.java Mon Dec 13 18:26:19 2010
@@ -61,6 +61,7 @@ import org.apache.aries.application.reso
import org.apache.aries.application.resolver.obr.impl.OBRBundleInfo;
import org.apache.aries.application.resolver.obr.impl.RepositoryGeneratorImpl;
import org.apache.aries.application.resolver.obr.impl.ResourceWrapper;
+import org.apache.aries.application.utils.AppConstants;
import org.apache.aries.application.utils.filesystem.IOUtils;
import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor;
import org.apache.aries.application.utils.manifest.ManifestHeaderProcessor.NameValueMap;
@@ -146,41 +147,12 @@ public class OBRAriesResolver implements
{
log.debug(LOG_ENTRY, "resolve", new Object[]{appName, appVersion,byValueBundles, inputs});
Collection<ImportedBundle> importedBundles = toImportedBundle(inputs);
- DataModelHelper helper = repositoryAdmin.getHelper();
-
-
Collection<ModelledResource> toReturn = new ArrayList<ModelledResource>();
- Repository appRepo;
- try {
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- RepositoryGeneratorImpl.generateRepository(repositoryAdmin, appName + "_" + appVersion, byValueBundles, bytesOut);
- appRepo = helper.readRepository(new InputStreamReader(new ByteArrayInputStream(bytesOut.toByteArray())));
- } catch (Exception e) {
- throw new ResolverException(e);
- }
-
- List<Repository> resolveRepos = new ArrayList<Repository>();
- // add system repository
- resolveRepos.add(repositoryAdmin.getSystemRepository());
- // add local repository
- resolveRepos.add(getLocalRepository(repositoryAdmin));
- // add application repository
- resolveRepos.add(appRepo);
-
-
-
- // Need to refresh the repositories added to repository admin
-
- // add user-defined repositories
- Repository[] repos = repositoryAdmin.listRepositories();
- for (Repository r : repos) {
- resolveRepos.add(r);
- }
- Resolver obrResolver = repositoryAdmin.resolver(resolveRepos.toArray(new Repository[resolveRepos.size()]));
- addPlatformRepositories (obrResolver, appName);
+ Resolver obrResolver = getConfiguredObrResolver(appName, appVersion, byValueBundles);
// add a resource describing the requirements of the application metadata.
obrResolver.add(createApplicationResource( appName, appVersion, importedBundles));
+
if (obrResolver.resolve()) {
List<Resource> requiredResources = retrieveRequiredResources(obrResolver);
@@ -238,15 +210,48 @@ public class OBRAriesResolver implements
}
}
+
+ private Resolver getConfiguredObrResolver(String appName, String appVersion,
+ Collection<ModelledResource> byValueBundles) throws ResolverException
+ {
+ log.debug(LOG_ENTRY, "getConfiguredObrResolver", new Object[]{appName, appVersion,byValueBundles });
+ DataModelHelper helper = repositoryAdmin.getHelper();
+ Repository appRepo;
+ try {
+ ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+ RepositoryGeneratorImpl.generateRepository(repositoryAdmin, appName + "_" + appVersion, byValueBundles, bytesOut);
+ appRepo = helper.readRepository(new InputStreamReader(new ByteArrayInputStream(bytesOut.toByteArray())));
+ } catch (Exception e) {
+ throw new ResolverException(e);
+ }
+
+ List<Repository> resolveRepos = new ArrayList<Repository>();
+ // add system repository
+ resolveRepos.add(repositoryAdmin.getSystemRepository());
+ // add local repository if configured
+ if (!(excludeLocalRuntime())) {
+ resolveRepos.add(getLocalRepository(repositoryAdmin));
+ }
+ // add application repository
+ resolveRepos.add(appRepo);
+ // Need to refresh the repositories added to repository admin
+ // add user-defined repositories
+ Repository[] repos = repositoryAdmin.listRepositories();
+ for (Repository r : repos) {
+ resolveRepos.add(r);
+ }
+ Resolver obrResolver = repositoryAdmin.resolver(resolveRepos.toArray(new Repository[resolveRepos.size()]));
+ addPlatformRepositories (obrResolver, appName);
+ log.debug(LOG_EXIT, "getConfiguredObrResolver", obrResolver);
+ return obrResolver;
+ }
+
@Deprecated
@Override
public Set<BundleInfo> resolve(AriesApplication app, ResolveConstraint... constraints) throws ResolverException
{
log.trace("resolving {}", app);
- DataModelHelper helper = repositoryAdmin.getHelper();
-
-
ApplicationMetadata appMeta = app.getApplicationMetadata();
String appName = appMeta.getApplicationSymbolicName();
@@ -263,34 +268,7 @@ public class OBRAriesResolver implements
}
}
- Repository appRepo;
- try {
-
- ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
- RepositoryGeneratorImpl.generateRepository(repositoryAdmin, appName + "_" + appVersion, toModelledResource(app.getBundleInfo()), bytesOut);
-
- appRepo = helper.readRepository(new InputStreamReader(new ByteArrayInputStream(bytesOut.toByteArray())));
- } catch (Exception e) {
- throw new ResolverException(e);
- }
-
- List<Repository> resolveRepos = new ArrayList<Repository>();
-
- // add system repository
- resolveRepos.add(repositoryAdmin.getSystemRepository());
- // add local repository
- resolveRepos.add(getLocalRepository(repositoryAdmin));
- // add application repository
- resolveRepos.add(appRepo);
-
- // add user-defined repositories
- Repository[] repos = repositoryAdmin.listRepositories();
- for (Repository r : repos) {
- resolveRepos.add(r);
- }
- Resolver obrResolver = repositoryAdmin.resolver(resolveRepos.toArray(new Repository[resolveRepos.size()]));
- addPlatformRepositories (obrResolver, appName);
-
+ Resolver obrResolver = getConfiguredObrResolver(appName, appVersion.toString(), toModelledResource(app.getBundleInfo()));
// add a resource describing the requirements of the application metadata.
obrResolver.add(createApplicationResource( appName, appVersion, contents));
if (obrResolver.resolve()) {
@@ -334,6 +312,8 @@ public class OBRAriesResolver implements
throw re;
}
}
+
+
@Override
public BundleInfo getBundleInfo(String bundleSymbolicName, Version bundleVersion)
@@ -710,5 +690,8 @@ public class OBRAriesResolver implements
}
+ private boolean excludeLocalRuntime() {
+ return Boolean.parseBoolean(System.getProperty(AppConstants.PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP));
+ }
}
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/impl/RepositoryGeneratorImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/impl/RepositoryGeneratorImpl.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/impl/RepositoryGeneratorImpl.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-obr-resolver/src/main/java/org/apache/aries/application/resolver/obr/impl/RepositoryGeneratorImpl.java Mon Dec 13 18:26:19 2010
@@ -56,6 +56,8 @@ public final class RepositoryGeneratorIm
private RepositoryAdmin repositoryAdmin;
private static Logger logger = LoggerFactory.getLogger(RepositoryGeneratorImpl.class);
private static Collection<BundleResourceTransformer> bundleResourceTransformers = new ArrayList<BundleResourceTransformer>();
+ private static final String MANDATORY_DIRECTIVE = Constants.MANDATORY_DIRECTIVE + ":";
+
public void setBundleResourceTransformers (List<BundleResourceTransformer> brts) {
bundleResourceTransformers = brts;
@@ -126,23 +128,11 @@ public final class RepositoryGeneratorIm
Property[] props = c.getProperties();
- String mandatoryDirective = Constants.MANDATORY_DIRECTIVE + ":";
- boolean mandatoryPresent = false;
for (Property entry : props) {
-
String name = (String) entry.getName();
String objectAttrs = entry.getValue();
- if (name.endsWith(":")) {
- if (mandatoryDirective.equals(name)) {
- mandatoryPresent = true;
- // remove the : and write it out
- name = name.substring(0, name.length() - 1);
- } else {
- // ignore other directives
- continue;
- }
- }
+
String type = getType(name);
// remove the beginning " and tailing "
@@ -151,12 +141,6 @@ public final class RepositoryGeneratorIm
addProperty(doc, capability, name, objectAttrs, type);
}
- // OBR's strange behaviour requires that we write out the mandatory entry
- // with an empty string if the mandatory is not specified
- if (!!!mandatoryPresent) {
- addProperty(doc, capability, Constants.MANDATORY_DIRECTIVE, "" , null);
- }
-
logger.debug(LOG_EXIT, "writeCapability");
}
@@ -233,7 +217,7 @@ public final class RepositoryGeneratorIm
String type = null;
if (Constants.VERSION_ATTRIBUTE.equals(name) || (Constants.BUNDLE_VERSION_ATTRIBUTE.equals(name))) {
type = "version";
- } else if (Constants.OBJECTCLASS.equals(name))
+ } else if (Constants.OBJECTCLASS.equals(name) || MANDATORY_DIRECTIVE.equals(name))
type = "set";
logger.debug(LOG_EXIT, "getType", new Object[]{type});
return type;
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/pom.xml?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/pom.xml (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/pom.xml Mon Dec 13 18:26:19 2010
@@ -32,6 +32,14 @@
A bundle framework manager implementation
</description>
+ <properties>
+ <aries.osgi.export.pkg>
+ </aries.osgi.export.pkg>
+ <aries.osgi.private.pkg>
+ org.apache.aries.application.runtime.framework.management
+ </aries.osgi.private.pkg>
+ </properties>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerImpl.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerImpl.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/BundleFrameworkManagerImpl.java Mon Dec 13 18:26:19 2010
@@ -29,27 +29,23 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Properties;
import java.util.Set;
-import org.apache.aries.application.Content;
import org.apache.aries.application.DeploymentContent;
import org.apache.aries.application.DeploymentMetadata;
-import org.apache.aries.application.InvalidAttributeException;
import org.apache.aries.application.management.AriesApplication;
import org.apache.aries.application.management.UpdateException;
import org.apache.aries.application.management.spi.framework.BundleFramework;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkConfiguration;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkConfigurationFactory;
import org.apache.aries.application.management.spi.framework.BundleFrameworkFactory;
import org.apache.aries.application.management.spi.framework.BundleFrameworkManager;
import org.apache.aries.application.management.spi.repository.ContextException;
import org.apache.aries.application.management.spi.repository.BundleRepository.BundleSuggestion;
import org.apache.aries.application.management.spi.update.UpdateStrategy;
-import org.apache.aries.application.utils.runtime.InstallUtils;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,11 +56,12 @@ public class BundleFrameworkManagerImpl
BundleContext _ctx;
BundleFramework _sharedBundleFramework;
BundleFrameworkFactory _bundleFrameworkFactory;
+ BundleFrameworkConfigurationFactory _bundleFrameworkConfigurationFactory;
Map<Bundle, BundleFramework> _frameworks = new HashMap<Bundle, BundleFramework>();
Map<AriesApplication, BundleFramework> _frameworksByApp = new HashMap<AriesApplication, BundleFramework>();
private List<UpdateStrategy> _updateStrategies = Collections.emptyList();
- public void setUpdateStrategies(List<UpdateStrategy> updateStrategies)
+ public void setUpdateStrategies(List<UpdateStrategy> updateStrategies)
{
_updateStrategies = updateStrategies;
}
@@ -79,33 +76,52 @@ public class BundleFrameworkManagerImpl
_bundleFrameworkFactory = bff;
}
+ public void setBundleFrameworkConfigurationFactory(BundleFrameworkConfigurationFactory bfcf)
+ {
+ _bundleFrameworkConfigurationFactory = bfcf;
+ }
+
public void init()
{
- try {
- _sharedBundleFramework = SharedBundleFramework.getSharedBundleFramework(_ctx,
- _bundleFrameworkFactory);
- _frameworks.put(_sharedBundleFramework.getFrameworkBundle(), _sharedBundleFramework);
- } catch (ContextException e) {
- LOGGER.error(LOG_EXCEPTION, e);
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ try {
+ _sharedBundleFramework = SharedBundleFramework.getSharedBundleFramework(_ctx,
+ _bundleFrameworkConfigurationFactory,
+ _bundleFrameworkFactory);
+ _frameworks.put(_sharedBundleFramework.getFrameworkBundle(), _sharedBundleFramework);
+ } catch (ContextException e) {
+ LOGGER.error(LOG_EXCEPTION, e);
+ }
}
}
public BundleFramework getBundleFramework(Bundle frameworkBundle)
{
- return _frameworks.get(frameworkBundle);
+ BundleFramework framework = null;
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ framework = _frameworks.get(frameworkBundle);
+ }
+ return framework;
}
public Bundle installIsolatedBundles(Collection<BundleSuggestion> bundlesToInstall,
AriesApplication app) throws BundleException
{
- // We need to create a new isolated framework for this content and install
- // the bundles to it
- BundleFramework isolatedFramework = isolatedInstall(bundlesToInstall, app);
+ Bundle frameworkBundle = null;
+
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ // We need to create a new isolated framework for this content and install
+ // the bundles to it
+ BundleFramework isolatedFramework = isolatedInstall(bundlesToInstall, _sharedBundleFramework
+ .getIsolatedBundleContext(), app);
- _frameworks.put(isolatedFramework.getFrameworkBundle(), isolatedFramework);
- _frameworksByApp.put(app, isolatedFramework);
+ _frameworks.put(isolatedFramework.getFrameworkBundle(), isolatedFramework);
+ _frameworksByApp.put(app, isolatedFramework);
+
+ frameworkBundle = isolatedFramework.getFrameworkBundle();
+ }
- return isolatedFramework.getFrameworkBundle();
+ return frameworkBundle;
}
public Collection<Bundle> installSharedBundles(Collection<BundleSuggestion> bundlesToInstall,
@@ -113,95 +129,32 @@ public class BundleFrameworkManagerImpl
{
Collection<Bundle> installedBundles = new ArrayList<Bundle>();
- // Shared bundle : Install to the shared bundle framework
- for (BundleSuggestion suggestion : bundlesToInstall)
- installedBundles.add(_sharedBundleFramework.install(suggestion, app));
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ // Shared bundle : Install to the shared bundle framework
+ for (BundleSuggestion suggestion : bundlesToInstall)
+ installedBundles.add(_sharedBundleFramework.install(suggestion, app));
+ }
return installedBundles;
}
- private BundleFramework isolatedInstall(
- Collection<BundleSuggestion> bundlesToBeInstalled,
- AriesApplication app)
- throws BundleException
+ private BundleFramework isolatedInstall(Collection<BundleSuggestion> bundlesToBeInstalled,
+ BundleContext parentCtx, AriesApplication app) throws BundleException
{
LOGGER.debug(LOG_ENTRY, "isolatedInstall", new Object[] { bundlesToBeInstalled, app });
- BundleFramework bundleFramework = null;
- BundleContext parentCtx = _sharedBundleFramework.getIsolatedBundleContext();
- DeploymentMetadata deploymentMF = app.getDeploymentMetadata();
-
/**
- * Set up framework config properties
+ * Build the configuration information for this application framework
*/
- Properties frameworkConfig = new Properties();
- String osgiFrameworkLocation = parentCtx.getProperty(FrameworkConstants.OSGI_FRAMEWORK);
- if (osgiFrameworkLocation != null) {
- frameworkConfig.put(FrameworkConstants.OSGI_FRAMEWORK, osgiFrameworkLocation);
-
- // let's only set javax.transaction as system extra packages because of the split package.
- // It is reasonable to do so because we always flow userTransaction service into child framework anyway.
- frameworkConfig.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, "javax.transaction;version=1.1.0");
- }
+ BundleFrameworkConfiguration config = _bundleFrameworkConfigurationFactory
+ .createBundleFrameworkConfig(app.getApplicationMetadata().getApplicationScope(), parentCtx,
+ app);
/**
- * Set up BundleManifest for the framework bundle
- */
- Properties frameworkBundleManifest = new Properties();
- frameworkBundleManifest.put(Constants.BUNDLE_SYMBOLICNAME, deploymentMF.getApplicationSymbolicName());
- frameworkBundleManifest.put(Constants.BUNDLE_VERSION, deploymentMF.getApplicationVersion().toString());
-
- /**
- * Set up Import-Package header for framework manifest
- */
- // Extract the import packages and remove anything we already have available in the current framework
- Collection<Content> imports =
- InstallUtils.calculateImports(
- deploymentMF.getImportPackage(),
- InstallUtils.getExportPackages(_sharedBundleFramework.getIsolatedBundleContext()));
-
- if (imports != null && !imports.isEmpty())
- {
- StringBuffer buffer = new StringBuffer();
- for (Content i : imports)
- buffer.append(InstallUtils.contentToString(i) + ",");
- frameworkBundleManifest.put(Constants.IMPORT_PACKAGE, buffer.substring(0, buffer.length()-1));
- }
-
- /**
- * Set up CompositeServiceFilter-Import header for framework manifest
- */
- StringBuffer serviceImportFilter =
- new StringBuffer("(" + Constants.OBJECTCLASS + "=javax.transaction.TransactionSynchronizationRegistry)");
-
- try
- {
- for (Filter importFilter : app.getDeploymentMetadata().getDeployedServiceImport()) {
- if (serviceImportFilter.length() > 0) {
- serviceImportFilter.append(",");
- }
- serviceImportFilter.append(importFilter.toString());
- }
-
- frameworkBundleManifest.put("CompositeServiceFilter-Import",
- serviceImportFilter.toString());
- }
- catch (InvalidAttributeException e)
- {
- LOGGER.debug(LOG_EXCEPTION, e);
- LOGGER.debug(LOG_EXIT,"isolatedInstall", e);
- throw new BundleException("Failed to process Service Imports" , e);
- }
-
- /**
* Install and start the new isolated bundle framework
*/
- bundleFramework =
- _bundleFrameworkFactory.createBundleFramework(
- parentCtx,
- app.getApplicationMetadata().getApplicationScope(),
- frameworkConfig,
- frameworkBundleManifest);
+ BundleFramework bundleFramework = _bundleFrameworkFactory.createBundleFramework(parentCtx,
+ config);
// We should now have a bundleFramework
if (bundleFramework != null) {
@@ -238,109 +191,126 @@ public class BundleFrameworkManagerImpl
public BundleFramework getSharedBundleFramework()
{
- return _sharedBundleFramework;
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ return _sharedBundleFramework;
+ }
}
public void uninstallBundle(Bundle b) throws BundleException
{
- BundleFramework framework = getBundleFramework(b);
- if (framework != null) framework.close();
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ BundleFramework framework = getBundleFramework(b);
+ if (framework != null) framework.close();
+ }
}
public void startBundle(Bundle b) throws BundleException
{
- BundleFramework framework = getBundleFramework(b);
- if (framework != null) // App Content
- {
- for (Bundle bundle : framework.getBundles())
- framework.start(bundle);
- } else // Shared bundle
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ BundleFramework framework = getBundleFramework(b);
+ if (framework != null) // App Content
+ {
+ for (Bundle bundle : framework.getBundles())
+ framework.start(bundle);
+ } else // Shared bundle
_sharedBundleFramework.start(b);
+ }
}
public void stopBundle(Bundle b) throws BundleException
{
- BundleFramework framework = getBundleFramework(b);
- if (framework != null) // App Content
- {
- for (Bundle bundle : framework.getBundles())
- framework.stop(bundle);
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ BundleFramework framework = getBundleFramework(b);
+ if (framework != null) // App Content
+ {
+ for (Bundle bundle : framework.getBundles())
+ framework.stop(bundle);
+ }
+ // Do not stop shared bundles
}
- // Do not stop shared bundles
}
- public boolean allowsUpdate(DeploymentMetadata newMetadata, DeploymentMetadata oldMetadata)
+ public boolean allowsUpdate(DeploymentMetadata newMetadata, DeploymentMetadata oldMetadata)
{
for (UpdateStrategy strategy : _updateStrategies) {
if (strategy.allowsUpdate(newMetadata, oldMetadata)) {
return true;
}
}
-
+
return false;
}
- public void updateBundles(
- final DeploymentMetadata newMetadata,
- final DeploymentMetadata oldMetadata,
- final AriesApplication app,
- final BundleLocator locator,
- final Set<Bundle> bundles,
- final boolean startBundles)
- throws UpdateException
+ public void updateBundles(final DeploymentMetadata newMetadata,
+ final DeploymentMetadata oldMetadata, final AriesApplication app,
+ final BundleLocator locator, final Set<Bundle> bundles, final boolean startBundles)
+ throws UpdateException
{
UpdateStrategy strategy = null;
-
+
for (UpdateStrategy us : _updateStrategies) {
if (us.allowsUpdate(newMetadata, oldMetadata)) {
strategy = us;
break;
}
}
-
- if (strategy == null) throw new IllegalArgumentException("No UpdateStrategy supports the supplied DeploymentMetadata changes.");
-
- final BundleFramework appFwk = _frameworksByApp.get(app);
-
- strategy.update(new UpdateStrategy.UpdateInfo() {
-
- public void register(Bundle bundle) {
- bundles.add(bundle);
- }
-
- public void unregister(Bundle bundle) {
- bundles.remove(bundle);
- }
-
- public Map<DeploymentContent, BundleSuggestion> suggestBundle(Collection<DeploymentContent> bundles) throws ContextException {
- return locator.suggestBundle(bundles);
- }
-
- public boolean startBundles() {
- return startBundles;
- }
-
- public BundleFramework getSharedFramework() {
- return _sharedBundleFramework;
- }
-
- public DeploymentMetadata getOldMetadata() {
- return oldMetadata;
- }
-
- public DeploymentMetadata getNewMetadata() {
- return newMetadata;
- }
-
- public AriesApplication getApplication() {
- return app;
- }
-
- public BundleFramework getAppFramework() {
- return appFwk;
- }
- });
+
+ if (strategy == null)
+ throw new IllegalArgumentException(
+ "No UpdateStrategy supports the supplied DeploymentMetadata changes.");
+
+ synchronized (BundleFrameworkManager.SHARED_FRAMEWORK_LOCK) {
+ final BundleFramework appFwk = _frameworksByApp.get(app);
+
+ strategy.update(new UpdateStrategy.UpdateInfo() {
+
+ public void register(Bundle bundle)
+ {
+ bundles.add(bundle);
+ }
+
+ public void unregister(Bundle bundle)
+ {
+ bundles.remove(bundle);
+ }
+
+ public Map<DeploymentContent, BundleSuggestion> suggestBundle(
+ Collection<DeploymentContent> bundles) throws BundleException
+ {
+ return locator.suggestBundle(bundles);
+ }
+
+ public boolean startBundles()
+ {
+ return startBundles;
+ }
+
+ public BundleFramework getSharedFramework()
+ {
+ return _sharedBundleFramework;
+ }
+
+ public DeploymentMetadata getOldMetadata()
+ {
+ return oldMetadata;
+ }
+
+ public DeploymentMetadata getNewMetadata()
+ {
+ return newMetadata;
+ }
+
+ public AriesApplication getApplication()
+ {
+ return app;
+ }
+
+ public BundleFramework getAppFramework()
+ {
+ return appFwk;
+ }
+ });
+ }
}
-
-
+
}
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/java/org/apache/aries/application/runtime/framework/management/SharedBundleFramework.java Mon Dec 13 18:26:19 2010
@@ -28,6 +28,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.aries.application.management.spi.framework.BundleFramework;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkConfiguration;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkConfigurationFactory;
import org.apache.aries.application.management.spi.framework.BundleFrameworkFactory;
import org.apache.aries.application.management.spi.repository.ContextException;
@@ -35,62 +37,50 @@ import static org.apache.aries.applicati
import static org.apache.aries.application.utils.AppConstants.LOG_EXIT;
public class SharedBundleFramework
-{
+{
private static final Logger LOGGER = LoggerFactory.getLogger(SharedBundleFramework.class);
-
private static BundleFramework sharedFramework;
/**
- * This is not the right way to make blueprint usable by applications, but it is all
- * we have time to make work. I have locked down the version ranges so that this can
- * be fixed properly in the future. NB The org.osgi.service.blueprint
- * package is deliberately unversioned as it is not part of the osgi compendium.
+ * This is not the right way to make blueprint usable by applications, but
+ * it is all we have time to make work. I have locked down the version
+ * ranges so that this can be fixed properly in the future. NB The
+ * org.osgi.service.blueprint package is deliberately unversioned as it is
+ * not part of the osgi compendium.
*/
private static final String RUNTIME_PACKAGES = "org.osgi.service.blueprint,org.osgi.service.blueprint.container;version=\"[1.0.0,1.0.1]\",org.osgi.service.blueprint.reflect;version=\"[1.0.0,1.0.1]\",org.apache.aries.transaction.exception;version=\"[0.1,1.0.0)\"";
/**
- * create using any bundle context in EBA App framework
- * as we want to create a child framework under EBA App framework
+ * 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});
+ LOGGER.debug(LOG_ENTRY, "createSharedBundleFramework", new Object[] { bc,
+ bundleFrameworkFactory });
try {
- // Set up the isolated framework
- Properties frameworkConfig = new Properties();
- frameworkConfig.put("osgi.console", "0");
-
- String osgiFrameworkLocation = bc.getProperty(FrameworkConstants.OSGI_FRAMEWORK);
- if (osgiFrameworkLocation != null) {
-
- frameworkConfig.put(FrameworkConstants.OSGI_FRAMEWORK, osgiFrameworkLocation);
- if (bc.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA) != null)
- {
- frameworkConfig.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA, bc
- .getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA));
- }
- }
-
- Properties compositeManifest = new Properties();
- compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, BundleFramework.SHARED_BUNDLE_FRAMEWORK);
-
- //Add blueprint so that it is available to applications.
- compositeManifest.put(Constants.IMPORT_PACKAGE, RUNTIME_PACKAGES);
- sharedFramework = bundleFrameworkFactory.createBundleFramework(bc, BundleFramework.SHARED_BUNDLE_FRAMEWORK,
- frameworkConfig, compositeManifest);
+ BundleFrameworkConfiguration config =
+ new SharedBundleFrameworkConfiguration(
+ bundleFrameworkConfigFactory.createBundleFrameworkConfig(
+ BundleFramework.SHARED_BUNDLE_FRAMEWORK,
+ bc));
+
+ sharedFramework = bundleFrameworkFactory.createBundleFramework(bc, config);
sharedFramework.init();
-
+
} catch (BundleException e) {
LOGGER.debug(LOG_EXIT, "createSharedBundleFramework", e);
- throw new ContextException(
- "Unable to create or start the shared framework composite bundle " + sharedFramework, e);
+ throw new ContextException("Unable to create or start the shared framework composite bundle "
+ + sharedFramework, e);
}
LOGGER.debug(LOG_EXIT, "createSharedBundleFramework");
@@ -99,23 +89,64 @@ public class SharedBundleFramework
/**
* pass in the EBA framework bundle context and get the shared bundle
* framework associated with the bundle context
- * @param bc any bundle context in EBA framework
- * @return the composite bundle associated with the shared bundle framework
+ *
+ * @param bc
+ * any bundle context in EBA framework
+ * @return the composite bundle associated with the shared bundle framework
* @throws BundleException
* @throws InvalidSyntaxException
* @throws SharedFrameworkCreationException
*/
public synchronized static BundleFramework getSharedBundleFramework(BundleContext bc,
+ BundleFrameworkConfigurationFactory bfcf,
BundleFrameworkFactory bff) throws ContextException
{
- LOGGER.debug(LOG_ENTRY, "getSharedBundleFramework", new Object[] {bc, bff});
-
+ LOGGER.debug(LOG_ENTRY, "getSharedBundleFramework", new Object[] { bc, bff });
+
if (sharedFramework == null) {
- createSharedBundleFramework(bc, bff);
+ createSharedBundleFramework(bc, bfcf, bff);
}
-
+
LOGGER.debug(LOG_EXIT, "getSharedBundleFramework", sharedFramework);
return sharedFramework;
}
+
+ /**
+ * Wrapper for the basic framework configuration
+ * @author cwilkin
+ *
+ */
+ private static class SharedBundleFrameworkConfiguration implements BundleFrameworkConfiguration
+ {
+ BundleFrameworkConfiguration basicConfig = null;
+
+ public SharedBundleFrameworkConfiguration(BundleFrameworkConfiguration basicConfig) {
+ this.basicConfig = basicConfig;
+ }
+
+ public String getFrameworkID()
+ {
+ return basicConfig.getFrameworkID();
+ }
+
+ public Properties getFrameworkManifest()
+ {
+
+ Properties compositeManifest = basicConfig.getFrameworkManifest();
+
+ compositeManifest.put(Constants.BUNDLE_SYMBOLICNAME, BundleFramework.SHARED_BUNDLE_FRAMEWORK);
+
+ // Add blueprint so that it is available to applications.
+ compositeManifest.put(Constants.IMPORT_PACKAGE, RUNTIME_PACKAGES);
+
+ return compositeManifest;
+ }
+
+ public Properties getFrameworkProperties()
+ {
+ return basicConfig.getFrameworkProperties();
+ }
+
+ }
}
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework-management/src/main/resources/OSGI-INF/blueprint/bundle-framework-management.xml Mon Dec 13 18:26:19 2010
@@ -21,6 +21,7 @@
<bean id="equinox-bundle-framework-manager" class="org.apache.aries.application.runtime.framework.management.BundleFrameworkManagerImpl" init-method="init">
<property name="bundleFrameworkFactory" ref="bundle-framework-factory"/>
+ <property name="bundleFrameworkConfigurationFactory" ref="bundle-framework-configuration-factory"/>
<property name="bundleContext" ref="blueprintBundleContext"/>
<property name="updateStrategies" ref="strategies" />
</bean>
@@ -30,6 +31,8 @@
ranking="-1"/>
<reference id="bundle-framework-factory" interface="org.apache.aries.application.management.spi.framework.BundleFrameworkFactory"/>
+
+ <reference id="bundle-framework-configuration-factory" interface="org.apache.aries.application.management.spi.framework.BundleFrameworkConfigurationFactory"/>
<reference-list id="strategies" interface="org.apache.aries.application.management.spi.update.UpdateStrategy" availability="optional" />
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/pom.xml?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/pom.xml (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/pom.xml Mon Dec 13 18:26:19 2010
@@ -32,6 +32,16 @@
An equinox based bundle framework runtime implementation
</description>
+ <properties>
+ <aries.osgi.export.pkg>
+ org.apache.aries.application.runtime.framework.utils
+ </aries.osgi.export.pkg>
+ <aries.osgi.private.pkg>
+ org.apache.aries.application.runtime.framework;
+ org.apache.aries.application.runtime.framework.config
+ </aries.osgi.private.pkg>
+ </properties>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkFactoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkFactoryImpl.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkFactoryImpl.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkFactoryImpl.java Mon Dec 13 18:26:19 2010
@@ -19,9 +19,8 @@
package org.apache.aries.application.runtime.framework;
-import java.util.Properties;
-
import org.apache.aries.application.management.spi.framework.BundleFramework;
+import org.apache.aries.application.management.spi.framework.BundleFrameworkConfiguration;
import org.apache.aries.application.management.spi.framework.BundleFrameworkFactory;
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
@@ -31,8 +30,7 @@ import org.osgi.service.framework.Compos
public class BundleFrameworkFactoryImpl implements BundleFrameworkFactory
{
- public BundleFramework createBundleFramework(BundleContext bc, String frameworkId,
- Properties frameworkConfig, Properties frameworkManifest) throws BundleException
+ public BundleFramework createBundleFramework(BundleContext bc, BundleFrameworkConfiguration config) throws BundleException
{
BundleFramework framework = null;
ServiceReference sr = bc.getServiceReference(CompositeBundleFactory.class.getName());
@@ -41,9 +39,9 @@ public class BundleFrameworkFactoryImpl
CompositeBundleFactory cbf = (CompositeBundleFactory) bc.getService(sr);
CompositeBundle compositeBundle = cbf.installCompositeBundle(
- frameworkConfig,
- frameworkId,
- frameworkManifest);
+ config.getFrameworkProperties(),
+ config.getFrameworkID(),
+ config.getFrameworkManifest());
framework = new BundleFrameworkImpl(compositeBundle);
} else throw new BundleException("Failed to obtain framework factory service");
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/java/org/apache/aries/application/runtime/framework/BundleFrameworkImpl.java Mon Dec 13 18:26:19 2010
@@ -139,7 +139,7 @@ public class BundleFrameworkImpl impleme
public Bundle install(BundleSuggestion suggestion, AriesApplication app) throws BundleException
{
- Bundle installedBundle = suggestion.install(getIsolatedBundleContext(), app);
+ Bundle installedBundle = suggestion.install(this, app);
_bundles.add(installedBundle);
return installedBundle;
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/resources/OSGI-INF/blueprint/bundle-framework.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/resources/OSGI-INF/blueprint/bundle-framework.xml?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/resources/OSGI-INF/blueprint/bundle-framework.xml (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-framework/src/main/resources/OSGI-INF/blueprint/bundle-framework.xml Mon Dec 13 18:26:19 2010
@@ -20,9 +20,15 @@
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0">
<bean id="bundle-framework-factory" class="org.apache.aries.application.runtime.framework.BundleFrameworkFactoryImpl" />
+
+ <bean id="bundle-framework-configuration-factory" class="org.apache.aries.application.runtime.framework.config.BundleFrameworkConfigurationFactoryImpl" />
<service interface="org.apache.aries.application.management.spi.framework.BundleFrameworkFactory"
ref="bundle-framework-factory"
ranking="-1"/>
+ <service interface="org.apache.aries.application.management.spi.framework.BundleFrameworkConfigurationFactory"
+ ref="bundle-framework-configuration-factory"
+ ranking="-1"/>
+
</blueprint>
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/pom.xml?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/pom.xml (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/pom.xml Mon Dec 13 18:26:19 2010
@@ -32,6 +32,14 @@
An isolated application runtime implementation
</description>
+ <properties>
+ <aries.osgi.export.pkg>
+ </aries.osgi.export.pkg>
+ <aries.osgi.private.pkg>
+ org.apache.aries.application.runtime.isolated.impl
+ </aries.osgi.private.pkg>
+ </properties>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextImpl.java Mon Dec 13 18:26:19 2010
@@ -25,9 +25,8 @@ import static org.apache.aries.applicati
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -36,7 +35,6 @@ import org.apache.aries.application.Depl
import org.apache.aries.application.DeploymentMetadata;
import org.apache.aries.application.management.AriesApplication;
import org.apache.aries.application.management.AriesApplicationContext;
-import org.apache.aries.application.management.ManagementException;
import org.apache.aries.application.management.UpdateException;
import org.apache.aries.application.management.spi.framework.BundleFrameworkManager;
import org.apache.aries.application.management.spi.repository.BundleRepositoryManager;
@@ -61,39 +59,33 @@ public class ApplicationContextImpl impl
private DeploymentMetadata _deploymentMF;
public ApplicationContextImpl(AriesApplication app, ApplicationContextManagerImpl acm)
- throws BundleException, ManagementException
+ throws BundleException
{
LOGGER.debug(LOG_ENTRY, "ApplicationContextImpl", new Object[] { app, acm });
_bundleFrameworkManager = acm.getBundleFrameworkManager();
_bundleRepositoryManager = acm.getBundleRepositoryManager();
- _bundles = new HashSet<Bundle>();
+ _bundles = new LinkedHashSet<Bundle>();
_application = app;
_deploymentMF = _application.getDeploymentMetadata();
if (_deploymentMF.getApplicationDeploymentContents() != null
- && !_deploymentMF.getApplicationDeploymentContents().isEmpty()) {
- if (processContent())
- _state = ApplicationState.INSTALLED;
- }
+ && !_deploymentMF.getApplicationDeploymentContents().isEmpty())
+ install();
LOGGER.debug(LOG_EXIT, "ApplicationContextImpl", this);
}
/**
- * Called to install the application, if called multiple times the subsequent
- * calls will be ignored.
+ * Called to install the application.
* @return whether the installation is successful
*
*/
- private boolean processContent()
+ private void install() throws BundleException
{
LOGGER.debug(LOG_ENTRY, "install");
- boolean success = true;
- boolean provisionBundleInstall = false;
- boolean useBundleInstall = false;
List<DeploymentContent> bundlesToFind = new ArrayList<DeploymentContent>(_deploymentMF
.getApplicationDeploymentContents());
List<DeploymentContent> useBundlesToFind = new ArrayList<DeploymentContent>(_deploymentMF
@@ -101,26 +93,26 @@ public class ApplicationContextImpl impl
List<DeploymentContent> provisionBundlesToFind = new ArrayList<DeploymentContent>(_deploymentMF
.getApplicationProvisionBundles());
- provisionBundleInstall = install(provisionBundlesToFind, true);
- useBundleInstall = install(useBundlesToFind, true);
- success = install(bundlesToFind, false);
-
- if (success && provisionBundleInstall && useBundleInstall) {
+ try {
+
+ installBundles(provisionBundlesToFind, true);
+ installBundles(useBundlesToFind, true);
+ installBundles(bundlesToFind, false);
+
+ _state = ApplicationState.INSTALLED;
+
LOGGER.debug("Successfully installed application "
+ _application.getApplicationMetadata().getApplicationSymbolicName());
- } else {
+ } catch (BundleException e) {
LOGGER.debug(LOG_EXCEPTION, "Failed to install application "
+ _application.getApplicationMetadata().getApplicationSymbolicName());
+
uninstall();
+
+ throw e;
}
- // calculate installed again as we only claim install success
- // when provision bundle and use bundle are installed too.
- success = success && provisionBundleInstall && useBundleInstall;
-
- LOGGER.debug(LOG_EXIT, "install", new Object[] { Boolean.valueOf(success) });
-
- return success;
+ LOGGER.debug(LOG_EXIT, "install");
}
@@ -129,12 +121,10 @@ public class ApplicationContextImpl impl
* calls will be ignored.
* @return whether the uninstallation is successful
*/
- protected boolean uninstall()
+ protected synchronized void uninstall() throws BundleException
{
LOGGER.debug(LOG_ENTRY, "uninstall");
-
- int numErrorBundle = 0;
-
+
// Iterate through all of the bundles that were started when this application was started,
// and attempt to stop and uninstall each of them.
for (Iterator<Bundle> bundleIter = _bundles.iterator(); bundleIter.hasNext();) {
@@ -150,19 +140,15 @@ public class ApplicationContextImpl impl
_bundleFrameworkManager.uninstallBundle(bundleToRemove);
} catch (BundleException be) {
- numErrorBundle++;
LOGGER.debug(LOG_EXCEPTION, be);
+ throw be;
}
}
-
_bundles.clear();
+
+ _state = ApplicationState.UNINSTALLED;
- // return success only if all bundles were uninstalled successfully
- boolean result = (numErrorBundle == 0);
-
- LOGGER.debug(LOG_EXIT, "uninstall", new Object[] { Boolean.valueOf(result) });
-
- return result;
+ LOGGER.debug(LOG_EXIT, "uninstall");
}
@@ -172,23 +158,21 @@ public class ApplicationContextImpl impl
* @param shared whether the bundles will be shared or isolated
* @return the result of execution
*/
- private boolean install(List<DeploymentContent> bundlesToFind, boolean shared)
+ private void installBundles(List<DeploymentContent> bundlesToFind, boolean shared)
+ throws BundleException
{
LOGGER.debug(LOG_ENTRY, "install", new Object[] { bundlesToFind, Boolean.valueOf(shared) });
- int numException = 0; //log the number of exceptions, only assert success if no exception
-
if (!bundlesToFind.isEmpty() || !shared) {
Iterator<DeploymentContent> it = bundlesToFind.iterator();
/**
- * Dont install any bundles from the list which are already installed
+ * Dont install any bundles from the list which are already
+ * installed
*/
- Bundle[] sharedBundles =
- _bundleFrameworkManager.getSharedBundleFramework().
- getIsolatedBundleContext().
- getBundles();
+ Bundle[] sharedBundles = _bundleFrameworkManager.getSharedBundleFramework()
+ .getIsolatedBundleContext().getBundles();
if (shared) {
if (sharedBundles.length > 0) {
while (it.hasNext()) {
@@ -207,47 +191,45 @@ public class ApplicationContextImpl impl
}
/**
- * Ask the repository manager to find us a list of suggested bundles to install based on our
- * content list
+ * Ask the repository manager to find us a list of suggested bundles
+ * to install based on our content list
+ */
+ Map<DeploymentContent, BundleSuggestion> bundlesToBeInstalled =
+ findBundleSuggestions(bundlesToFind);
+
+ /**
+ * Perform the install of the bundles
*/
- Map<DeploymentContent, BundleSuggestion> bundlesToBeInstalled = new HashMap<DeploymentContent, BundleSuggestion>();
try {
- bundlesToBeInstalled = findBundleSuggestions(bundlesToFind);
- } catch (ContextException e) {
- numException++;
- LOGGER.debug(LOG_EXCEPTION, e);
- }
+ if (shared) _bundles.addAll(_bundleFrameworkManager.installSharedBundles(
+ new ArrayList<BundleSuggestion>(bundlesToBeInstalled.values()), _application));
+ else _bundles.add(_bundleFrameworkManager.installIsolatedBundles(
+ new ArrayList<BundleSuggestion>(bundlesToBeInstalled.values()), _application));
- if (numException == 0) {
- /**
- * Perform the install of the bundles
- */
- try {
- if (shared)
- _bundles.addAll(_bundleFrameworkManager.installSharedBundles(
- new ArrayList<BundleSuggestion>(bundlesToBeInstalled.values()), _application));
- else
- _bundles.add(_bundleFrameworkManager.installIsolatedBundles(
- new ArrayList<BundleSuggestion>(bundlesToBeInstalled.values()), _application));
-
- } catch (BundleException e) {
- numException++;
- LOGGER.debug(LOG_EXCEPTION, e);
- }
+ } catch (BundleException e) {
+ LOGGER.debug(LOG_EXCEPTION, e);
+ throw e;
}
}
+ LOGGER.debug(LOG_EXIT, "install");
- LOGGER.debug(LOG_EXIT, "install", new Object[] { Boolean.valueOf(numException == 0) });
-
- return (numException == 0);
}
-
- private Map<DeploymentContent, BundleSuggestion> findBundleSuggestions(Collection<DeploymentContent> bundlesToFind)
- throws ContextException
+
+ private Map<DeploymentContent, BundleSuggestion> findBundleSuggestions(
+ Collection<DeploymentContent> bundlesToFind) throws BundleException
{
- return _bundleRepositoryManager.getBundleSuggestions(_application
- .getApplicationMetadata().getApplicationSymbolicName(), _application
- .getApplicationMetadata().getApplicationVersion().toString(), bundlesToFind);
+ Map<DeploymentContent, BundleSuggestion> suggestions = null;
+ try {
+ suggestions = _bundleRepositoryManager.getBundleSuggestions(_application
+ .getApplicationMetadata().getApplicationSymbolicName(), _application
+ .getApplicationMetadata().getApplicationVersion().toString(), bundlesToFind);
+ } catch (ContextException e) {
+ LOGGER.debug(LOG_EXCEPTION, e);
+ throw new BundleException("Failed to locate bundle suggestions", e);
+ }
+
+ return suggestions;
+
}
public AriesApplication getApplication()
@@ -258,7 +240,7 @@ public class ApplicationContextImpl impl
return _application;
}
- public Set<Bundle> getApplicationContent()
+ public synchronized Set<Bundle> getApplicationContent()
{
LOGGER.debug(LOG_ENTRY, "getApplicationContent");
LOGGER.debug(LOG_EXIT, "getApplicationContent", new Object[] { _bundles });
@@ -266,7 +248,7 @@ public class ApplicationContextImpl impl
return _bundles;
}
- public ApplicationState getApplicationState()
+ public synchronized ApplicationState getApplicationState()
{
LOGGER.debug(LOG_ENTRY, "getApplicationState");
LOGGER.debug(LOG_EXIT, "getApplicationState", new Object[] { _state });
@@ -274,13 +256,14 @@ public class ApplicationContextImpl impl
return _state;
}
- public void start() throws BundleException
+ public synchronized void start() throws BundleException, IllegalStateException
{
LOGGER.debug(LOG_ENTRY, "start");
- ApplicationState oldState = _state;
- _state = ApplicationState.STARTING;
-
+ if (!(_state == ApplicationState.INSTALLED ||
+ _state == ApplicationState.RESOLVED))
+ throw new IllegalStateException("Appication is in incorrect state " + _state + " expected " + ApplicationState.INSTALLED + " or " + ApplicationState.RESOLVED);
+
List<Bundle> bundlesWeStarted = new ArrayList<Bundle>();
try {
for (Bundle b : _bundles) {
@@ -299,100 +282,98 @@ public class ApplicationContextImpl impl
LOGGER.debug(LOG_EXCEPTION, be2);
}
}
- _state = oldState;
LOGGER.debug(LOG_EXCEPTION, be);
LOGGER.debug(LOG_EXIT, "start", new Object[] { be });
throw be;
}
+
_state = ApplicationState.ACTIVE;
LOGGER.debug(LOG_EXIT, "start");
}
- public void stop() throws BundleException
+ public synchronized void stop() throws BundleException, IllegalStateException
{
LOGGER.debug(LOG_ENTRY, "stop");
-
+
+ if (_state != ApplicationState.ACTIVE)
+ throw new IllegalStateException("Appication is in incorrect state " + _state + " expected " + ApplicationState.ACTIVE);
+
for (Bundle entry : _bundles) {
Bundle b = entry;
_bundleFrameworkManager.stopBundle(b);
}
+
_state = ApplicationState.RESOLVED;
LOGGER.debug(LOG_EXIT, "stop");
}
- public void setState(ApplicationState state)
- {
- LOGGER.debug(LOG_ENTRY, "setState", new Object[] { _state, state });
-
- _state = state;
-
- LOGGER.debug(LOG_EXIT, "setState");
- }
-
- public void update(final DeploymentMetadata newMetadata, final DeploymentMetadata oldMetadata)
- throws UpdateException
+ public synchronized void update(final DeploymentMetadata newMetadata, final DeploymentMetadata oldMetadata)
+ throws UpdateException
{
final boolean toStart = getApplicationState() == ApplicationState.ACTIVE;
-
+
if (_bundleFrameworkManager.allowsUpdate(newMetadata, oldMetadata)) {
- _bundleFrameworkManager.updateBundles(
- newMetadata, oldMetadata,
- _application,
- new BundleFrameworkManager.BundleLocator() {
+ _bundleFrameworkManager.updateBundles(newMetadata, oldMetadata, _application,
+ new BundleFrameworkManager.BundleLocator() {
public Map<DeploymentContent, BundleSuggestion> suggestBundle(
- Collection<DeploymentContent> bundles) throws ContextException {
+ Collection<DeploymentContent> bundles) throws BundleException
+ {
return findBundleSuggestions(bundles);
}
- },
- _bundles,
- toStart);
-
+ }, _bundles, toStart);
+
} else {
// fallback do a uninstall, followed by a reinstall
-
- boolean uninstallSuccess = uninstall();
-
- if (uninstallSuccess) {
- _deploymentMF = newMetadata;
- boolean reinstallSuccess = processContent();
- Exception installException = null;
-
- if (reinstallSuccess) {
- if (toStart) {
- try {
- start();
- } catch (BundleException be) {
- reinstallSuccess = false;
- installException = be;
- }
- }
- }
-
- if (!!!reinstallSuccess) {
- boolean rollbackSuccess = uninstall();
- Exception rollbackException = null;
+ try {
+ uninstall();
+ _deploymentMF = newMetadata;
+ try {
+ install();
- if (rollbackSuccess) {
- _deploymentMF = oldMetadata;
- rollbackSuccess = processContent();
+ if (toStart)
+ start();
+ }
+ catch (BundleException e)
+ {
+ try {
+ uninstall();
- if (rollbackSuccess && toStart) {
- try {
- start();
- } catch (BundleException be) {
- rollbackException = be;
- rollbackSuccess = false;
- }
- }
- }
+ _deploymentMF = oldMetadata;
+ install();
+
+ if (toStart)
+ start();
- throw new UpdateException("Could not install updated application", installException, rollbackSuccess, rollbackException);
+ throw new UpdateException("Could not install updated application", e,
+ true, null);
+ }
+ catch (BundleException e2)
+ {
+ throw new UpdateException("Could not install updated application", e,
+ false, e2);
+ }
+ }
+ }
+ catch (BundleException e)
+ {
+ try {
+ _deploymentMF = oldMetadata;
+ install();
+
+ if (toStart)
+ start();
+
+ throw new UpdateException("Could not install updated application", e,
+ true, null);
}
- } else {
- throw new UpdateException("Could not uninstall old bundles", null, false, null);
+ catch (BundleException e2)
+ {
+ throw new UpdateException("Could not install updated application", e,
+ false, e2);
+ }
}
}
}
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-isolated/src/main/java/org/apache/aries/application/runtime/isolated/impl/ApplicationContextManagerImpl.java Mon Dec 13 18:26:19 2010
@@ -20,6 +20,7 @@
package org.apache.aries.application.runtime.isolated.impl;
import static org.apache.aries.application.utils.AppConstants.LOG_ENTRY;
+import static org.apache.aries.application.utils.AppConstants.LOG_EXCEPTION;
import static org.apache.aries.application.utils.AppConstants.LOG_EXIT;
import java.util.HashSet;
@@ -46,7 +47,7 @@ public class ApplicationContextManagerIm
{
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationContextManagerImpl.class);
- private ConcurrentMap<AriesApplication, ApplicationContextImpl> _appToContextMap;
+ private ConcurrentMap<AriesApplication, AriesApplicationContext> _appToContextMap;
private BundleFrameworkManager _bundleFrameworkManager;
private BundleRepositoryManager _bundleRepositoryManager;
@@ -54,7 +55,7 @@ public class ApplicationContextManagerIm
{
LOGGER.debug(LOG_ENTRY, "ApplicationContextImpl");
- _appToContextMap = new ConcurrentHashMap<AriesApplication, ApplicationContextImpl>();
+ _appToContextMap = new ConcurrentHashMap<AriesApplication, AriesApplicationContext>();
LOGGER.debug(LOG_EXIT, "ApplicationContextImpl", this);
}
@@ -88,12 +89,12 @@ public class ApplicationContextManagerIm
{
LOGGER.debug(LOG_ENTRY, "getApplicationContext", app);
- ApplicationContextImpl result;
+ AriesApplicationContext result;
if (_appToContextMap.containsKey(app)) {
result = _appToContextMap.get(app);
} else {
result = new ApplicationContextImpl(app, this);
- ApplicationContextImpl previous = _appToContextMap.putIfAbsent(app, result);
+ AriesApplicationContext previous = _appToContextMap.putIfAbsent(app, result);
if (previous != null) {
result = previous;
}
@@ -109,7 +110,7 @@ public class ApplicationContextManagerIm
LOGGER.debug(LOG_ENTRY, "getApplicationContexts");
Set<AriesApplicationContext> result = new HashSet<AriesApplicationContext>();
- for (Map.Entry<AriesApplication, ApplicationContextImpl> entry : _appToContextMap.entrySet()) {
+ for (Map.Entry<AriesApplication, AriesApplicationContext> entry : _appToContextMap.entrySet()) {
result.add(entry.getValue());
}
@@ -118,49 +119,46 @@ public class ApplicationContextManagerIm
return result;
}
- public synchronized void remove(AriesApplicationContext app)
+ public synchronized void remove(AriesApplicationContext app) throws BundleException
{
LOGGER.debug(LOG_ENTRY, "remove", app);
- Iterator<Map.Entry<AriesApplication, ApplicationContextImpl>> it = _appToContextMap.entrySet()
+ Iterator<Map.Entry<AriesApplication, AriesApplicationContext>> it = _appToContextMap.entrySet()
.iterator();
while (it.hasNext()) {
- Map.Entry<AriesApplication, ApplicationContextImpl> entry = it.next();
+ Map.Entry<AriesApplication, AriesApplicationContext> entry = it.next();
- ApplicationContextImpl potentialMatch = entry.getValue();
+ ApplicationContextImpl potentialMatch = (ApplicationContextImpl) entry.getValue();
if (potentialMatch == app) {
it.remove();
- uninstall(potentialMatch);
+ potentialMatch.uninstall();
break;
}
}
-
+
LOGGER.debug(LOG_EXIT, "remove");
}
-
- private void uninstall(ApplicationContextImpl app)
- {
- LOGGER.debug(LOG_ENTRY, "uninstall", app);
-
- if (app.uninstall())
- app.setState(ApplicationState.UNINSTALLED);
-
- LOGGER.debug(LOG_EXIT, "uninstall");
- }
-
+
public synchronized void close()
{
LOGGER.debug(LOG_ENTRY, "close");
- for (ApplicationContextImpl ctx : _appToContextMap.values()) {
- uninstall(ctx);
+ Iterator<AriesApplicationContext> it = _appToContextMap.values().iterator();
+ while (it.hasNext())
+ {
+ try {
+ ApplicationContextImpl ctx = (ApplicationContextImpl)it.next();
+ ctx.uninstall();
+ it.remove();
+ } catch (BundleException e)
+ {
+ LOGGER.debug(LOG_EXCEPTION,e);
+ }
}
-
- _appToContextMap.clear();
LOGGER.debug(LOG_EXIT, "close");
}
@@ -174,7 +172,7 @@ public class ApplicationContextManagerIm
}
public AriesApplicationContext update(AriesApplication app, DeploymentMetadata oldMetadata) throws UpdateException {
- ApplicationContextImpl ctx = _appToContextMap.get(app);
+ ApplicationContextImpl ctx = (ApplicationContextImpl)_appToContextMap.get(app);
if (ctx == null) {
throw new IllegalArgumentException("AriesApplication "+
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-repository/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-repository/pom.xml?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-repository/pom.xml (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-runtime-repository/pom.xml Mon Dec 13 18:26:19 2010
@@ -32,6 +32,14 @@
An bundle repository runtime implementation
</description>
+ <properties>
+ <aries.osgi.export.pkg>
+ </aries.osgi.export.pkg>
+ <aries.osgi.private.pkg>
+ org.apache.aries.application.runtime.repository
+ </aries.osgi.private.pkg>
+ </properties>
+
<dependencies>
<dependency>
<groupId>junit</groupId>
Propchange: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-twitter4j/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Dec 13 18:26:19 2010
@@ -0,0 +1,4 @@
+target
+.classpath
+.project
+.settings
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/impl/DeploymentMetadataImpl.java Mon Dec 13 18:26:19 2010
@@ -286,7 +286,7 @@ public class DeploymentMetadataImpl impl
return Collections.unmodifiableSet(_deploymentImportPackage);
}
- public Collection<Filter> getDeployedServiceImport() throws InvalidAttributeException
+ public Collection<Filter> getDeployedServiceImport()
{
return Collections.unmodifiableCollection(_deployedImportService);
}
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/utils/AppConstants.java Mon Dec 13 18:26:19 2010
@@ -79,6 +79,8 @@ public interface AppConstants
public static final String DEPLOYMENT_PROVISION_BUNDLE = "Provision-Bundle";
/** Blueprint managed services imported by the isolated bundles */
public static final String DEPLOYMENTSERVICE_IMPORT = "DeployedService-Import";
+
+ public static final String PROVISON_EXCLUDE_LOCAL_REPO_SYSPROP="provision.exclude.local.repository";
/**
* Logging insert strings
*/
Modified: incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java
URL: http://svn.apache.org/viewvc/incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java?rev=1045274&r1=1045273&r2=1045274&view=diff
==============================================================================
--- incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java (original)
+++ incubator/aries/sandbox/jbohn/interceptor-proto/application/application-utils/src/main/java/org/apache/aries/application/utils/filesystem/IOUtils.java Mon Dec 13 18:26:19 2010
@@ -34,6 +34,7 @@ import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
+import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream;
@@ -48,10 +49,7 @@ public class IOUtils
public static void copy(InputStream in, OutputStream out) throws IOException
{
try {
- int len;
- byte[] b = new byte[1024];
- while ((len = in.read(b)) != -1)
- out.write(b,0,len);
+ copyAndDoNotCloseInputStream(in, out);
}
finally {
close(in);
@@ -59,6 +57,17 @@ public class IOUtils
}
/**
+ * Copy an InputStream to an OutputStream and do not close the InputStream afterwards.
+ */
+ public static void copyAndDoNotCloseInputStream(InputStream in, OutputStream out) throws IOException
+ {
+ int len;
+ byte[] b = new byte[1024];
+ while ((len = in.read(b)) != -1)
+ out.write(b,0,len);
+ }
+
+ /**
* Close some xStream for good :)
*/
public static void close(Closeable c)
@@ -67,7 +76,19 @@ public class IOUtils
if (c != null)
c.close();
}
- catch (IOException e) { c=null; } //in other words do nothing in a language findbugs can understand
+ catch (IOException e) {
+ c = null;
+ }
+ }
+
+ /**
+ * A special version of close() for ZipFiles, which don't implement Closeable.
+ * @param file the file to close. ZipFiles seem prone to file locking problems
+ * on Windows, so to aid diagnostics we throw, not swallow, any exceptions.
+ */
+ public static void close(ZipFile file) throws IOException
+ {
+ if (file != null) file.close();
}
public static OutputStream getOutputStream(File outputDir, String relativePath) throws IOException
@@ -81,18 +102,18 @@ public class IOUtils
{
dirName = relativePath.substring(0, lastSeparatorIndex);
fileName = relativePath.substring(lastSeparatorIndex + 1);
+
outputDirectory = new File(outputDir, dirName);
+ if (!!!outputDirectory.exists() && !!!outputDirectory.mkdirs())
+ throw new IOException(MessageUtil.getMessage("APPUTILS0012E", relativePath));
}
else
{
outputDirectory = outputDir;
fileName = relativePath;
}
- if (!!!outputDirectory.exists() && !!!outputDirectory.mkdirs()) {
- throw new IOException(MessageUtil.getMessage("APPUTILS0012E", relativePath));
- }
-
+
File outputFile = new File(outputDirectory, fileName);
return new FileOutputStream(outputFile);
}
@@ -113,7 +134,23 @@ public class IOUtils
}
}
- /**
+ /**
+ * Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.
+ * Necessary subdirectories will be created. This method will not close the supplied InputStream.
+ */
+ public static void writeOutAndDontCloseInputStream(File outputDir, String relativePath, InputStream content) throws IOException
+ {
+ OutputStream out = null;
+ try {
+ out = getOutputStream(outputDir, relativePath);
+ IOUtils.copyAndDoNotCloseInputStream(content, out);
+ }
+ finally {
+ close(out);
+ }
+ }
+
+ /**
* Zip up all contents of rootDir (recursively) into targetStream
*/
@SuppressWarnings("unchecked")
@@ -131,9 +168,17 @@ public class IOUtils
/**
* Zip up all contents of rootDir (recursively) into targetFile
*/
+ @SuppressWarnings("unchecked")
public static void zipUp(File rootDir, File targetFile) throws IOException
{
- zipUp (rootDir, new FileOutputStream (targetFile));
+ ZipOutputStream out = null;
+ try {
+ out = new ZipOutputStream(new FileOutputStream(targetFile));
+ zipUpRecursive(out, "", rootDir, (Set<String>) Collections.EMPTY_SET);
+ }
+ finally {
+ close(out);
+ }
}
/**
@@ -232,11 +277,6 @@ public class IOUtils
do {
if (!zipEntry.isDirectory()) {
writeOutAndDontCloseInputStream(outputDir, zipEntry.getName(), zis);
- } else {
- File f = new File (outputDir, zipEntry.getName());
- if (!f.exists()) {
- success &= f.mkdirs();
- }
}
zis.closeEntry();
zipEntry = zis.getNextEntry();
@@ -250,31 +290,5 @@ public class IOUtils
return success;
}
- /**
- * Write the given InputStream to a file given by a root directory (outputDir) and a relative directory.
- * Necessary subdirectories will be created. This method will not close the supplied InputStream.
- */
- public static void writeOutAndDontCloseInputStream(File outputDir, String relativePath, InputStream content) throws IOException
- {
- OutputStream out = null;
- try {
- out = getOutputStream(outputDir, relativePath);
- IOUtils.copyAndDoNotCloseInputStream(content, out);
- }
- finally {
- close(out);
- }
- }
-
- /**
- * Copy an InputStream to an OutputStream and do not close the InputStream afterwards.
- */
- public static void copyAndDoNotCloseInputStream(InputStream in, OutputStream out) throws IOException
- {
- int len;
- byte[] b = new byte[1024];
- while ((len = in.read(b)) != -1)
- out.write(b,0,len);
- }
-}
+}