Search in sources :

Example 1 with EntitlementPluginApi

use of org.killbill.billing.entitlement.plugin.api.EntitlementPluginApi in project killbill by killbill.

the class EntitlementPluginExecution method executePluginPriorCalls.

private PriorEntitlementResult executePluginPriorCalls(final EntitlementContext entitlementContextArg) throws EntitlementPluginApiException {
    // Return as soon as the first plugin aborts, or the last result for the last plugin
    PriorEntitlementResult prevResult = null;
    EntitlementContext currentContext = entitlementContextArg;
    for (final String pluginName : pluginRegistry.getAllServices()) {
        final EntitlementPluginApi plugin = pluginRegistry.getServiceForName(pluginName);
        if (plugin == null) {
            // First call to plugin, we log warn, if plugin is not registered
            log.warn("Skipping unknown entitlement control plugin {} when fetching results", pluginName);
            continue;
        }
        prevResult = plugin.priorCall(currentContext, currentContext.getPluginProperties());
        if (prevResult != null && prevResult.isAborted()) {
            break;
        }
        currentContext = new DefaultEntitlementContext(currentContext, prevResult);
    }
    return prevResult;
}
Also used : PriorEntitlementResult(org.killbill.billing.entitlement.plugin.api.PriorEntitlementResult) EntitlementPluginApi(org.killbill.billing.entitlement.plugin.api.EntitlementPluginApi) EntitlementContext(org.killbill.billing.entitlement.plugin.api.EntitlementContext)

Aggregations

EntitlementContext (org.killbill.billing.entitlement.plugin.api.EntitlementContext)1 EntitlementPluginApi (org.killbill.billing.entitlement.plugin.api.EntitlementPluginApi)1 PriorEntitlementResult (org.killbill.billing.entitlement.plugin.api.PriorEntitlementResult)1