felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1504843 - in /felix/trunk/deploymentadmin/deploymentadmin: ./ src/main/java/org/apache/felix/deploymentadmin/spi/
Date Fri, 19 Jul 2013 11:40:05 GMT
Author: jawi
Date: Fri Jul 19 11:40:04 2013
New Revision: 1504843

URL: http://svn.apache.org/r1504843
Log:
FELIX-4167: do not try to start or stop fragment bundles.


Modified:
    felix/trunk/deploymentadmin/deploymentadmin/   (props changed)
    felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/Command.java
    felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
    felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java

Propchange: felix/trunk/deploymentadmin/deploymentadmin/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Fri Jul 19 11:40:04 2013
@@ -1 +1,4 @@
 target
+.project
+.classpath
+.settings

Modified: felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/Command.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/Command.java?rev=1504843&r1=1504842&r2=1504843&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/Command.java
(original)
+++ felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/Command.java
Fri Jul 19 11:40:04 2013
@@ -22,6 +22,8 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.ListIterator;
 
+import org.apache.felix.deploymentadmin.Constants;
+import org.osgi.framework.Bundle;
 import org.osgi.service.deploymentadmin.DeploymentException;
 
 /**
@@ -105,7 +107,7 @@ public abstract class Command {
     protected void addCommit(Runnable runnable) {
         m_commit.add(runnable);
     }
-
+    
     /**
      * Sets the command to being cancelled, this does not have an immediate effect. Commands
that are executing should
      * check regularly if they were cancelled and if so they should make an effort to stop
their operations as soon as possible
@@ -114,4 +116,14 @@ public abstract class Command {
     public void cancel() {
         m_cancelled = true;
     }
+
+    /**
+     * Determines whether a given bundle is actually a fragment bundle.
+     * @param bundle the bundle to test, cannot be <code>null</code>.
+     * @return <code>true</code> if the given bundle is actually a fragment bundle,
<code>false</code> otherwise.
+     */
+    static final boolean isFragmentBundle(Bundle bundle) {
+        Object fragmentHost = bundle.getHeaders().get(Constants.FRAGMENT_HOST);
+        return fragmentHost != null;
+    }
 }

Modified: felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java?rev=1504843&r1=1504842&r2=1504843&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
(original)
+++ felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StartBundleCommand.java
Fri Jul 19 11:40:04 2013
@@ -48,14 +48,18 @@ public class StartBundleCommand extends 
         BundleInfoImpl[] bundleInfos = source.getOrderedBundleInfos();
         for (int i = 0; i < bundleInfos.length; i++) {
             BundleInfoImpl bundleInfoImpl = bundleInfos[i];
-            if(!bundleInfoImpl.isCustomizer()) {
+            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);
+                    if (isFragmentBundle(bundle)) {
+                        log.log(LogService.LOG_INFO, "Skipping fragment bundle '" + bundle.getSymbolicName()
+ "'");
+                    } else {
+                        try {
+                            bundle.start();
+                        }
+                        catch (BundleException be) {
+                            log.log(LogService.LOG_WARNING, "Could not start bundle '" +
bundle.getSymbolicName() + "'", be);
+                        }
                     }
                 }
                 else {

Modified: felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
URL: http://svn.apache.org/viewvc/felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java?rev=1504843&r1=1504842&r2=1504843&view=diff
==============================================================================
--- felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
(original)
+++ felix/trunk/deploymentadmin/deploymentadmin/src/main/java/org/apache/felix/deploymentadmin/spi/StopBundleCommand.java
Fri Jul 19 11:40:04 2013
@@ -39,6 +39,8 @@ public class StopBundleCommand extends C
 
     public void execute(DeploymentSessionImpl session) throws DeploymentException {
         String stopUnaffectedBundle = System.getProperty("org.apache.felix.deploymentadmin.stopunaffectedbundle",
"true");
+
+        LogService log = session.getLog();
         
         AbstractDeploymentPackage target = session.getTargetAbstractDeploymentPackage();
         BundleInfo[] bundleInfos = target.getOrderedBundleInfos();
@@ -52,16 +54,20 @@ public class StopBundleCommand extends C
         		if ("false".equalsIgnoreCase(stopUnaffectedBundle) && omitBundleStop(session,
symbolicName)) {
         			continue;
         		}
-                addRollback(new StartBundleRunnable(session, bundle));
-                try {
-                    bundle.stop();
-                }
-                catch (BundleException e) {
-                	session.getLog().log(LogService.LOG_WARNING, "Could not stop bundle '" +
bundle.getSymbolicName() + "'", e);
-                }
+        		if (isFragmentBundle(bundle)) {
+                    log.log(LogService.LOG_INFO, "Skipping fragment bundle '" + bundle.getSymbolicName()
+ "'");
+        		} else {
+        		    addRollback(new StartBundleRunnable(session, bundle));
+        		    try {
+        		        bundle.stop();
+        		    }
+        		    catch (BundleException e) {
+        		        log.log(LogService.LOG_WARNING, "Could not stop bundle '" + bundle.getSymbolicName()
+ "'", e);
+        		    }
+        		}
             }
             else {
-            	session.getLog().log(LogService.LOG_WARNING, "Could not stop bundle '" + symbolicName
+ "' because it was not defined int he framework");
+            	log.log(LogService.LOG_WARNING, "Could not stop bundle '" + symbolicName + "'
because it was not defined int he framework");
             }
         }
     }



Mime
View raw message