killbill-aplcache

osgi: stop adding lots of bundles in the System bundle This

2/16/2013 6:41:39 PM

Details

.gitignore 3(+2 -1)

diff --git a/.gitignore b/.gitignore
index 6fa2692..e303df5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,4 +16,5 @@ logs/
 *.project
 */bin/
 catalog/src/test/resources/CatalogSchema.xsd
-*/test-output/
\ No newline at end of file
+*/test-output/
+server/load

osgi/pom.xml 56(+2 -54)

diff --git a/osgi/pom.xml b/osgi/pom.xml
index de67f1e..67db67c 100644
--- a/osgi/pom.xml
+++ b/osgi/pom.xml
@@ -34,69 +34,22 @@
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>
-            <artifactId>org.osgi.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.configadmin</artifactId>
-            <version>1.6.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.log</artifactId>
-            <version>1.0.1</version>
-        </dependency>
-
-        <!-- TODO PIERRE Dependencies for the Felix Web Console.
-             In 4.0.1-SNAPSHOT, these are provided by the bundle,
-             see https://issues.apache.org/jira/browse/FELIX-3778.
-        -->
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.webconsole</artifactId>
-            <version>4.0.0</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-fileupload</groupId>
-            <artifactId>commons-fileupload</artifactId>
-            <version>1.2.1</version>
-        </dependency>
-        <dependency>
-            <groupId>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-            <version>1.4</version>
-        </dependency>
-        <dependency>
-            <groupId>org.json</groupId>
-            <artifactId>json</artifactId>
-            <version>20070829</version>
+            <artifactId>org.apache.felix.fileinstall</artifactId>
         </dependency>
         <dependency>
             <groupId>org.apache.felix</groupId>
-            <artifactId>org.apache.felix.shell</artifactId>
-            <version>1.0.0</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.felix</groupId>
-            <artifactId>org.osgi.service.obr</artifactId>
-            <version>1.0.2</version>
+            <artifactId>org.osgi.core</artifactId>
         </dependency>
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>org.osgi.compendium</artifactId>
-            <version>4.3.1</version>
         </dependency>
-
         <dependency>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
         </dependency>
         <dependency>
             <groupId>com.ning.billing</groupId>
-            <artifactId>killbill-osgi-bundles-webconsolebranding</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>com.ning.billing</groupId>
             <artifactId>killbill-api</artifactId>
         </dependency>
         <dependency>
@@ -124,11 +77,6 @@
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-api</artifactId>
         </dependency>
-        <!-- Default Bundles -->
-        <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>osgi-over-slf4j</artifactId>
-        </dependency>
         <!-- TEST SCOPE -->
         <dependency>
             <groupId>org.slf4j</groupId>
diff --git a/osgi/src/main/java/com/ning/billing/osgi/DefaultOSGIService.java b/osgi/src/main/java/com/ning/billing/osgi/DefaultOSGIService.java
index 068a91b..0850235 100644
--- a/osgi/src/main/java/com/ning/billing/osgi/DefaultOSGIService.java
+++ b/osgi/src/main/java/com/ning/billing/osgi/DefaultOSGIService.java
@@ -24,19 +24,16 @@ import java.util.Map;
 
 import javax.inject.Inject;
 
-import org.apache.felix.cm.impl.ConfigurationManager;
+import org.apache.felix.fileinstall.internal.FileInstall;
 import org.apache.felix.framework.Felix;
 import org.apache.felix.framework.util.FelixConstants;
-import org.apache.felix.webconsole.internal.OsgiManagerActivator;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
 import org.osgi.framework.launch.Framework;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.slf4j.osgi.logservice.impl.Activator;
 
 import com.ning.billing.lifecycle.LifecycleHandlerType;
 import com.ning.billing.lifecycle.LifecycleHandlerType.LifecycleLevel;
@@ -47,7 +44,6 @@ import com.ning.billing.osgi.api.config.PluginRubyConfig;
 import com.ning.billing.osgi.pluginconf.DefaultPluginConfigServiceApi;
 import com.ning.billing.osgi.pluginconf.PluginConfigException;
 import com.ning.billing.osgi.pluginconf.PluginFinder;
-import com.ning.billing.payment.plugin.api.PaymentPluginApi;
 import com.ning.billing.util.config.OSGIConfig;
 
 import com.google.common.collect.ImmutableList;
@@ -64,8 +60,6 @@ public class DefaultOSGIService implements OSGIService {
     private final KillbillActivator killbillActivator;
 
     private Framework framework;
-    private volatile ServiceReference[] paymentApiReferences;
-    private Map<String, PaymentPluginApi> paymentPluginApis;
 
     @Inject
     public DefaultOSGIService(final OSGIConfig osgiConfig, final PluginFinder pluginFinder,
@@ -129,6 +123,8 @@ public class DefaultOSGIService implements OSGIService {
             final BundleContext context = framework.getBundleContext();
 
             // Install all bundles and create service mapping
+            // TODO PIERRE Could we leverage Felix fileinstall plugin to manage Killbill plugins?
+
             final List<Bundle> installedBundles = new LinkedList<Bundle>();
             installAllJavaBundles(context, installedBundles);
             installAllJRubyBundles(context, installedBundles);
@@ -182,19 +178,12 @@ public class DefaultOSGIService implements OSGIService {
         final Map<Object, Object> felixConfig = new HashMap<Object, Object>();
         felixConfig.putAll(config);
 
-        // Install default bundles
-        // TODO PIERRE Should the Felix Web Console (and its dependencies) be rather installed at deploy time?
+        // Install default bundles in the Framework: Killbill bundle and Felix fileinstall bundle
+        // Note! Think twice before adding a bundle here as it will run inside the System bundle. This means the bundle
+        // context that the bundle will see is the System bundle one, which will break e.g. resources lookup
         felixConfig.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP,
-                        ImmutableList.<BundleActivator>of(killbillActivator,
-                                                          // SLF4J LogService
-                                                          new Activator(),
-                                                          // Felix Web Console
-                                                          new OsgiManagerActivator(),
-                                                          // Felix Log Service (installed for the Web Console)
-                                                          // TODO PIERRE Does it conflict with the SLF4J one?
-                                                          new org.apache.felix.log.Activator(),
-                                                          // Felix Configuration Admin Service (installed for the Web Console)
-                                                          new ConfigurationManager()));
+                        ImmutableList.<BundleActivator>of(new FileInstall(),
+                                                          killbillActivator));
 
         final Framework felix = new Felix(felixConfig);
         felix.init();

pom.xml 10(+10 -0)

diff --git a/pom.xml b/pom.xml
index 9f4a10a..7059bac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -78,11 +78,21 @@
                 <version>1.0.1</version>
             </dependency>
             <dependency>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>org.apache.felix.fileinstall</artifactId>
+                <version>3.2.6</version>
+            </dependency>
+            <dependency>
                 <groupId>org.osgi</groupId>
                 <artifactId>org.osgi.core</artifactId>
                 <version>4.3.1</version>
             </dependency>
             <dependency>
+                <groupId>org.osgi</groupId>
+                <artifactId>org.osgi.compendium</artifactId>
+                <version>4.3.1</version>
+            </dependency>
+            <dependency>
                 <groupId>net.sf.ehcache</groupId>
                 <artifactId>ehcache-core</artifactId>
                 <version>${ehcache.version}</version>