Skip to content
Permalink
Browse files
Added a whole collection of tests to ensure that DeploymentAdmin conf…
…orms to the specification and works correctly. Refactored some of the code. Specifically modified the uninstall behavior to make it spec compliant.

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1352090 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
m4rr5 committed Jun 20, 2012
1 parent 974feb6 commit adc011e16bbdebec2b3cd8cb65123750e31fdc5c
Show file tree
Hide file tree
Showing 47 changed files with 4,490 additions and 155 deletions.
@@ -146,10 +146,14 @@ public Bundle getBundle(String symbolicName) {
if (isStale()) {
throw new IllegalStateException("Can not get bundle from stale deployment package.");
}
if (m_nameToBundleInfo.containsKey(symbolicName)) {

BundleInfo bundleInfo = (BundleInfo) m_nameToBundleInfo.get(symbolicName);
if (bundleInfo != null) {
Version version = bundleInfo.getVersion();

Bundle[] bundles = m_bundleContext.getBundles();
for (int i = 0; i < bundles.length; i++) {
if (symbolicName.equals(bundles[i].getSymbolicName())) {
if (symbolicName.equals(bundles[i].getSymbolicName()) && version.equals(bundles[i].getVersion())) {
return bundles[i];
}
}
@@ -272,6 +276,14 @@ public boolean isStale() {
return m_isStale;
}

/**
* @return <code>true</code> if this package is actually an empty package used for
* installing new deployment packages, <code>false</code> otherwise.
*/
public boolean isNew() {
return this == EMPTY_PACKAGE;
}

public void setStale(boolean isStale) {
m_isStale = isStale;
}
@@ -280,12 +292,23 @@ public void uninstall() throws DeploymentException {
if (isStale()) {
throw new IllegalStateException("Deployment package is stale, cannot uninstall.");
}
m_deploymentAdmin.uninstallDeploymentPackage(this);
setStale(true);
try {
m_deploymentAdmin.uninstallDeploymentPackage(this, false /* force */);
} finally {
setStale(true);
}
}

public boolean uninstallForced() throws DeploymentException {
throw new IllegalStateException("Not implemented, use uninstall() for now.");
if (isStale()) {
throw new IllegalStateException("Deployment package is stale, cannot uninstall.");
}
try {
m_deploymentAdmin.uninstallDeploymentPackage(this, true /* force */);
} finally {
setStale(true);
}
return true;
}

/**
@@ -18,6 +18,8 @@
*/
package org.apache.felix.deploymentadmin;

import org.osgi.service.deploymentadmin.DeploymentPackage;

public interface Constants extends org.osgi.framework.Constants {

// manifest main attribute header constants
@@ -34,7 +36,11 @@ public interface Constants extends org.osgi.framework.Constants {
public static final String EVENTTOPIC_INSTALL = "org/osgi/service/deployment/INSTALL";
public static final String EVENTTOPIC_UNINSTALL = "org/osgi/service/deployment/UNINSTALL";
public static final String EVENTTOPIC_COMPLETE = "org/osgi/service/deployment/COMPLETE";
public static final String EVENTPROPERTY_DEPLOYMENTPACKAGE_NAME = "deploymentpackage.name";

public static final String EVENTPROPERTY_DEPLOYMENTPACKAGE_NAME = DeploymentPackage.EVENT_DEPLOYMENTPACKAGE_NAME;
public static final String EVENTPROPERTY_DEPLOYMENTPACKAGE_READABLENAME = DeploymentPackage.EVENT_DEPLOYMENTPACKAGE_READABLENAME;
public static final String EVENTPROPERTY_DEPLOYMENTPACKAGE_CURRENTVERSION = DeploymentPackage.EVENT_DEPLOYMENTPACKAGE_CURRENTVERSION;
public static final String EVENTPROPERTY_DEPLOYMENTPACKAGE_NEXTVERSION = DeploymentPackage.EVENT_DEPLOYMENTPACKAGE_NEXTVERSION;
public static final String EVENTPROPERTY_SUCCESSFUL = "successful";

// miscellaneous constants

0 comments on commit adc011e

Please sign in to comment.