Fix a few problems with command bundles not starting correctly

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@771938 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/FeaturesRegistry.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/FeaturesRegistry.java
index fcf8689..b67c98c 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/FeaturesRegistry.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/FeaturesRegistry.java
@@ -21,6 +21,9 @@
  * Tracks features and repositories.
  */
 public interface FeaturesRegistry {
+
+    void setFeaturesService(FeaturesService service);
+
     void register(Feature feature);
 
     void unregister(Feature feature);
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/internal/FeaturesServiceImpl.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/internal/FeaturesServiceImpl.java
index 59446b6..41facc4 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/internal/FeaturesServiceImpl.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/internal/FeaturesServiceImpl.java
@@ -105,6 +105,7 @@
 
     public void setFeaturesServiceRegistry(FeaturesRegistry featuresRegistry) {
         this.featuresRegistry = featuresRegistry;
+        this.featuresRegistry.setFeaturesService(this);
     }
 
     public void setUrls(String uris) throws URISyntaxException {
diff --git a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagedFeaturesRegistry.java b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagedFeaturesRegistry.java
index 90624b7..d62eed9 100644
--- a/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagedFeaturesRegistry.java
+++ b/karaf/gshell/gshell-features/src/main/java/org/apache/felix/karaf/gshell/features/management/ManagedFeaturesRegistry.java
@@ -48,6 +48,7 @@
     private Map<String, ManagedRepository> repositories;
     private boolean mbeanServerInitialized;
     private FeaturesService featuresService;
+    private MBeanServer mbeanServer;
 
     @ManagedOperation
     public void installFeature(String name) throws Exception {
@@ -182,12 +183,19 @@
         if (namingStrategy == null) {
             throw new IllegalArgumentException("namingStrategy must not be null");
         }
+        if (mbeanServer != null) {
+            registerMBeanServer(mbeanServer, null);
+        }
     }
 
     public void registerMBeanServer(MBeanServer mbeanServer, Map props ) throws Exception {
         if (mbeanServer != null) {
-            mbeanServerInitialized = true;
+            this.mbeanServer = mbeanServer;
         }
+        if (managementAgent == null) {
+            return;
+        }
+        mbeanServerInitialized = true;
 
         managementAgent.register(this, namingStrategy.getObjectName(this));
 
diff --git a/karaf/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml b/karaf/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml
index 22a4b95..d1b851d 100644
--- a/karaf/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml
+++ b/karaf/gshell/gshell-features/src/main/resources/META-INF/spring/gshell-features.xml
@@ -39,7 +39,7 @@
   http://servicemix.apache.org/schema/servicemix-gshell/servicemix-gshell.xsd">
 
     <bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
-      <property name="location" value="file:${karaf.home}/etc/org.apache.servicemix.features.cfg"/>
+      <property name="location" value="file:${karaf.home}/etc/org.apache.felix.karaf.features.cfg"/>
     </bean>
 
     <gshell:command-bundle>
@@ -108,7 +108,6 @@
     <bean id="featureServiceRegistry" class="org.apache.felix.karaf.gshell.features.management.ManagedFeaturesRegistry" init-method="init">
         <property name="managementAgent" ref="managementAgent" />
         <property name="namingStrategy" ref="namingStrategy" />
-        <property name="featuresService" ref="featuresService" />
     </bean>
 
     <osgi:reference id="configAdmin" interface="org.osgi.service.cm.ConfigurationAdmin" />
diff --git a/karaf/jaas/jaas-modules/src/main/resources/META-INF/spring/karaf-jaas-module.xml b/karaf/jaas/jaas-modules/src/main/resources/META-INF/spring/karaf-jaas-module.xml
index 5791028..a989da8 100644
--- a/karaf/jaas/jaas-modules/src/main/resources/META-INF/spring/karaf-jaas-module.xml
+++ b/karaf/jaas/jaas-modules/src/main/resources/META-INF/spring/karaf-jaas-module.xml
@@ -53,7 +53,7 @@
 
     <jaas:config id="karaf">
         <jaas:module className="org.apache.felix.karaf.jaas.modules.properties.PropertiesLoginModule" flags="required">
-            users = ${servicemix.base}/etc/users.properties
+            users = ${karaf.base}/etc/users.properties
         </jaas:module>
     </jaas:config>