use of org.apache.felix.deploymentadmin.BundleInfoImpl in project felix by apache.
the class DropAllBundlesCommand method doExecute.
protected void doExecute(DeploymentSessionImpl session) throws Exception {
AbstractDeploymentPackage target = session.getTargetAbstractDeploymentPackage();
LogService log = session.getLog();
BundleInfoImpl[] orderedTargetBundles = target.getOrderedBundleInfos();
for (int i = orderedTargetBundles.length - 1; i >= 0; i--) {
BundleInfoImpl bundleInfo = orderedTargetBundles[i];
// stale bundle, save a copy for rolling back and uninstall it
String symbolicName = bundleInfo.getSymbolicName();
try {
Bundle bundle = target.getBundle(symbolicName);
if (bundle != null) {
bundle.uninstall();
addRollback(new InstallBundleRunnable(bundle, target, log));
}
} catch (Exception be) {
log.log(LogService.LOG_WARNING, "Bundle '" + symbolicName + "' could not be uninstalled", be);
}
}
}
use of org.apache.felix.deploymentadmin.BundleInfoImpl in project felix by apache.
the class DropBundleCommand method doExecute.
protected void doExecute(DeploymentSessionImpl session) throws Exception {
AbstractDeploymentPackage target = session.getTargetAbstractDeploymentPackage();
AbstractDeploymentPackage source = session.getSourceAbstractDeploymentPackage();
LogService log = session.getLog();
BundleInfoImpl[] orderedTargetBundles = target.getOrderedBundleInfos();
for (int i = orderedTargetBundles.length - 1; i >= 0; i--) {
BundleInfoImpl bundleInfo = orderedTargetBundles[i];
String symbolicName = bundleInfo.getSymbolicName();
if (!bundleInfo.isCustomizer() && source.getBundleInfoByName(symbolicName) == null) {
// stale bundle, save a copy for rolling back and uninstall it
try {
Bundle bundle = target.getBundle(symbolicName);
bundle.uninstall();
addRollback(new InstallBundleRunnable(bundle, target, log));
} catch (Exception be) {
log.log(LogService.LOG_WARNING, "Bundle '" + symbolicName + "' could not be uninstalled", be);
}
}
}
}
use of org.apache.felix.deploymentadmin.BundleInfoImpl in project felix by apache.
the class StartBundleCommand method doExecute.
protected void doExecute(DeploymentSessionImpl session) throws Exception {
AbstractDeploymentPackage source = session.getSourceAbstractDeploymentPackage();
PackageAdmin packageAdmin = session.getPackageAdmin();
RefreshPackagesListener listener = new RefreshPackagesListener();
LogService log = session.getLog();
session.getBundleContext().addFrameworkListener(listener);
packageAdmin.refreshPackages(null);
m_refreshMonitor.waitForRefresh();
session.getBundleContext().removeFrameworkListener(listener);
// start source bundles
BundleInfoImpl[] bundleInfos = source.getOrderedBundleInfos();
for (int i = 0; i < bundleInfos.length; i++) {
BundleInfoImpl bundleInfoImpl = bundleInfos[i];
if (!bundleInfoImpl.isCustomizer()) {
String symbolicName = bundleInfoImpl.getSymbolicName();
Bundle bundle = source.getBundle(symbolicName);
if (bundle != null) {
if (isFragmentBundle(bundle)) {
log.log(LogService.LOG_INFO, "Skipping fragment bundle '" + symbolicName + "'");
} else {
try {
bundle.start();
} catch (Exception be) {
log.log(LogService.LOG_WARNING, "Could not start bundle '" + symbolicName + "'", be);
}
}
} else {
log.log(LogService.LOG_WARNING, "Could not start bundle '" + symbolicName + "' because it is not present in the framework");
}
}
}
}
use of org.apache.felix.deploymentadmin.BundleInfoImpl in project felix by apache.
the class StartCustomizerCommand method doExecute.
protected void doExecute(DeploymentSessionImpl session) throws Exception {
AbstractDeploymentPackage target = session.getTargetAbstractDeploymentPackage();
AbstractDeploymentPackage source = session.getSourceAbstractDeploymentPackage();
Set bundles = new HashSet();
Set sourceBundlePaths = new HashSet();
BundleInfoImpl[] targetInfos = target.getBundleInfoImpls();
BundleInfoImpl[] sourceInfos = source.getBundleInfoImpls();
for (int i = 0; i < sourceInfos.length; i++) {
if (sourceInfos[i].isCustomizer()) {
sourceBundlePaths.add(sourceInfos[i].getPath());
Bundle bundle = source.getBundle(sourceInfos[i].getSymbolicName());
if (bundle != null) {
bundles.add(bundle);
}
}
}
for (int i = 0; i < targetInfos.length; i++) {
if (targetInfos[i].isCustomizer() && !sourceBundlePaths.contains(targetInfos[i].getPath())) {
Bundle bundle = target.getBundle(targetInfos[i].getSymbolicName());
if (bundle != null) {
bundles.add(bundle);
}
}
}
for (Iterator i = bundles.iterator(); i.hasNext(); ) {
Bundle bundle = (Bundle) i.next();
try {
bundle.start();
} catch (Exception be) {
throw new DeploymentException(CODE_OTHER_ERROR, "Could not start customizer bundle '" + bundle.getSymbolicName() + "'", be);
}
addRollback(new StopCustomizerRunnable(session, bundle));
}
}
use of org.apache.felix.deploymentadmin.BundleInfoImpl in project felix by apache.
the class StopBundleCommand method omitBundleStop.
/**
* Determines whether stopping a bundle is strictly needed.
*
* @param session The current deployment session.
* @param symbolicName The symbolic name of the bundle to inspect.
*
* @return Returns <code>true</code> if
* <code>Constants.DEPLOYMENTPACKAGE_MISSING</code> is true for the
* specified bundle in the source deployment package or if the
* version of the bundle is the same in both source and target
* deployment package. Returns <code>false</code> otherwise.
*/
private boolean omitBundleStop(DeploymentSessionImpl session, String symbolicName) {
boolean stopUnaffectedBundles = session.getConfiguration().isStopUnaffectedBundles();
if (stopUnaffectedBundles) {
// Default behavior: stop all bundles (see spec)...
return false;
}
BundleInfoImpl sourceBundleInfo = session.getSourceAbstractDeploymentPackage().getBundleInfoByName(symbolicName);
BundleInfoImpl targetBundleInfo = session.getTargetAbstractDeploymentPackage().getBundleInfoByName(symbolicName);
boolean fixPackageMissing = sourceBundleInfo != null && sourceBundleInfo.isMissing();
boolean sameVersion = (targetBundleInfo != null && sourceBundleInfo != null && targetBundleInfo.getVersion().equals(sourceBundleInfo.getVersion()));
return (fixPackageMissing || sameVersion);
}
Aggregations