killbill-aplcache

Various OSGI fixes to make JRuby bundles HTTP-ready Signed-off-by:

2/7/2013 9:17:12 PM

Details

api/pom.xml 4(+4 -0)

diff --git a/api/pom.xml b/api/pom.xml
index 17409f6..17ffe14 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -42,6 +42,10 @@
             <scope>provided</scope>
         </dependency>
         <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
             <groupId>joda-time</groupId>
             <artifactId>joda-time</artifactId>
         </dependency>
diff --git a/api/src/main/java/com/ning/billing/osgi/api/config/PluginRubyConfig.java b/api/src/main/java/com/ning/billing/osgi/api/config/PluginRubyConfig.java
index 0e9ca2a..2350304 100644
--- a/api/src/main/java/com/ning/billing/osgi/api/config/PluginRubyConfig.java
+++ b/api/src/main/java/com/ning/billing/osgi/api/config/PluginRubyConfig.java
@@ -21,5 +21,6 @@ public interface PluginRubyConfig extends PluginConfig {
     public String getRubyMainClass();
 
     public String getRubyLoadDir();
-    
+
+    public String getRubyRequire();
 }
diff --git a/api/src/main/java/com/ning/billing/osgi/api/http/ServletRouter.java b/api/src/main/java/com/ning/billing/osgi/api/http/ServletRouter.java
new file mode 100644
index 0000000..ef4d3bb
--- /dev/null
+++ b/api/src/main/java/com/ning/billing/osgi/api/http/ServletRouter.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2010-2013 Ning, Inc.
+ *
+ * Ning 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 com.ning.billing.osgi.api.http;
+
+import javax.servlet.http.HttpServlet;
+
+public interface ServletRouter {
+
+    void registerServlet(String pluginName, HttpServlet httpServlet);
+
+    HttpServlet getServletForPlugin(String pluginName);
+}
diff --git a/api/src/main/java/com/ning/billing/osgi/api/OSGIKillbill.java b/api/src/main/java/com/ning/billing/osgi/api/OSGIKillbill.java
index ea3b5a9..4212b9b 100644
--- a/api/src/main/java/com/ning/billing/osgi/api/OSGIKillbill.java
+++ b/api/src/main/java/com/ning/billing/osgi/api/OSGIKillbill.java
@@ -16,7 +16,7 @@
 
 package com.ning.billing.osgi.api;
 
-
+import javax.servlet.http.HttpServlet;
 import javax.sql.DataSource;
 
 import com.ning.billing.account.api.AccountUserApi;
@@ -92,4 +92,12 @@ public interface OSGIKillbill {
      * @return the dataSource for the OSGI bundles
      */
     public DataSource getDataSource();
+
+    /**
+     * Register a servlet
+     *
+     * @param pluginName plugin name
+     * @param pluginServlet servlet from the bundle
+     */
+    public void registerServlet(String pluginName, HttpServlet pluginServlet);
 }
diff --git a/osgi/src/main/java/com/ning/billing/osgi/DefaultOSGIKillbill.java b/osgi/src/main/java/com/ning/billing/osgi/DefaultOSGIKillbill.java
index 315dfa9..dbcb4bc 100644
--- a/osgi/src/main/java/com/ning/billing/osgi/DefaultOSGIKillbill.java
+++ b/osgi/src/main/java/com/ning/billing/osgi/DefaultOSGIKillbill.java
@@ -18,6 +18,7 @@ package com.ning.billing.osgi;
 
 import javax.inject.Inject;
 import javax.inject.Named;
+import javax.servlet.http.HttpServlet;
 import javax.sql.DataSource;
 
 import com.ning.billing.account.api.AccountUserApi;
@@ -34,6 +35,7 @@ import com.ning.billing.invoice.api.InvoicePaymentApi;
 import com.ning.billing.invoice.api.InvoiceUserApi;
 import com.ning.billing.osgi.api.OSGIKillbill;
 import com.ning.billing.osgi.api.config.PluginConfigServiceApi;
+import com.ning.billing.osgi.api.http.ServletRouter;
 import com.ning.billing.osgi.glue.DefaultOSGIModule;
 import com.ning.billing.overdue.OverdueUserApi;
 import com.ning.billing.payment.api.PaymentApi;
