2525import javax .servlet .Servlet ;
2626import javax .servlet .http .HttpServlet ;
2727
28+ import org .killbill .billing .invoice .plugin .api .InvoiceFormatterFactory ;
2829import org .killbill .billing .invoice .plugin .api .InvoicePluginApi ;
2930import org .killbill .billing .osgi .api .Healthcheck ;
3031import org .killbill .billing .osgi .api .OSGIPluginProperties ;
3637import org .killbill .billing .plugin .core .config .PluginEnvironmentConfig ;
3738import org .killbill .billing .plugin .core .resources .jooby .PluginApp ;
3839import org .killbill .billing .plugin .core .resources .jooby .PluginAppBuilder ;
40+ import org .killbill .commons .health .api .HealthCheckRegistry ;
3941import org .osgi .framework .BundleContext ;
42+ import org .osgi .framework .ServiceReference ;
4043import org .osgi .util .tracker .ServiceTracker ;
41- import org .killbill .billing .invoice .plugin .api .InvoiceFormatterFactory ;
44+ import org .slf4j .Logger ;
45+ import org .slf4j .LoggerFactory ;
4246
4347public class HelloWorldActivator extends KillbillActivatorBase {
4448
@@ -48,16 +52,26 @@ public class HelloWorldActivator extends KillbillActivatorBase {
4852 //
4953 public static final String PLUGIN_NAME = "hello-world-plugin" ;
5054
55+ private static final Logger logger = LoggerFactory .getLogger (HelloWorldActivator .class );
56+
5157 private HelloWorldConfigurationHandler helloWorldConfigurationHandler ;
5258 private OSGIKillbillEventDispatcher .OSGIKillbillEventHandler killbillEventHandler ;
5359 private MetricsGeneratorExample metricsGenerator ;
5460
5561 private ServiceTracker <InvoiceFormatterFactory , InvoiceFormatterFactory > invoiceFormatterTracker ;
5662
63+ private HealthCheckRegistry healthCheckRegistry ;
64+
5765 @ Override
5866 public void start (final BundleContext context ) throws Exception {
5967 super .start (context );
60-
68+ final ServiceReference <HealthCheckRegistry > reference = context .getServiceReference (HealthCheckRegistry .class );
69+ if (reference != null ) {
70+ final HealthCheckRegistry healthCheckRegistry = context .getService (reference );
71+ if (healthCheckRegistry != null ) {
72+ this .healthCheckRegistry = healthCheckRegistry ;
73+ }
74+ }
6175 final String region = PluginEnvironmentConfig .getRegion (configProperties .getProperties ());
6276
6377 // Register an event listener for plugin configuration (optional)
@@ -72,7 +86,7 @@ public void start(final BundleContext context) throws Exception {
7286
7387
7488 // Register an event listener (optional)
75- killbillEventHandler = new HelloWorldListener (killbillAPI , invoiceFormatterTracker , configProperties .getProperties ());
89+ killbillEventHandler = new HelloWorldListener (killbillAPI , invoiceFormatterTracker , healthCheckRegistry , configProperties .getProperties ());
7690
7791 // As an example, this plugin registers a PaymentPluginApi (this could be
7892 // changed to any other plugin api)
@@ -99,6 +113,7 @@ public void start(final BundleContext context) throws Exception {
99113 registerServlet (context , httpServlet );
100114
101115 registerHandlers ();
116+ // HealthCheck aviateHealthCheck = hea
102117 }
103118
104119 @ Override
0 commit comments