All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.chtijbug.drools.kieserver.carinsurance.rest.CarInsuranceKieServerApplicationComponentsService Maven / Gradle / Ivy

There is a newer version: 2.0.5
Show newest version
package org.chtijbug.drools.kieserver.carinsurance.rest;

import org.chtijbug.kieserver.services.drools.DroolsFrameworkRulesExecutionService;
import org.kie.server.services.api.KieServerApplicationComponentsService;
import org.kie.server.services.api.KieServerRegistry;
import org.kie.server.services.api.SupportedTransports;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;


public class CarInsuranceKieServerApplicationComponentsService implements KieServerApplicationComponentsService {

    private static final String OWNER_EXTENSION = "DroolsFramework";

    public Collection getAppComponents(String extension, SupportedTransports type, Object... services) {
        // skip calls from other than owning extension
        if (!OWNER_EXTENSION.equals(extension)) {
            return Collections.emptyList();
        }

        DroolsFrameworkRulesExecutionService rulesExecutionService = null;
        KieServerRegistry context = null;

        for (Object object : services) {
            if (DroolsFrameworkRulesExecutionService.class.isAssignableFrom(object.getClass())) {
                DroolsFrameworkRulesExecutionService droolsFrameworkRulesExecutionService = (DroolsFrameworkRulesExecutionService) object;
                context = droolsFrameworkRulesExecutionService.getContext();
                rulesExecutionService = droolsFrameworkRulesExecutionService;
                continue;
            }
        }

        List components = new ArrayList(1);
        if (SupportedTransports.REST.equals(type)) {
            components.add(new CarInsuranceResource(rulesExecutionService, context));
        }

        return components;
    }

}