Search in sources :

Example 1 with CaseManagementRuntimeDataServiceBase

use of org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase in project droolsjbpm-integration by kiegroup.

the class CaseRestApplicationComponentsService method getAppComponents.

@Override
public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
    // skip calls from other than owning extension
    if (!OWNER_EXTENSION.equals(extension)) {
        return Collections.emptyList();
    }
    CaseManagementServiceBase caseManagementServiceBase = null;
    CaseManagementRuntimeDataServiceBase caseManagementRuntimeDataServiceBase = null;
    CaseAdminServiceBase caseAdminServiceBase = null;
    KieServerRegistry context = null;
    for (Object object : services) {
        // in case given service is null (meaning was not configured) continue with next one
        if (object == null) {
            continue;
        }
        if (CaseManagementServiceBase.class.isAssignableFrom(object.getClass())) {
            caseManagementServiceBase = (CaseManagementServiceBase) object;
            continue;
        } else if (CaseManagementRuntimeDataServiceBase.class.isAssignableFrom(object.getClass())) {
            caseManagementRuntimeDataServiceBase = (CaseManagementRuntimeDataServiceBase) object;
            continue;
        } else if (CaseAdminServiceBase.class.isAssignableFrom(object.getClass())) {
            caseAdminServiceBase = (CaseAdminServiceBase) object;
            continue;
        } else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
            context = (KieServerRegistry) object;
            continue;
        }
    }
    List<Object> components = new ArrayList<Object>();
    components.add(new CaseResource(caseManagementServiceBase, caseManagementRuntimeDataServiceBase, context));
    components.add(new CaseQueryResource(caseManagementRuntimeDataServiceBase, context));
    components.add(new CaseAdminResource(caseManagementRuntimeDataServiceBase, caseAdminServiceBase, context));
    return components;
}
Also used : KieServerRegistry(org.kie.server.services.api.KieServerRegistry) CaseManagementRuntimeDataServiceBase(org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase) CaseManagementServiceBase(org.kie.server.services.casemgmt.CaseManagementServiceBase) ArrayList(java.util.ArrayList) CaseAdminServiceBase(org.kie.server.services.casemgmt.CaseAdminServiceBase)

Example 2 with CaseManagementRuntimeDataServiceBase

use of org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase in project droolsjbpm-integration by kiegroup.

the class SpringBootCaseKieServerExtension method configureServices.

@Override
protected void configureServices(KieServerImpl kieServer, KieServerRegistry registry) {
    this.caseManagementServiceBase = new CaseManagementServiceBase(caseService, caseRuntimeDataService, registry);
    this.caseManagementRuntimeDataService = new CaseManagementRuntimeDataServiceBase(caseRuntimeDataService, advanceCaseRuntimeDataService, registry);
    this.caseAdminServiceBase = new CaseAdminServiceBase(caseInstanceMigrationService, registry);
}
Also used : CaseManagementRuntimeDataServiceBase(org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase) CaseManagementServiceBase(org.kie.server.services.casemgmt.CaseManagementServiceBase) CaseAdminServiceBase(org.kie.server.services.casemgmt.CaseAdminServiceBase)

Example 3 with CaseManagementRuntimeDataServiceBase

use of org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase in project droolsjbpm-integration by kiegroup.

the class PrometheusKieServerExtension method init.

@Override
public void init(KieServerImpl kieServer, KieServerRegistry registry) {
    this.context = registry;
    customMetrics = new PrometheusCustomMetricsSupport(this);
    registerDefaultDescriptor();
    // Prometheus Monitoring
    KieServerExtension jBPMExtension = context.getServerExtension(JbpmKieServerExtension.EXTENSION_NAME);
    if (jBPMExtension != null) {
        final KModuleDeploymentService deploymentService = jBPMExtension.getAppComponents(KModuleDeploymentService.class);
        if (deploymentService != null) {
            List<DeploymentEventListener> metrics = customMetrics.getDeploymentEventListener();
            if (!metrics.isEmpty()) {
                List<DeploymentEventListener> listeners = new ArrayList<>(metrics);
                listeners.forEach(l -> deploymentService.addListener(l));
            }
            deploymentService.addListener(new PrometheusDeploymentEventListener());
        }
        final ExecutorServiceImpl executorService = jBPMExtension.getAppComponents(ExecutorServiceImpl.class);
        if (executorService != null) {
            List<AsynchronousJobListener> metrics = customMetrics.getAsynchronousJobListener();
            if (!metrics.isEmpty()) {
                List<AsynchronousJobListener> listeners = new ArrayList<>(metrics);
                listeners.forEach(l -> executorService.addAsyncJobListener(l));
            }
            executorService.addAsyncJobListener(new PrometheusJobListener());
        }
        final QueryServiceImpl queryService = jBPMExtension.getAppComponents(QueryServiceImpl.class);
        if (queryService != null) {
            final DataSetDefRegistry dataSetDefRegistry = queryService.getDataSetDefRegistry();
            final PrometheusDataSetListener listener = new PrometheusDataSetListener(dataSetDefRegistry);
            listener.init();
            dataSetDefRegistry.addListener(listener);
        }
        final RuntimeDataService dataService = jBPMExtension.getAppComponents(RuntimeDataService.class);
        if (dataService != null) {
            final Collection<ProcessInstanceDesc> processInstances = dataService.getProcessInstances(asList(ProcessInstance.STATE_ACTIVE), null, new QueryContext(0, Integer.MAX_VALUE));
            processInstances.forEach(pi -> recordRunningProcessInstance(pi.getDeploymentId(), pi.getProcessId()));
        }
    }
    KieServerExtension caseExtension = context.getServerExtension(CaseKieServerExtension.EXTENSION_NAME);
    if (caseExtension != null) {
        final CaseManagementRuntimeDataServiceBase caseRuntime = caseExtension.getAppComponents(CaseManagementRuntimeDataServiceBase.class);
        if (caseRuntime != null) {
            final CaseInstanceList caseInstances = caseRuntime.getCaseInstances(asList(CaseStatus.OPEN.getName()), 0, Integer.MAX_VALUE, null, false);
            for (CaseInstance instance : caseInstances.getCaseInstances()) {
                recordRunningCaseInstance(instance.getCaseDefinitionId());
            }
        }
    }
    initialized = true;
    if (!customMetrics.hasCustomMetrics()) {
        LOGGER.info("{} started", toString());
    } else {
        LOGGER.info("{} started with custom Prometheus metrics provider(s): {}", toString(), customMetrics.customMetricsProviders());
    }
}
Also used : RuntimeDataService(org.jbpm.services.api.RuntimeDataService) AsynchronousJobListener(org.jbpm.executor.AsynchronousJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) JbpmKieServerExtension(org.kie.server.services.jbpm.JbpmKieServerExtension) KieServerExtension(org.kie.server.services.api.KieServerExtension) CaseKieServerExtension(org.kie.server.services.casemgmt.CaseKieServerExtension) CaseManagementRuntimeDataServiceBase(org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase) ArrayList(java.util.ArrayList) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) QueryContext(org.kie.api.runtime.query.QueryContext) DataSetDefRegistry(org.dashbuilder.dataset.def.DataSetDefRegistry) CaseInstanceList(org.kie.server.api.model.cases.CaseInstanceList) CaseInstance(org.kie.server.api.model.cases.CaseInstance) PrometheusCaseEventListener.recordRunningCaseInstance(org.kie.server.services.prometheus.PrometheusCaseEventListener.recordRunningCaseInstance) KModuleDeploymentService(org.jbpm.kie.services.impl.KModuleDeploymentService) DeploymentEventListener(org.jbpm.services.api.DeploymentEventListener) QueryServiceImpl(org.jbpm.kie.services.impl.query.QueryServiceImpl)

