Skip to content

Commit 9ae227f

Browse files
committed
use config property
1 parent a8a3cb6 commit 9ae227f

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/main/java/org/killbill/billing/plugin/helloworld/HelloWorldActivator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void start(final BundleContext context) throws Exception {
7272

7373

7474
// Register an event listener (optional)
75-
killbillEventHandler = new HelloWorldListener(killbillAPI, invoiceFormatterTracker);
75+
killbillEventHandler = new HelloWorldListener(killbillAPI, invoiceFormatterTracker, configProperties.getProperties());
7676

7777
// As an example, this plugin registers a PaymentPluginApi (this could be
7878
// changed to any other plugin api)

src/main/java/org/killbill/billing/plugin/helloworld/HelloWorldListener.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import java.util.List;
2323
import java.util.Locale;
24+
import java.util.Properties;
2425

2526
import org.joda.time.LocalDate;
2627
import org.killbill.billing.account.api.Account;
@@ -47,9 +48,12 @@ public class HelloWorldListener implements OSGIKillbillEventDispatcher.OSGIKillb
4748

4849
private final ServiceTracker<InvoiceFormatterFactory, InvoiceFormatterFactory> invoiceFormatterTracker;
4950

50-
public HelloWorldListener(final OSGIKillbillAPI killbillAPI, final ServiceTracker<InvoiceFormatterFactory, InvoiceFormatterFactory> invoiceFormatterTracker) {
51+
private final Properties configProperties;
52+
53+
public HelloWorldListener(final OSGIKillbillAPI killbillAPI, final ServiceTracker<InvoiceFormatterFactory, InvoiceFormatterFactory> invoiceFormatterTracker, Properties configProperties) {
5154
this.osgiKillbillAPI = killbillAPI;
5255
this.invoiceFormatterTracker = invoiceFormatterTracker;
56+
this.configProperties = configProperties;
5357
}
5458

5559
private static final String defaultLocale = "en_US";
@@ -85,6 +89,13 @@ public void handleKillbillEvent(final ExtBusEvent killbillEvent) {
8589
}
8690
final List<Invoice> invoices = osgiKillbillAPI.getInvoiceUserApi().getInvoicesByAccount(killbillEvent.getAccountId(), false, false, true, context);
8791
logger.info("Invoices in hello-world-plugin {}: ",invoices.size());
92+
93+
final String invoiceFormatterPluginName = configProperties.getProperty("org.killbill.template.invoiceFormatterFactoryPluginName");
94+
if(invoiceFormatterPluginName == null || invoiceFormatterPluginName.isEmpty()){
95+
logger.info("Invoice formatter plugin not configured. set the org.killbill.template.invoiceFormatterFactoryPluginName property to configure it");
96+
return;
97+
}
98+
8899
final InvoiceFormatterFactory formatterFactory = (invoiceFormatterTracker != null ? invoiceFormatterTracker.getService() : null);
89100
Invoice invoice = invoices.get(0); //For demo purpose, we are only retrieving the formattedEndDate for the first invoice
90101
//TODO Using null for parameters like catalogBundlePath,bundle, defaultBundle, etc. Update this to use correct values if possible or verify that using null values has no adverse effect

0 commit comments

Comments
 (0)