### Start Kill Bill Skeleton Server with Maven Source: https://github.com/killbill/killbill-platform/blob/master/server/README.md This command starts the Kill Bill skeleton server using Maven's Jetty plugin. Ensure you have Maven installed and the project's pom.xml configured for Jetty. ```bash mvn jetty:run ``` -------------------------------- ### Configure Plugin Installation Coordinates (Properties) Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/kpm/README.md This configuration snippet shows how to set up properties for installing plugins using coordinates. It specifies the repository URL, authentication method, username, password, and whether to always try the public repository. These settings are crucial for KPM to locate and download plugins from custom or private repositories. ```properties org.killbill.billing.plugin.kpm.pluginInstall.coordinate.url=https://maven.pkg.github.com/xsalefter/killbill-hello-world-java-plugin org.killbill.billing.plugin.kpm.pluginInstall.coordinate.authMethod=BASIC org.killbill.billing.plugin.kpm.pluginInstall.coordinate.authUsername= org.killbill.billing.plugin.kpm.pluginInstall.coordinate.authPassword= org.killbill.billing.plugin.kpm.pluginInstall.coordinate.alwaysTryPublicRepository=true ``` -------------------------------- ### Custom Plugins Directory Configuration Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/kpm/README.md Configures the location and authentication for the plugins_directory.yml file, which lists available plugins for coordinate-based installation. Supports various authentication methods like NONE, BASIC, and TOKEN. ```properties org.killbill.billing.plugin.kpm.pluginsDirectory.url=URL org.killbill.billing.plugin.kpm.pluginsDirectory.authMethod=NONE|BASIC|TOKEN org.killbill.billing.plugin.kpm.pluginsDirectory.authUsername=VALID_USERNAME org.killbill.billing.plugin.kpm.pluginsDirectory.authPassword=VALID_PASSWORD org.killbill.billing.plugin.kpm.pluginsDirectory.authToken=VALID_TOKEN ``` -------------------------------- ### Manage OSGI Plugins with DefaultOSGIService (Java) Source: https://context7.com/killbill/killbill-platform/llms.txt The `DefaultOSGIService` manages the Apache Felix OSGI framework for Kill Bill plugins. It handles plugin discovery, installation, starting, stopping, and lifecycle events. Plugins are loaded from the configured installation directory and can be Java-based OSGI bundles. Configuration properties are set in `killbill.properties`. ```java import org.killbill.billing.osgi.DefaultOSGIService; import org.killbill.billing.osgi.BundleRegistry; import org.killbill.billing.osgi.BundleRegistry.BundleWithMetadata; import org.killbill.billing.osgi.config.OSGIConfig; import org.killbill.billing.platform.api.OSGIService; // OSGIConfig properties (set in killbill.properties): // org.killbill.osgi.bundle.install.dir=/var/tmp/bundles // org.killbill.osgi.root.dir=/var/tmp/felix // org.killbill.osgi.bundle.cache.name=osgi-cache // org.killbill.osgi.bundle.property.name=killbill.properties // org.killbill.billing.plugin.mandatory.plugins=plugin-a,plugin-b // The OSGI service lifecycle is automatic via annotations: // @LifecycleHandlerType(INIT_PLUGIN) - initialize() // - Prunes OSGI cache // - Creates Felix framework // - Installs bundles from install directory // - Registers external bus listener // @LifecycleHandlerType(START_PLUGIN) - start() // - Starts all bundles // - Verifies mandatory plugins are running // - Sends STARTED lifecycle event // @LifecycleHandlerType(STOP_PLUGIN) - stop() // - Unregisters bus listener // - Stops Felix framework // - Sends STOPPED lifecycle event // BundleRegistry for runtime plugin management BundleRegistry registry = injector.getInstance(BundleRegistry.class); // Install and start a new plugin at runtime BundleWithMetadata bundle = registry.installAndStartNewBundle("my-payment-plugin", "1.0.0"); System.out.println("Installed: " + bundle.getPluginName() + " v" + bundle.getVersion()); // Stop and uninstall a plugin registry.stopAndUninstallNewBundle("my-payment-plugin", "1.0.0"); // Get information about a specific plugin BundleWithMetadata pluginInfo = registry.getBundle("my-payment-plugin"); if (pluginInfo != null) { System.out.println("Plugin: " + pluginInfo.getPluginName()); System.out.println("Version: " + pluginInfo.getVersion()); System.out.println("Services: " + pluginInfo.getServiceNames()); } ``` -------------------------------- ### Configure Dependency Injection with Guice Modules Source: https://context7.com/killbill/killbill-platform/llms.txt Kill Bill Platform utilizes Google Guice for dependency injection. This example demonstrates setting up custom application modules by extending platform base modules for lifecycle, bus, and OSGI configurations. It involves creating a config source, defining custom bindings, and bootstrapping the Guice injector. ```java import org.killbill.billing.platform.glue.KillBillPlatformModuleBase; import org.killbill.billing.lifecycle.glue.LifecycleModule; import org.killbill.billing.lifecycle.glue.BusModule; import org.killbill.billing.lifecycle.glue.BusModule.BusType; import org.killbill.billing.osgi.glue.DefaultOSGIModule; import org.killbill.billing.platform.api.KillbillConfigSource; import org.killbill.billing.platform.config.DefaultKillbillConfigSource; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.AbstractModule; // Create config source KillbillConfigSource configSource = new DefaultKillbillConfigSource(); // Custom application module extending platform base public class MyApplicationModule extends KillBillPlatformModuleBase { public MyApplicationModule(KillbillConfigSource configSource) { super(configSource); } @Override protected void configure() { // Install lifecycle management install(new LifecycleModule(configSource)); // Install internal event bus (persistent for production) install(new BusModule(BusType.PERSISTENT, false, configSource)); // Install external event bus for plugin communication install(new BusModule(BusType.PERSISTENT, true, configSource)); // Install OSGI plugin framework install(new DefaultOSGIModule( configSource, configSource, // OSGIConfigProperties osgiDataSourceConfig, osgiEmbeddedDB )); // Bind custom services bind(MyService.class).to(MyServiceImpl.class).asEagerSingleton(); } } // Bootstrap application Injector injector = Guice.createInjector(new MyApplicationModule(configSource)); // Get lifecycle and start application Lifecycle lifecycle = injector.getInstance(Lifecycle.class); lifecycle.fireStartupSequencePriorEventRegistration(); lifecycle.fireStartupSequencePostEventRegistration(); // Application is now running... // Graceful shutdown Runtime.getRuntime().addShutdownHook(new Thread(() -> { lifecycle.fireShutdownSequencePriorEventUnRegistration(); lifecycle.fireShutdownSequencePostEventUnRegistration(); })); ``` -------------------------------- ### Kill Bill Custom Repository Configuration Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/kpm/README.md Configures Kill Bill's custom installation repository for KPM plugins. This is used when the 'latest' parameter is true and specifies the URL and Maven path for fetching Kill Bill information. Authentication methods can also be configured. ```properties org.killbill.billing.plugin.kpm.nexusUrl=https://dl.cloudsmith.io//killbill/ org.killbill.billing.plugin.kpm.nexusRepository=/maven ``` -------------------------------- ### Run Kill Bill Instances with Maven Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/eureka/README.md This command runs a Kill Bill instance using Maven's jetty plugin. It specifies the server properties file and the HTTP port. This is typically used for setting up multiple instances for testing. ```bash # First instance: mvn jetty:run \ -Dorg.killbill.server.properties=file:///killbill-eureka.properties \ -Djetty.http.port=8080 # Second instance: mvn jetty:run \ -Dorg.killbill.server.properties=file:///killbill-eureka.properties \ -Djetty.http.port=8081 ``` -------------------------------- ### Configure H2 Database with Additional DDL Files Source: https://github.com/killbill/killbill-platform/blob/master/server/README.md This Java system property is used to specify additional DDL files for the H2 database when starting the Kill Bill skeleton server. The DDL files are executed only if the database does not already exist. ```java -Dorg.killbill.dao.additionalSeedFiles=file:/path/to/killbill-analytics-plugin/src/main/resources/org/killbill/billing/plugin/analytics/ddl.sql ``` -------------------------------- ### Configure Kill Bill Eureka Client Properties Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/eureka/README.md This properties file configures the Kill Bill instance to act as an Eureka client. It includes database connection details for both the main Kill Bill instance and OSGI plugins, as well as specific Eureka client settings like the service URL, registration enablement, and status/health check paths. Enabling 'org.killbill.eureka=true' is crucial for activating Eureka integration. ```properties # Database config org.killbill.dao.url=jdbc:mysql://127.0.0.1:3306/killbill_dev org.killbill.dao.user=root org.killbill.dao.password=admin # Database config (OSGI plugins) org.killbill.billing.osgi.dao.url=jdbc:mysql://127.0.0.1:3306/killbill_osgi_dev org.killbill.billing.osgi.dao.user=root org.killbill.billing.osgi.dao.password=admin # Eureka client specifics configuration. Read more https://github.com/Netflix/eureka/wiki/Configuring-Eureka euroka.serviceUrl.default=http://localhost:8761/eureka euroka.registration.enabled=true euroka.name=killbill euroka.port.enabled=true euroka.securePort.enabled=false euroka.statusPageUrlPath=/1.0/metrics euroka.healthCheckUrlPath=/1.0/healthCheck euroka.decoderName=JacksonJson euroka.preferSameZone=true euroka.shouldUseDns=false # Enable eureka in Kill Bill org.killbill.eureka=true # Kill Bill plugins root directory. If not set, the value would be "/var/tmp/bundles" org.killbill.osgi.bundle.install.dir= ``` -------------------------------- ### Configure Eureka Server with Spring Boot Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/eureka/README.md This snippet shows the minimal configuration for a Spring Boot application to act as an Eureka server. It sets the server port, disables self-registration and registry fetching, and specifies the instance hostname. This is useful for development and testing environments. ```properties server.port=8761 euroka.client.registerWithEureka=false euroka.client.fetchRegistry=false euroka.instance.hostname=localhost ``` -------------------------------- ### Manage Kill Bill Instance Rotation with Java Client Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/eureka/README.md Demonstrates how to use the killbill-client-java to manage the rotation status of a Kill Bill instance in Eureka. The `putOutOfRotation` method marks an instance as DOWN, while `putInRotation` restores it to UP. ```java public class EurekaServiceRegistryTest { private KillbillClient killbillClient = newKillbillClientWithPort8080(); // Will make killbill instance with port 8080 status=DOWN in eureka. See eureka console in browser @Test void putOutRotation() throws KillBillClientException { final AdminApi adminApi = new AdminApi(killbillClient); adminApi.putOutOfRotation(RequestOptions.empty()); } // Will make killbill instance with port 8080 status back to 'UP' in eureka @Test void putInRotation() throws KillBillClientException { final AdminApi adminApi = new AdminApi(killbillClient); adminApi.putInRotation(RequestOptions.empty()); } } ``` -------------------------------- ### Create Tenant in Kill Bill Database Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/eureka/README.md This SQL command inserts a new tenant record into the Kill Bill database. It includes essential fields like ID, external key, API key, API secret, and timestamps. This is necessary for interacting with the Kill Bill REST API. ```sql INSERT INTO tenants (record_id, id, external_key, api_key, api_secret, api_salt, created_date, created_by, updated_date, updated_by) VALUES (1, 'f76d3b8a-2fe9-4538-b434-a5dbf51b2d27', null, 'bob', 'iJTgdUDR/6RZF3lgBNtKxXZ+tPadfjHtQtykVq6yRkEecrlWp/wkWJ65G2EeHMfOpjVQ9XfYKyGYy86tMFT5pw==', 'IGfdQIzGWp7AbQ5Xx6h07w==', '2022-09-03 08:27:55', 'demo', '2022-09-03 08:28:06', 'demo'); ``` -------------------------------- ### Manage Application Lifecycle with Lifecycle API (Java) Source: https://context7.com/killbill/killbill-platform/llms.txt Illustrates the usage of the Lifecycle API for managing the application's startup and shutdown sequences. It shows how to create a Lifecycle instance using Guice and fire events in predefined phases to ensure proper service initialization and termination. The API relies on reflection to invoke methods annotated with @LifecycleHandlerType. ```java import org.killbill.billing.lifecycle.DefaultLifecycle; import org.killbill.billing.lifecycle.api.Lifecycle; import org.killbill.billing.lifecycle.config.LifecycleConfig; import com.google.inject.Guice; import com.google.inject.Injector; // Create lifecycle with Guice injector Injector injector = Guice.createInjector(new MyModule()); LifecycleConfig config = injector.getInstance(LifecycleConfig.class); Lifecycle lifecycle = new DefaultLifecycle(injector, config); // Application startup sequence // Phase 1: BOOT -> LOAD_CATALOG -> INIT_BUS -> INIT_PLUGIN -> INIT_SERVICE -> START_PLUGIN lifecycle.fireStartupSequencePriorEventRegistration(); // Phase 2: START_SERVICE -> START_BUS (event handlers now active) lifecycle.fireStartupSequencePostEventRegistration(); // Application shutdown sequence // Phase 3: STOP_SERVICE -> STOP_PLUGIN lifecycle.fireShutdownSequencePriorEventUnRegistration(); // Phase 4: STOP_BUS -> SHUTDOWN lifecycle.fireShutdownSequencePostEventUnRegistration(); // Lifecycle levels and their sequences: // STARTUP_PRE_EVENT_REGISTRATION: BOOT, LOAD_CATALOG, INIT_BUS, INIT_PLUGIN, INIT_SERVICE, START_PLUGIN // STARTUP_POST_EVENT_REGISTRATION: START_SERVICE, START_BUS // SHUTDOWN_PRE_EVENT_UNREGISTRATION: STOP_SERVICE, STOP_PLUGIN // SHUTDOWN_POST_EVENT_UNREGISTRATION: STOP_BUS, SHUTDOWN ``` -------------------------------- ### List Available Plugins (cURL) Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/kpm/README.md This cURL command demonstrates how to list available plugins using the Kill Bill KPM API. It includes basic authentication and parameters for specifying the Kill Bill version and forcing a download. This endpoint is useful for programmatically discovering and managing plugins. ```bash curl -v \ -u admin:password \ http://127.0.0.1:8080/plugins/killbill-kpm/plugins?kbVersion=&latest=true ``` -------------------------------- ### List Available Plugins Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/kpm/README.md This endpoint allows you to list available plugins managed by the KPM plugin. You can filter by Kill Bill version and control whether to force a download of the latest plugin information. ```APIDOC ## GET /plugins/killbill-kpm/plugins ### Description Retrieves a list of available plugins. Supports filtering by Kill Bill version and forcing a download of the latest plugin information. ### Method GET ### Endpoint `/plugins/killbill-kpm/plugins` ### Parameters #### Query Parameters - **kbVersion** (string) - Optional - Specifies the Kill Bill version to filter plugins by. Use ``. - **latest** (boolean) - Optional - If set to `true`, forces KPM plugin to download plugins/plugins information in each request. Note that `availablePlugins.cache.enabled` takes precedence. ### Request Example ```bash curl -v \ -u admin:password \ http://127.0.0.1:8080/plugins/killbill-kpm/plugins?kbVersion=&latest=true ``` ### Response #### Success Response (200) - **plugins** (array) - A list of available plugins. - **name** (string) - The name of the plugin. - **version** (string) - The version of the plugin. - **description** (string) - A description of the plugin. #### Response Example ```json { "plugins": [ { "name": "killbill-hello-world-java-plugin", "version": "0.1.0", "description": "A sample Kill Bill Java plugin." } ] } ``` ``` -------------------------------- ### Discover and Manage Plugins with PluginFinder Source: https://context7.com/killbill/killbill-platform/llms.txt The PluginFinder class is responsible for discovering and managing plugin configurations from the filesystem. It handles version selection using symlinks and plugin enabling/disabling via marker files. Dependencies include OSGI API configurations. ```java import org.killbill.billing.osgi.pluginconf.PluginFinder; import org.killbill.billing.osgi.api.config.PluginConfig; import org.killbill.billing.osgi.api.config.PluginJavaConfig; import java.util.List; import java.util.Map; import java.util.LinkedList; // Plugin directory structure: // /var/tmp/bundles/ // plugins/ // plugin_identifiers.json # Maps plugin keys to names // java/ // stripe-plugin/ // 1.0.0/ // stripe-plugin-1.0.0.jar // killbill.properties # Plugin config // tmp/ // disabled.txt # If present, plugin is disabled // 1.1.0/ // stripe-plugin-1.1.0.jar // SET_DEFAULT -> 1.1.0/ # Symlink to active version PluginFinder pluginFinder = injector.getInstance(PluginFinder.class); // Get all latest Java plugins (version marked by SET_DEFAULT or highest version) List latestPlugins = pluginFinder.getLatestJavaPlugins(); for (PluginJavaConfig plugin : latestPlugins) { System.out.println("Plugin: " + plugin.getPluginName()); System.out.println("Version: " + plugin.getVersion()); System.out.println("Jar: " + plugin.getBundleJarPath()); System.out.println("Selected for start: " + plugin.isSelectedForStart()); } // Get all versions of a specific plugin List versions = pluginFinder.getVersionsForPlugin("stripe-plugin", null); // Or get a specific version List v1 = pluginFinder.getVersionsForPlugin("stripe-plugin", "1.0.0"); // Get the version selected for start String activeVersion = pluginFinder.getPluginVersionSelectedForStart("stripe-plugin"); // Returns: "1.1.0" // Get all plugins with all their versions Map> allPlugins = pluginFinder.getAllPlugins(); // Reload plugins after filesystem changes pluginFinder.reloadPlugins(); // Resolve plugin key to identifier PluginIdentifier identifier = pluginFinder.resolvePluginKey("killbill-stripe"); // Returns plugin name, version info from plugin_identifiers.json ``` -------------------------------- ### Configure Kill Bill Platform Maven Dependencies Source: https://context7.com/killbill/killbill-platform/llms.txt This snippet shows how to configure Maven dependencies for the Kill Bill Platform. It includes the core API, base configuration, lifecycle management, OSGI framework, OSGI API, monitoring bundles, server components, and testing utilities. Ensure you use the correct version (e.g., 0.41.y for Kill Bill 0.24.x) for API compatibility. ```xml org.kill-bill.billing killbill-platform-api 0.41.19 org.kill-bill.billing killbill-platform-base 0.41.19 org.kill-bill.billing killbill-platform-lifecycle 0.41.19 org.kill-bill.billing killbill-platform-osgi 0.41.19 org.kill-bill.billing killbill-platform-osgi-api 0.41.19 org.kill-bill.billing killbill-platform-osgi-bundles-prometheus 0.41.19 org.kill-bill.billing killbill-platform-osgi-bundles-graphite 0.41.19 org.kill-bill.billing killbill-platform-server 0.41.19 org.kill-bill.billing killbill-platform-test 0.41.19 test ``` -------------------------------- ### Running Prometheus with Docker Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/prometheus/README.md This command demonstrates how to run the Prometheus server using a Docker container. It maps the host's port 9091 to the container's port 9090 and mounts a local `prometheus.yml` configuration file into the container. Replace `/path/to/prometheus.yml` with the actual path to your configuration file. ```bash docker run \ -p 9091:9090 \ -v /path/to/prometheus.yml:/etc/prometheus/prometheus.yml \ prom/prometheus ``` -------------------------------- ### Register Custom Service with KillbillService Interface (Java) Source: https://context7.com/killbill/killbill-platform/llms.txt Demonstrates how to implement the KillbillService interface to register a custom service within the Kill Bill platform. This involves defining the service name, registration ordering, and lifecycle handler methods for initialization, startup, and shutdown. Services are managed by Guice and invoked based on their LifecycleLevel. ```java import org.killbill.billing.platform.api.KillbillService; import org.killbill.billing.platform.api.LifecycleHandlerType; import org.killbill.billing.platform.api.LifecycleHandlerType.LifecycleLevel; public class MyCustomService implements KillbillService { @Override public String getName() { return "my-custom-service"; } @Override public int getRegistrationOrdering() { // Services are started in ascending order (platform: 0-100, core: 100-500, plugins: 500+) return 300; } @LifecycleHandlerType(LifecycleLevel.INIT_SERVICE) public void initialize() { // Called during STARTUP_PRE_EVENT_REGISTRATION sequence System.out.println("Initializing custom service..."); } @LifecycleHandlerType(LifecycleLevel.START_SERVICE) public void start() { // Called during STARTUP_POST_EVENT_REGISTRATION sequence System.out.println("Starting custom service..."); } @LifecycleHandlerType(LifecycleLevel.STOP_SERVICE) public void stop() { // Called during SHUTDOWN_PRE_EVENT_UNREGISTRATION sequence System.out.println("Stopping custom service..."); } } ``` -------------------------------- ### DefaultKillbillConfigSource - Java Configuration Management Source: https://context7.com/killbill/killbill-platform/llms.txt Manages application configuration by supporting properties files, environment variables, and Jasypt encrypted values. It prioritizes configuration sources and automatically maps environment variables prefixed with KB_. Supports retrieving individual properties, all properties, and properties organized by source. ```java import org.killbill.billing.platform.config.DefaultKillbillConfigSource; import java.util.Map; import java.util.Properties; // Initialize from default location (system properties or org.killbill.server.properties file) DefaultKillbillConfigSource configSource = new DefaultKillbillConfigSource(); // Or initialize with extra default properties Map extraDefaults = Map.of( "org.killbill.dao.url", "jdbc:mysql://localhost:3306/killbill", "org.killbill.dao.user", "killbill", "org.killbill.dao.password", "killbill" ); DefaultKillbillConfigSource configWithDefaults = new DefaultKillbillConfigSource(extraDefaults); // Or load from specific properties file DefaultKillbillConfigSource configFromFile = new DefaultKillbillConfigSource("/killbill.properties"); // Retrieve configuration values String dbUrl = configSource.getString("org.killbill.dao.url"); String dbUser = configSource.getString("org.killbill.dao.user"); // Get all properties Properties allProps = configSource.getProperties(); // Get properties organized by source (for debugging/audit) Map> propsBySource = configSource.getPropertiesBySource(); // Returns: {"ImmutableSystemProperties": {...}, "EnvironmentVariables": {...}, "RuntimeConfiguration": {...}} // Environment variables mapping (KB_DAO_URL -> org.killbill.dao.url) // Set KB_DAO_URL=jdbc:mysql://prod:3306/killbill in environment // Then configSource.getString("org.killbill.dao.url") returns the env value // Jasypt encrypted properties support // Set JASYPT_ENCRYPTOR_PASSWORD and JASYPT_ENCRYPTOR_ALGORITHM environment variables // Use ENC(encrypted_value) in properties file: // org.killbill.dao.password=ENC(aBcDeFgHiJkLmN==) ``` -------------------------------- ### Register Plugin Services with OSGIServiceRegistration (Java) Source: https://context7.com/killbill/killbill-platform/llms.txt The `OSGIServiceRegistration` interface allows plugins to register services that can be discovered and used by Kill Bill core. This enables a clean plugin API where payment plugins, notification plugins, and other extensions register their implementations for the platform to use. This is typically done within a plugin's activator. ```java import org.killbill.billing.osgi.api.OSGIServiceRegistration; import org.killbill.billing.osgi.api.OSGIServiceDescriptor; import org.killbill.billing.payment.plugin.api.PaymentPluginApi; // Plugin service registration (typically done in plugin activator) public class MyPaymentPluginActivator implements BundleActivator { private OSGIServiceRegistration paymentPluginRegistry; @Override public void start(BundleContext context) throws Exception { // Get the service registration from Kill Bill ServiceReference ref = context.getServiceReference(OSGIServiceRegistration.class); paymentPluginRegistry = context.getService(ref); // Create service descriptor OSGIServiceDescriptor descriptor = new OSGIServiceDescriptor() { @Override public String getPluginSymbolicName() { return "my-payment-plugin"; } @Override public String getPluginName() { return "My Payment Plugin"; } @Override public String getRegistrationName() { return "my-payment"; } }; // Register the payment plugin implementation MyPaymentPluginApi api = new MyPaymentPluginApi(); paymentPluginRegistry.registerService(descriptor, api); } @Override public void stop(BundleContext context) throws Exception { // Unregister on stop paymentPluginRegistry.unregisterService("my-payment"); } } // Kill Bill core uses the registry to find plugins OSGIServiceRegistration registry = injector.getInstance(new Key>() {}); // Get a specific plugin by name PaymentPluginApi stripePlugin = registry.getServiceForName("stripe"); // Get all registered payment plugins Set allPlugins = registry.getAllServices(); // Returns: ["stripe", "paypal", "braintree", ...] ``` -------------------------------- ### Add Kill Bill Platform Dependencies to Maven Project Source: https://github.com/killbill/killbill-platform/blob/master/README.md This snippet shows how to add various Kill Bill platform submodules as dependencies to a Maven project. It includes dependencies for the API, base components, lifecycle management, OSGI functionalities, and specific OSGI bundles for integrations and testing. Ensure you replace '... release version ...' with the actual version number. ```xml org.kill-bill.billing killbill-platform-api ... release version ... org.kill-bill.billing killbill-platform-base ... release version ... org.kill-bill.billing killbill-platform-lifecycle ... release version ... org.kill-bill.billing killbill-platform-osgi ... release version ... org.kill-bill.billing killbill-platform-osgi-all-bundles ... release version ... org.kill-bill.billing killbill-platform-osgi-api ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-defaultbundles ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-eureka ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-graphite ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-influxdb ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-kpm ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-lib-killbill ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-lib-slf4j-osgi ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-logger ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-metrics ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-test-beatrix ... release version ... org.kill-bill.billing killbill-platform-osgi-bundles-test-payment ... release version ... org.kill-bill.billing killbill-platform-osgi-lib-bundles ... release version ... org.kill-bill.billing killbill-platform-osgi-test-bundles ... release version ... org.kill-bill.billing killbill-platform-server ... release version ... org.kill-bill.billing killbill-platform-test ... release version ... ``` -------------------------------- ### Prometheus Configuration for Kill Bill Metrics Source: https://github.com/killbill/killbill-platform/blob/master/osgi-bundles/bundles/prometheus/README.md This YAML configuration defines how Prometheus should scrape metrics from the Kill Bill Prometheus plugin. It specifies the job name, scrape interval, timeout, target Kill Bill instance, metrics path, and scheme. Ensure the 'targets' field uses the machine's IP address where Kill Bill is running. ```yaml scrape_configs: - job_name: killbill scrape_interval: 30s scrape_timeout: 25s static_configs: - targets: [':'] metrics_path: /plugins/killbill-prometheus scheme: http ``` -------------------------------- ### Trigger Plugin Restart in Skeleton Server Source: https://github.com/killbill/killbill-platform/blob/master/server/README.md This command triggers a plugin restart in the Kill Bill skeleton server without restarting the entire Jetty server. This relies on a specific Jetty configuration within the project's pom.xml. ```bash touch /var/tmp/bundles/plugins/java/foo/1.0/tmp/restart.txt ``` -------------------------------- ### BusService - Java Event Bus Management Source: https://context7.com/killbill/killbill-platform/llms.txt Provides access to Kill Bill's persistent event bus for inter-service communication. Supports both in-memory and persistent bus implementations, enabling an event-driven architecture. Events are published and subscribed to without tight coupling. Requires Guice for dependency injection. ```java import org.killbill.billing.lifecycle.api.BusService; import org.killbill.billing.lifecycle.bus.DefaultBusService; import org.killbill.billing.lifecycle.glue.BusModule; import org.killbill.billing.lifecycle.glue.BusModule.BusType; import org.killbill.bus.api.PersistentBus; import org.killbill.bus.api.BusEvent; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.common.eventbus.Subscribe; // Configure bus module (PERSISTENT for production, MEMORY for testing) BusModule busModule = new BusModule(BusType.PERSISTENT, false, configSource); BusModule externalBusModule = new BusModule(BusType.PERSISTENT, true, configSource); Injector injector = Guice.createInjector(busModule, externalBusModule); BusService busService = injector.getInstance(BusService.class); // Get the persistent bus instance PersistentBus eventBus = busService.getBus(); // Register event handler public class MyEventHandler { @Subscribe public void handleEvent(BusEvent event) { System.out.println("Received event: " + event.getClass().getSimpleName()); // Process the event... } } MyEventHandler handler = new MyEventHandler(); eventBus.register(handler); // The bus is managed by lifecycle - these are called automatically: // @LifecycleHandlerType(INIT_BUS) - eventBus.initQueue() // @LifecycleHandlerType(START_BUS) - eventBus.startQueue() // @LifecycleHandlerType(STOP_BUS) - eventBus.stopQueue() // Unregister when done eventBus.unregister(handler); ``` -------------------------------- ### H2 Database Connection Details for Kill Bill Source: https://github.com/killbill/killbill-platform/blob/master/server/README.md These are the connection details for the H2 database used by the Kill Bill skeleton server. The database is file-based and located at /var/tmp/killbill. ```properties url: jdbc:h2:file:/var/tmp/killbill username: killbill password: killbill ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.