Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugins don't have access to OverdueApi #30

Closed
sbrossie opened this Issue Jan 12, 2017 · 4 comments

Comments

Projects
None yet
2 participants
@sbrossie
Copy link
Member

sbrossie commented Jan 12, 2017

The definition of the api returned to plugins is done here. We don't export the OverdueApi, which is an issue because plugin receive events which don't even contain the overdue state name, and so they need to retrieve the overdue status.

@sbrossie

This comment has been minimized.

Copy link
Member Author

sbrossie commented Jan 12, 2017

Note that the java parser also needs to be hacked to handle correctly the joda Period object that is returned in the OverdueApi.

@sbrossie

This comment has been minimized.

Copy link
Member Author

sbrossie commented Jan 17, 2017

Changes that would be required in platform:

diff --git a/osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyActivator.java b/osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyActivator.java
index 89e691c..38cc362 100644
--- a/osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyActivator.java
+++ b/osgi-bundles/bundles/jruby/src/main/java/org/killbill/billing/osgi/bundles/jruby/JRubyActivator.java
@@ -189,6 +189,7 @@ public class JRubyActivator extends KillbillActivatorBase {
         killbillUserApis.put("currency_conversion_api", killbillAPI.getCurrencyConversionApi());
         killbillUserApis.put("security_api", killbillAPI.getSecurityApi());
         killbillUserApis.put("plugins_info_api", killbillAPI.getPluginsInfoApi());
+        killbillUserApis.put("overdue_api", killbillAPI.getOverdueApi());
         killbillUserApis.put("killbill_nodes_api", killbillAPI.getKillbillNodesApi());
         return killbillUserApis;
     }
diff --git a/osgi-bundles/libs/killbill/src/main/java/org/killbill/billing/osgi/libs/killbill/OSGIKillbillAPI.java b/osgi-bundles/libs/killbill/src/main/java/org/killbill/billing/osgi/libs/killbill/OSGIKillbillAPI.java
index 43ec667..48e7330 100644
--- a/osgi-bundles/libs/killbill/src/main/java/org/killbill/billing/osgi/libs/killbill/OSGIKillbillAPI.java
+++ b/osgi-bundles/libs/killbill/src/main/java/org/killbill/billing/osgi/libs/killbill/OSGIKillbillAPI.java
@@ -27,6 +27,7 @@ import org.killbill.billing.invoice.api.InvoiceUserApi;
 import org.killbill.billing.osgi.api.OSGIKillbill;
 import org.killbill.billing.osgi.api.PluginsInfoApi;
 import org.killbill.billing.osgi.api.config.PluginConfigServiceApi;
+import org.killbill.billing.overdue.api.OverdueApi;
 import org.killbill.billing.payment.api.AdminPaymentApi;
 import org.killbill.billing.payment.api.PaymentApi;
 import org.killbill.billing.security.api.SecurityApi;
@@ -209,6 +210,16 @@ public class OSGIKillbillAPI extends OSGIKillbillLibraryBase implements OSGIKill
     }
 
     @Override