Example 4 with CaseManagementRuntimeDataServiceBase

use of org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase in project businessautomation-cop by redhat-cop.

the class CustomCaseMgmtKieServerAppComponentService method getAppComponents.

public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
    // skip calls from other than owning extension
    if (!OWNER_EXTENSION.equals(extension)) {
        return Collections.emptyList();
    }
    logger.info("Creating custom kie server extension CustomCaseMgmtKieServerAppComponentService");
    KieServerRegistry registry = null;
    CaseManagementServiceBase caseManagementServiceBase = null;
    CaseManagementRuntimeDataServiceBase caseManagementRuntimeDataService = null;
    for (Object object : services) {
        if (CaseManagementServiceBase.class.isAssignableFrom(object.getClass())) {
            caseManagementServiceBase = (CaseManagementServiceBase) object;
            continue;
        } else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
            registry = (KieServerRegistry) object;
            continue;
        } else if (CaseManagementRuntimeDataServiceBase.class.isAssignableFrom(object.getClass())) {
            caseManagementRuntimeDataService = (CaseManagementRuntimeDataServiceBase) object;
        }
    }
    List<Object> components = new ArrayList<Object>(1);
    if (SupportedTransports.REST.equals(type)) {
        components.add(new GetCasesWithDataResource(caseManagementServiceBase, caseManagementRuntimeDataService, registry));
    }
    return components;
}
Also used : KieServerRegistry(org.kie.server.services.api.KieServerRegistry) CaseManagementRuntimeDataServiceBase(org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase) CaseManagementServiceBase(org.kie.server.services.casemgmt.CaseManagementServiceBase) ArrayList(java.util.ArrayList)

Aggregations

CaseManagementRuntimeDataServiceBase (org.kie.server.services.casemgmt.CaseManagementRuntimeDataServiceBase)4 ArrayList (java.util.ArrayList)3 CaseManagementServiceBase (org.kie.server.services.casemgmt.CaseManagementServiceBase)3 KieServerRegistry (org.kie.server.services.api.KieServerRegistry)2 CaseAdminServiceBase (org.kie.server.services.casemgmt.CaseAdminServiceBase)2 DataSetDefRegistry (org.dashbuilder.dataset.def.DataSetDefRegistry)1 AsynchronousJobListener (org.jbpm.executor.AsynchronousJobListener)1 ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)1 KModuleDeploymentService (org.jbpm.kie.services.impl.KModuleDeploymentService)1 QueryServiceImpl (org.jbpm.kie.services.impl.query.QueryServiceImpl)1 DeploymentEventListener (org.jbpm.services.api.DeploymentEventListener)1 RuntimeDataService (org.jbpm.services.api.RuntimeDataService)1 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)1 QueryContext (org.kie.api.runtime.query.QueryContext)1 CaseInstance (org.kie.server.api.model.cases.CaseInstance)1 CaseInstanceList (org.kie.server.api.model.cases.CaseInstanceList)1 KieServerExtension (org.kie.server.services.api.KieServerExtension)1 CaseKieServerExtension (org.kie.server.services.casemgmt.CaseKieServerExtension)1 JbpmKieServerExtension (org.kie.server.services.jbpm.JbpmKieServerExtension)1 PrometheusCaseEventListener.recordRunningCaseInstance (org.kie.server.services.prometheus.PrometheusCaseEventListener.recordRunningCaseInstance)1