@@ -70,9 +72,11 @@ public class DefaultOSGIKillbill implements OSGIKillbill {
     private final PluginConfigServiceApi configServiceApi;
 
     private final DataSource dataSource;
+    private final ServletRouter servletRouter;
 
     @Inject
-    public DefaultOSGIKillbill(final @Named(DefaultOSGIModule.OSGI_NAMED) DataSource dataSource,
+    public DefaultOSGIKillbill(@Named(DefaultOSGIModule.OSGI_NAMED) final DataSource dataSource,
+                               final ServletRouter servletRouter,
                                final AccountUserApi accountUserApi,
                                final AnalyticsSanityApi analyticsSanityApi,
                                final AnalyticsUserApi analyticsUserApi,
@@ -95,6 +99,7 @@ public class DefaultOSGIKillbill implements OSGIKillbill {
                                final ExternalBus externalBus,
                                final PluginConfigServiceApi configServiceApi) {
         this.dataSource = dataSource;
+        this.servletRouter = servletRouter;
         this.accountUserApi = accountUserApi;
         this.analyticsSanityApi = analyticsSanityApi;
         this.analyticsUserApi = analyticsUserApi;
@@ -227,4 +232,9 @@ public class DefaultOSGIKillbill implements OSGIKillbill {
     public DataSource getDataSource() {
         return dataSource;
     }
+
+    @Override
+    public void registerServlet(final String pluginName, final HttpServlet pluginServlet) {
+        servletRouter.registerServlet(pluginName, pluginServlet);
+    }
 }
diff --git a/osgi/src/main/java/com/ning/billing/osgi/glue/DefaultOSGIModule.java b/osgi/src/main/java/com/ning/billing/osgi/glue/DefaultOSGIModule.java
index b2c3408..8b57895 100644
--- a/osgi/src/main/java/com/ning/billing/osgi/glue/DefaultOSGIModule.java
+++ b/osgi/src/main/java/com/ning/billing/osgi/glue/DefaultOSGIModule.java
@@ -23,9 +23,11 @@ import org.skife.config.ConfigurationObjectFactory;
 
 import com.ning.billing.osgi.DefaultOSGIKillbill;
 import com.ning.billing.osgi.KillbillActivator;
-import com.ning.billing.osgi.OSGIServlet;
 import com.ning.billing.osgi.api.OSGIKillbill;
 import com.ning.billing.osgi.api.config.PluginConfigServiceApi;
+import com.ning.billing.osgi.api.http.ServletRouter;
+import com.ning.billing.osgi.http.DefaultServletRouter;
+import com.ning.billing.osgi.http.OSGIServlet;
 import com.ning.billing.osgi.pluginconf.DefaultPluginConfigServiceApi;
 import com.ning.billing.osgi.pluginconf.PluginFinder;
 import com.ning.billing.util.config.OSGIConfig;
@@ -46,6 +48,7 @@ public class DefaultOSGIModule extends AbstractModule {
     }
 
     protected void installOSGIServlet() {
+        bind(ServletRouter.class).to(DefaultServletRouter.class).asEagerSingleton();
         bind(HttpServlet.class).annotatedWith(Names.named(OSGI_NAMED)).to(OSGIServlet.class).asEagerSingleton();
     }
 
diff --git a/osgi/src/main/java/com/ning/billing/osgi/http/DefaultServletRouter.java b/osgi/src/main/java/com/ning/billing/osgi/http/DefaultServletRouter.java
new file mode 100644
index 0000000..dea87a9
--- /dev/null
+++ b/osgi/src/main/java/com/ning/billing/osgi/http/DefaultServletRouter.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010-2013 Ning, Inc.
+ *
+ * Ning 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 com.ning.billing.osgi.http;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.inject.Singleton;
+import javax.servlet.http.HttpServlet;
+
+import com.ning.billing.osgi.api.http.ServletRouter;
+
+@Singleton
+public class DefaultServletRouter implements ServletRouter {
+
+    private final Map<String, HttpServlet> pluginServlets = new HashMap<String, HttpServlet>();
+
+    @Override
+    public void registerServlet(final String pluginName, final HttpServlet httpServlet) {
+        pluginServlets.put(pluginName, httpServlet);
+    }
+
+    @Override
+    public HttpServlet getServletForPlugin(final String pluginName) {
+        return pluginServlets.get(pluginName);
+    }
+}
diff --git a/osgi/src/main/java/com/ning/billing/osgi/pluginconf/DefaultPluginRubyConfig.java b/osgi/src/main/java/com/ning/billing/osgi/pluginconf/DefaultPluginRubyConfig.java
index f39f66e..26c2eb1 100644
--- a/osgi/src/main/java/com/ning/billing/osgi/pluginconf/DefaultPluginRubyConfig.java
+++ b/osgi/src/main/java/com/ning/billing/osgi/pluginconf/DefaultPluginRubyConfig.java
@@ -26,14 +26,17 @@ public class DefaultPluginRubyConfig extends DefaultPluginConfig implements Plug
     private static final String INSTALLATION_GEM_NAME = "gems";
 
     private static final String PROP_RUBY_MAIN_CLASS_NAME = "mainClass";
+    private static final String PROP_RUBY_REQUIRE = "require";
 
     private final String rubyMainClass;
     private final File rubyLoadDir;
+    private final String rubyRequire;
 
     public DefaultPluginRubyConfig(final String pluginName, final String version, final File pluginVersionRoot, final Properties props) throws PluginConfigException {
         super(pluginName, version, props);
         this.rubyMainClass = props.getProperty(PROP_RUBY_MAIN_CLASS_NAME);
         this.rubyLoadDir = new File(pluginVersionRoot.getAbsolutePath() + "/" + INSTALLATION_GEM_NAME);
+        this.rubyRequire = props.getProperty(PROP_RUBY_REQUIRE);
         validate();
     }
 
@@ -58,6 +61,11 @@ public class DefaultPluginRubyConfig extends DefaultPluginConfig implements Plug
     }
 
     @Override
+    public String getRubyRequire() {
+        return rubyRequire;
+    }
+
+    @Override
     public PluginLanguage getPluginLanguage() {
         return PluginLanguage.RUBY;
     }
diff --git a/osgi-bundles/jruby/pom.xml b/osgi-bundles/jruby/pom.xml
index d493e70..18b9486 100644
--- a/osgi-bundles/jruby/pom.xml
+++ b/osgi-bundles/jruby/pom.xml
@@ -37,6 +37,10 @@
             <artifactId>killbill-api</artifactId>
         </dependency>
         <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.jruby</groupId>
             <artifactId>jruby-complete</artifactId>
             <version>1.7.1</version>
diff --git a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/Activator.java b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/Activator.java
index a25a8a5..1d3ac3f 100644
--- a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/Activator.java
+++ b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/Activator.java
@@ -28,29 +28,10 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.osgi.service.log.LogService;
 
-import com.ning.billing.account.api.AccountUserApi;
-import com.ning.billing.analytics.api.sanity.AnalyticsSanityApi;
-import com.ning.billing.analytics.api.user.AnalyticsUserApi;
-import com.ning.billing.catalog.api.CatalogUserApi;
-import com.ning.billing.entitlement.api.migration.EntitlementMigrationApi;
-import com.ning.billing.entitlement.api.timeline.EntitlementTimelineApi;
-import com.ning.billing.entitlement.api.transfer.EntitlementTransferApi;
-import com.ning.billing.entitlement.api.user.EntitlementUserApi;
-import com.ning.billing.invoice.api.InvoiceMigrationApi;
-import com.ning.billing.invoice.api.InvoicePaymentApi;
-import com.ning.billing.invoice.api.InvoiceUserApi;
 import com.ning.billing.osgi.api.OSGIKillbill;
 import com.ning.billing.osgi.api.config.PluginConfig.PluginType;
 import com.ning.billing.osgi.api.config.PluginConfigServiceApi;
 import com.ning.billing.osgi.api.config.PluginRubyConfig;
-import com.ning.billing.overdue.OverdueUserApi;
-import com.ning.billing.payment.api.PaymentApi;
-import com.ning.billing.tenant.api.TenantUserApi;
-import com.ning.billing.usage.api.UsageUserApi;
-import com.ning.billing.util.api.AuditUserApi;
-import com.ning.billing.util.api.CustomFieldUserApi;
-import com.ning.billing.util.api.ExportUserApi;
-import com.ning.billing.util.api.TagUserApi;
 
 public class Activator implements BundleActivator {
 
@@ -73,9 +54,9 @@ public class Activator implements BundleActivator {
         // Setup JRuby
         final ScriptingContainer scriptingContainer = setupScriptingContainer(rubyConfig);
         if (PluginType.NOTIFICATION.equals(rubyConfig.getPluginType())) {
-            plugin = new JRubyNotificationPlugin(rubyConfig, scriptingContainer, logger);
+            plugin = new JRubyNotificationPlugin(rubyConfig, scriptingContainer, osgiKillbill, logger);
         } else if (PluginType.PAYMENT.equals(rubyConfig.getPluginType())) {
-            plugin = new JRubyPaymentPlugin(rubyConfig, scriptingContainer, logger);
+            plugin = new JRubyPaymentPlugin(rubyConfig, scriptingContainer, osgiKillbill, logger);
         }
 
         // Validate and instantiate the plugin
diff --git a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyNotificationPlugin.java b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyNotificationPlugin.java
index 8c1d7bb..9ac561a 100644
--- a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyNotificationPlugin.java
+++ b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyNotificationPlugin.java
@@ -26,14 +26,16 @@ import org.osgi.service.log.LogService;
 
 import com.ning.billing.beatrix.bus.api.ExtBusEvent;
 import com.ning.billing.beatrix.bus.api.ExternalBus;
+import com.ning.billing.osgi.api.OSGIKillbill;
 import com.ning.billing.osgi.api.config.PluginRubyConfig;
 
 import com.google.common.eventbus.Subscribe;
 
 public class JRubyNotificationPlugin extends JRubyPlugin {
 
-    public JRubyNotificationPlugin(final PluginRubyConfig config, final ScriptingContainer container, @Nullable final LogService logger) {
-        super(config, container, logger);
+    public JRubyNotificationPlugin(final PluginRubyConfig config, final ScriptingContainer container,
+                                   final OSGIKillbill osgiKillbill, @Nullable final LogService logger) {
+        super(config, container, osgiKillbill, logger);
     }
 
     @Override
diff --git a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
index 6c25605..6313608 100644
--- a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
+++ b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPaymentPlugin.java
@@ -30,6 +30,7 @@ import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.osgi.service.log.LogService;
 
+import com.ning.billing.osgi.api.OSGIKillbill;
 import com.ning.billing.osgi.api.config.PluginRubyConfig;
 import com.ning.billing.payment.api.PaymentMethodPlugin;
 import com.ning.billing.payment.plugin.api.PaymentInfoPlugin;
@@ -43,8 +44,9 @@ public class JRubyPaymentPlugin extends JRubyPlugin implements PaymentPluginApi 
 
     private volatile ServiceRegistration<PaymentPluginApi> paymentInfoPluginRegistration;
 
-    public JRubyPaymentPlugin(final PluginRubyConfig config, final ScriptingContainer container, @Nullable final LogService logger) {
-        super(config, container, logger);
+    public JRubyPaymentPlugin(final PluginRubyConfig config, final ScriptingContainer container,
+                              final OSGIKillbill osgiKillbill, @Nullable final LogService logger) {
+        super(config, container, osgiKillbill, logger);
     }
 
     @Override
diff --git a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPlugin.java b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPlugin.java
index 1a9423c..ea0fb90 100644
--- a/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPlugin.java
+++ b/osgi-bundles/jruby/src/main/java/com/ning/billing/osgi/bundles/jruby/JRubyPlugin.java
@@ -20,14 +20,17 @@ import java.util.Arrays;
 import java.util.Map;
 
 import javax.annotation.Nullable;
+import javax.servlet.http.HttpServlet;
 
 import org.jruby.Ruby;
 import org.jruby.RubyObject;
 import org.jruby.embed.EvalFailedException;
 import org.jruby.embed.ScriptingContainer;
+import org.jruby.runtime.builtin.IRubyObject;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.log.LogService;
 
+import com.ning.billing.osgi.api.OSGIKillbill;
 import com.ning.billing.osgi.api.config.PluginRubyConfig;
 
 // Bridge between the OSGI bundle and the ruby plugin
@@ -43,7 +46,9 @@ public abstract class JRubyPlugin {
     private static final String ACTIVE = "@active";
 
     protected final LogService logger;
+    protected final OSGIKillbill osgiKillbill;
     protected final String pluginGemName;
+    protected final String rubyRequire;
     protected final String pluginMainClass;
     protected final ScriptingContainer container;
     protected final String pluginLibdir;
@@ -52,9 +57,12 @@ public abstract class JRubyPlugin {
 
     private String cachedRequireLine = null;
 
-    public JRubyPlugin(final PluginRubyConfig config, final ScriptingContainer container, @Nullable final LogService logger) {
+    public JRubyPlugin(final PluginRubyConfig config, final ScriptingContainer container,
+                       final OSGIKillbill osgiKillbill, @Nullable final LogService logger) {
         this.logger = logger;
+        this.osgiKillbill = osgiKillbill;
         this.pluginGemName = config.getPluginName();
+        this.rubyRequire = config.getRubyRequire();
         this.pluginMainClass = config.getRubyMainClass();
         this.container = container;
         this.pluginLibdir = config.getRubyLoadDir();
@@ -84,6 +92,12 @@ public abstract class JRubyPlugin {
 
         // Start the plugin
         pluginInstance = (RubyObject) container.runScriptlet(pluginMainClass + ".new(" + JAVA_APIS + ")");
+
+        // Register the rack handler
+        final IRubyObject rackHandler = pluginInstance.callMethod("rack_handler");
+        if (!rackHandler.isNil()) {
+            osgiKillbill.registerServlet(pluginGemName, (HttpServlet) rackHandler);
+        }
     }
 
     public void startPlugin(final BundleContext context) {
@@ -158,10 +172,22 @@ public abstract class JRubyPlugin {
             // Assume the plugin is shipped as a Gem
             builder.append("begin\n")
                    .append("gem '").append(pluginGemName).append("'\n")
-                   .append("require '").append(pluginGemName).append("' rescue warn \"WARN: unable to load ").append(pluginGemName).append("\"\n")
                    .append("rescue Gem::LoadError\n")
                    .append("warn \"WARN: unable to load gem ").append(pluginGemName).append("\"\n")
                    .append("end\n");
+            builder.append("begin\n")
+                   .append("require '").append(pluginGemName).append("'\n")
+                   .append("rescue LoadError\n")
+                   .append("warn \"WARN: unable to require ").append(pluginGemName).append("\"\n")
+                   .append("end\n");
+            // Load the extra require file, if specified
+            if (rubyRequire != null) {
+                builder.append("begin\n")
+                       .append("require '").append(rubyRequire).append("'\n")
+                       .append("rescue LoadError\n")
+                       .append("warn \"WARN: unable to require ").append(rubyRequire).append("\"\n")
+                       .append("end\n");
+            }
             // Require any file directly in the pluginLibdir directory (e.g. /var/tmp/bundles/ruby/foo/1.0/gems/*.rb).
             // Although it is likely that any Killbill plugin will be distributed as a gem, it is still useful to
             // be able to load individual scripts for prototyping/testing/...
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestJaxrsBase.java b/server/src/test/java/com/ning/billing/jaxrs/TestJaxrsBase.java
index 15df041..88869d5 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestJaxrsBase.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestJaxrsBase.java
@@ -24,8 +24,6 @@ import java.util.Iterator;
 import java.util.Map;
 
 import javax.inject.Inject;
-import javax.inject.Named;
-import javax.servlet.http.HttpServlet;
 
 import org.eclipse.jetty.servlet.FilterHolder;
 import org.joda.time.LocalDate;
@@ -51,6 +49,7 @@ import com.ning.billing.invoice.api.InvoiceNotifier;
 import com.ning.billing.invoice.glue.DefaultInvoiceModule;
 import com.ning.billing.invoice.notification.NullInvoiceNotifier;
 import com.ning.billing.junction.glue.DefaultJunctionModule;
+import com.ning.billing.osgi.api.http.ServletRouter;
 import com.ning.billing.osgi.glue.DefaultOSGIModule;
 import com.ning.billing.overdue.glue.DefaultOverdueModule;
 import com.ning.billing.payment.glue.PaymentModule;
@@ -94,8 +93,7 @@ public class TestJaxrsBase extends KillbillClient {
     protected static final int DEFAULT_HTTP_TIMEOUT_SEC = 6000; // 5;
 
     @Inject
-    @Named("osgi")
-    protected HttpServlet osgiServlet;
+    protected ServletRouter servletRouter;
 
     protected static TestKillbillGuiceListener listener;
 
diff --git a/server/src/test/java/com/ning/billing/jaxrs/TestPlugin.java b/server/src/test/java/com/ning/billing/jaxrs/TestPlugin.java
index f8da0a7..3b42643 100644
--- a/server/src/test/java/com/ning/billing/jaxrs/TestPlugin.java
+++ b/server/src/test/java/com/ning/billing/jaxrs/TestPlugin.java
@@ -30,7 +30,6 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import com.ning.billing.jaxrs.resources.JaxrsResource;
-import com.ning.billing.osgi.OSGIServlet;
 import com.ning.http.client.Response;
 
 public class TestPlugin extends TestJaxrsBase {
@@ -159,7 +158,7 @@ public class TestPlugin extends TestJaxrsBase {
     }
 
     private void setupOSGIPlugin() {
-        ((OSGIServlet) osgiServlet).registerResource(TEST_PLUGIN_NAME, new HttpServlet() {
+        servletRouter.registerServlet(TEST_PLUGIN_NAME, new HttpServlet() {
             @Override
             protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
                 if ((JaxrsResource.PLUGINS_PATH + "/" + TEST_PLUGIN_NAME + "/" + TEST_PLUGIN_VALID_GET_PATH).equals(req.getPathInfo())) {
diff --git a/util/src/main/java/com/ning/billing/util/config/OSGIConfig.java b/util/src/main/java/com/ning/billing/util/config/OSGIConfig.java
index 6e929cf..cae9b53 100644
--- a/util/src/main/java/com/ning/billing/util/config/OSGIConfig.java
+++ b/util/src/main/java/com/ning/billing/util/config/OSGIConfig.java
@@ -29,18 +29,36 @@ public interface OSGIConfig extends KillbillConfig {
     @Default("osgi-cache")
     public String getOSGIBundleCacheName();
 
-
     @Config("killbill.osgi.bundle.install.dir")
     @Default("/var/tmp/bundles")
     public String getRootInstallationDir();
 
     @Config("killbill.osgi.system.bundle.export.packages")
-    @Default("com.ning.billing.account.api,com.ning.billing.beatrix.bus.api,com.ning.billing.payment.plugin.api,com.ning.billing.osgi.api.config,com.ning.billing.util.callcontext,com.google.common.eventbus")
+    @Default("com.ning.billing.account.api," +
+             "com.ning.billing.analytics.api.sanity," +
+             "com.ning.billing.analytics.api.user," +
+             "com.ning.billing.beatrix.bus.api," +
+             "com.ning.billing.catalog.api," +
+             "com.ning.billing.entitlement.api.migration," +
+             "com.ning.billing.entitlement.api.timeline," +
+             "com.ning.billing.entitlement.api.transfer," +
+             "com.ning.billing.entitlement.api.user," +
+             "com.ning.billing.invoice.api," +
+             "com.ning.billing.osgi.api," +
+             "com.ning.billing.osgi.api.config," +
+             "com.ning.billing.overdue," +
+             "com.ning.billing.payment.api," +
+             "com.ning.billing.tenant.api," +
+             "com.ning.billing.usage.api," +
+             "com.ning.billing.util.api," +
+             "com.ning.billing.util.callcontext," +
+             "com.google.common.eventbus," +
+             "org.osgi.service.log")
     public String getSystemBundleExportPackages();
 
     // TODO FIXME OSGI
     @Config("killbill.osgi.jruby.bundle.path")
-    @Default("file:/var/tmp/killbill-osgi-jruby-bundle-0.1.51-SNAPSHOT-jar-with-dependencies.jar")
+    @Default("file:/var/tmp/killbill-osgi-bundles-jruby-0.1.52-SNAPSHOT-jar-with-dependencies.jar")
     public String getJrubyBundlePath();
 
 }