+    public OverdueApi getOverdueApi() {
+        return withServiceTracker(killbillTracker, new APICallback<OverdueApi, OSGIKillbill>(KILLBILL_SERVICE_NAME) {
+            @Override
+            public OverdueApi executeWithService(final OSGIKillbill service) {
+                return service.getOverdueApi();
+            }
+        });
+    }
+
+    @Override
     public PluginConfigServiceApi getPluginConfigServiceApi() {
         return withServiceTracker(killbillTracker, new APICallback<PluginConfigServiceApi, OSGIKillbill>(KILLBILL_SERVICE_NAME) {
             @Override
diff --git a/osgi/src/main/java/org/killbill/billing/osgi/DefaultOSGIKillbill.java b/osgi/src/main/java/org/killbill/billing/osgi/DefaultOSGIKillbill.java
index c22e5c8..d3ceb29 100644
--- a/osgi/src/main/java/org/killbill/billing/osgi/DefaultOSGIKillbill.java
+++ b/osgi/src/main/java/org/killbill/billing/osgi/DefaultOSGIKillbill.java
@@ -28,6 +28,7 @@ import org.killbill.billing.invoice.api.InvoiceUserApi;
 import org.killbill.billing.osgi.api.OSGIKillbill;
 import org.killbill.billing.osgi.api.PluginsInfoApi;
 import org.killbill.billing.osgi.api.config.PluginConfigServiceApi;
+import org.killbill.billing.overdue.api.OverdueApi;
 import org.killbill.billing.payment.api.AdminPaymentApi;
 import org.killbill.billing.payment.api.PaymentApi;
 import org.killbill.billing.security.api.SecurityApi;
@@ -63,6 +64,7 @@ public class DefaultOSGIKillbill implements OSGIKillbill {
     private PluginsInfoApi pluginsInfoApi;
     private KillbillNodesApi killbillNodesApi;
     private AdminPaymentApi adminPaymentApi;
+    private OverdueApi overdueApi;
 
     private PluginConfigServiceApi configServiceApi;
 
@@ -166,6 +168,12 @@ public class DefaultOSGIKillbill implements OSGIKillbill {
         this.adminPaymentApi = adminPaymentApi;
     }
 
+    @Inject(optional = true)
+    public void setOverdueApi(final OverdueApi overdueApi) {
+        this.overdueApi = overdueApi;
+    }
+
+
     @Override
     public AccountUserApi getAccountUserApi() {
         return accountUserApi;
@@ -265,4 +273,9 @@ public class DefaultOSGIKillbill implements OSGIKillbill {
     public AdminPaymentApi getAdminPaymentApi() {
         return adminPaymentApi;
     }
+
+    @Override
+    public OverdueApi getOverdueApi() {
+        return overdueApi;
+    }
 }
diff --git a/osgi/src/main/java/org/killbill/billing/osgi/config/OSGIConfig.java b/osgi/src/main/java/org/killbill/billing/osgi/config/OSGIConfig.java
index e3d6414..8b5d1ea 100644
--- a/osgi/src/main/java/org/killbill/billing/osgi/config/OSGIConfig.java
+++ b/osgi/src/main/java/org/killbill/billing/osgi/config/OSGIConfig.java
@@ -64,6 +64,7 @@ public interface OSGIConfig extends KillbillPlatformConfig {
              "org.killbill.billing.osgi.api," +
              "org.killbill.billing.osgi.api.config," +
              "org.killbill.billing.overdue," +
+             "org.killbill.billing.overdue.api," +
              "org.killbill.billing.payment.api," +
              "org.killbill.billing.payment.plugin.api," +
              "org.killbill.billing.control.plugin.api," +
@@ -84,6 +85,7 @@ public interface OSGIConfig extends KillbillPlatformConfig {
              "org.killbill.billing.entitlement.plugin.api," +
              "org.killbill.billing.currency.api," +
              "org.killbill.billing.security.api," +
+             "org.killbill.billing.overdue.api," +
              "org.killbill.billing.osgi.libs.killbill," +

@pierre pierre added this to the Release-0.20.x milestone Mar 10, 2017

@sbrossie

This comment has been minimized.

Copy link
Member Author

sbrossie commented Apr 6, 2017

Note that this change is likely to break all our ruby plugins:

Caused by: org.jruby.exceptions.RaiseException: (NameError) uninitialized constant Killbill::Plugin::Api::OverdueApi
	at org.jruby.RubyModule.const_missing(org/jruby/RubyModule.java:2733)
	at org.jruby.RubyModule.const_get(org/jruby/RubyModule.java:2648)
	at RUBY.to_class(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill.rb:12)
	at org.jruby.RubyArray.each(org/jruby/RubyArray.java:1613)
	at org.jruby.RubyEnumerable.inject(org/jruby/RubyEnumerable.java:866)
	at RUBY.to_class(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill.rb:11)
	at RUBY.create_proxy_api(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill/killbill_api.rb:49)
	at RUBY.initialize(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill/killbill_api.rb:19)
	at org.jruby.RubyHash.each(org/jruby/RubyHash.java:1341)
	at org.jruby.java.proxies.MapJavaProxy.each(org/jruby/java/proxies/MapJavaProxy.java:414)
	at RUBY.initialize(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill/killbill_api.rb:18)
	at RUBY.create(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill/creator.rb:31)
	at RUBY.initialize(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill/jplugin.rb:41)
	at RUBY.initialize(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill/gen/plugin-api/notification_plugin_api.rb:38)
	at RUBY.initialize(/var/folders/ch/rfsn_qvn31188hdp5hkq4dssk31v6n/T/1491439991580-1/plugins/ruby/killbill-payment-test/4.0.0/ROOT/gems/gems/killbill-8.3.1/lib/killbill/gen/plugin-api/payment_plugin_api.rb:39)
	at RUBY.(root)(<script>:1)

@sbrossie sbrossie self-assigned this Apr 6, 2017

@sbrossie

This comment has been minimized.

Copy link
Member Author

sbrossie commented Apr 6, 2017

See da54efb

@sbrossie sbrossie closed this Apr 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.