You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2009/12/03 07:31:50 UTC

svn commit: r886684 - in /geronimo/server/trunk/framework/modules: geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/ geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/ geronimo-system/src/main/java/org/apache/geronimo/system/...

Author: gawor
Date: Thu Dec  3 06:31:46 2009
New Revision: 886684

URL: http://svn.apache.org/viewvc?rev=886684&view=rev
Log:
do not start fragment bundles - they cannot be started

Added:
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java   (with props)
Modified:
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
    geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java?rev=886684&r1=886683&r2=886684&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/config/SimpleConfigurationManager.java Thu Dec  3 06:31:46 2009
@@ -35,6 +35,7 @@
 import org.apache.geronimo.gbean.annotation.ParamSpecial;
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.kernel.management.State;
+import org.apache.geronimo.kernel.osgi.BundleUtils;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.ArtifactResolver;
 import org.apache.geronimo.kernel.repository.Dependency;
@@ -296,7 +297,7 @@
         try {
             String location = locateBundle(configurationId, monitor);
             Bundle bundle = bundleContext.installBundle(location);
-            if (bundle.getState() != Bundle.STARTING) {
+            if (BundleUtils.canStart(bundle)) {
                 bundle.start(Bundle.START_TRANSIENT);
             }
             bundles.put(configurationId, bundle);

Added: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java?rev=886684&view=auto
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java (added)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java Thu Dec  3 06:31:46 2009
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.kernel.osgi;
+
+import java.util.Dictionary;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.Constants;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class BundleUtils {
+   
+    public static boolean canStart(Bundle bundle) {
+        return (bundle.getState() != Bundle.STARTING)  && (!isFragment(bundle));
+    }
+    
+    public static boolean isFragment(Bundle bundle) {
+        Dictionary headers = bundle.getHeaders();
+        return (headers != null && headers.get(Constants.FRAGMENT_HOST) != null);
+    }
+}

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/framework/modules/geronimo-kernel/src/main/java/org/apache/geronimo/kernel/osgi/BundleUtils.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java?rev=886684&r1=886683&r2=886684&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/DependencyManager.java Thu Dec  3 06:31:46 2009
@@ -33,6 +33,7 @@
 import org.apache.geronimo.gbean.annotation.SpecialAttributeType;
 import org.apache.geronimo.kernel.config.InvalidConfigException;
 import org.apache.geronimo.kernel.config.NoSuchConfigException;
+import org.apache.geronimo.kernel.osgi.BundleUtils;
 import org.apache.geronimo.kernel.repository.Artifact;
 import org.apache.geronimo.kernel.repository.Repository;
 import org.apache.geronimo.system.plugin.model.DependencyType;
@@ -98,10 +99,12 @@
                         }
                     }
                     for (Bundle b : bundles) {
-                        try {
-                            b.start(Bundle.START_TRANSIENT);
-                        } catch (BundleException e) {
-                            log.warn("Could not start bundle: " + b, e);
+                        if (BundleUtils.canStart(b)) {
+                            try {
+                                b.start(Bundle.START_TRANSIENT);
+                            } catch (BundleException e) {
+                                log.warn("Could not start bundle: " + b, e);
+                            }
                         }
                     }
                 } catch (Throwable e) {