[
https://issues.apache.org/jira/browse/FELIX-4167?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13712376#comment-13712376
]
Andrej Zachar edited comment on FELIX-4167 at 7/18/13 2:36 PM:
---------------------------------------------------------------
Hello Apache Ace!
We had a similar problem and I patched the code, here is the implementation:
Index: src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
===================================================================
--- src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
(revision 1493938)
+++ src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
(working copy)
@@ -22,6 +22,7 @@
import org.apache.felix.deploymentadmin.BundleInfoImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.service.deploymentadmin.BundleInfo;
import org.osgi.service.deploymentadmin.DeploymentException;
import org.osgi.service.log.LogService;
@@ -49,6 +50,10 @@
String symbolicName = bundleInfos[i].getSymbolicName();
Bundle bundle = target.getBundle(symbolicName);
if (bundle != null) {
+ boolean isFragment =
bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
+ if (isFragment) {
+ continue;
+ }
if ("false".equalsIgnoreCase(stopUnaffectedBundle) &&
omitBundleStop(session, symbolicName)) {
continue;
}
Index:
src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
===================================================================
--- src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
(revision 1493938)
+++ src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
(working copy)
@@ -22,6 +22,7 @@
import org.apache.felix.deploymentadmin.BundleInfoImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.service.log.LogService;
@@ -51,11 +52,16 @@
if(!bundleInfoImpl.isCustomizer()) {
Bundle bundle =
source.getBundle(bundleInfoImpl.getSymbolicName());
if (bundle != null) {
- try {
- bundle.start();
- }
- catch (BundleException be) {
- log.log(LogService.LOG_WARNING, "Could not start
bundle '" + bundle.getSymbolicName() + "'", be);
+ boolean isFragment =
bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
+ if (isFragment) {
+ log.log(LogService.LOG_INFO, "Skipping starting
fragment bundle '" + bundleInfoImpl.getSymbolicName() + "'");
+ } else {
+ try {
+ bundle.start();
+ }
+ catch (BundleException be) {
+ log.log(LogService.LOG_WARNING, "Could not start
bundle '" + bundle.getSymbolicName() + "'", be);
+ }
}
}
else {
was (Author: azachar):
Hello Apache Ace!
We had similar problem and I patched the code, here is the implementation:
Index: src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
===================================================================
--- src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
(revision 1493938)
+++ src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
(working copy)
@@ -22,6 +22,7 @@
import org.apache.felix.deploymentadmin.BundleInfoImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.service.deploymentadmin.BundleInfo;
import org.osgi.service.deploymentadmin.DeploymentException;
import org.osgi.service.log.LogService;
@@ -49,6 +50,10 @@
String symbolicName = bundleInfos[i].getSymbolicName();
Bundle bundle = target.getBundle(symbolicName);
if (bundle != null) {
+ boolean isFragment =
bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
+ if (isFragment) {
+ continue;
+ }
if ("false".equalsIgnoreCase(stopUnaffectedBundle) &&
omitBundleStop(session, symbolicName)) {
continue;
}
Index:
src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
===================================================================
--- src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
(revision 1493938)
+++ src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
(working copy)
@@ -22,6 +22,7 @@
import org.apache.felix.deploymentadmin.BundleInfoImpl;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkEvent;
import org.osgi.framework.FrameworkListener;
import org.osgi.service.log.LogService;
@@ -51,11 +52,16 @@
if(!bundleInfoImpl.isCustomizer()) {
Bundle bundle =
source.getBundle(bundleInfoImpl.getSymbolicName());
if (bundle != null) {
- try {
- bundle.start();
- }
- catch (BundleException be) {
- log.log(LogService.LOG_WARNING, "Could not start
bundle '" + bundle.getSymbolicName() + "'", be);
+ boolean isFragment =
bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
+ if (isFragment) {
+ log.log(LogService.LOG_INFO, "Skipping starting
fragment bundle '" + bundleInfoImpl.getSymbolicName() + "'");
+ } else {
+ try {
+ bundle.start();
+ }
+ catch (BundleException be) {
+ log.log(LogService.LOG_WARNING, "Could not start
bundle '" + bundle.getSymbolicName() + "'", be);
+ }
}
}
else {
> DeploymentAdmin tries to start/stop fragment bundles
> ----------------------------------------------------
>
> Key: FELIX-4167
> URL: https://issues.apache.org/jira/browse/FELIX-4167
> Project: Felix
> Issue Type: Bug
> Components: Deployment Admin
> Reporter: J.W. Janssen
>
> Deployment Admin currently tries to start all bundles in a deployment
> package, including fragment bundles. Although this fails, the installation of
> the deployment package still succeeds. Nevertheless, it is sloppy to do this.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira