use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class JbpmRestApplicationComponentsService 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();
}
ProcessService processService = null;
RuntimeDataService runtimeDataService = null;
DefinitionService definitionService = null;
UserTaskService userTaskService = null;
ExecutorService executorService = null;
QueryService queryService = null;
ProcessInstanceMigrationService processInstanceMigrationService = null;
ProcessInstanceAdminService processInstanceAdminService = null;
UserTaskAdminService userTaskAdminService = null;
KieServerRegistry context = null;
AdvanceRuntimeDataService advanceRuntimeDataService = null;
for (Object object : services) {
// in case given service is null (meaning was not configured) continue with next one
if (object == null) {
continue;
}
if (ProcessService.class.isAssignableFrom(object.getClass())) {
processService = (ProcessService) object;
continue;
} else if (RuntimeDataService.class.isAssignableFrom(object.getClass())) {
runtimeDataService = (RuntimeDataService) object;
continue;
} else if (DefinitionService.class.isAssignableFrom(object.getClass())) {
definitionService = (DefinitionService) object;
continue;
} else if (UserTaskService.class.isAssignableFrom(object.getClass())) {
userTaskService = (UserTaskService) object;
continue;
} else if (ExecutorService.class.isAssignableFrom(object.getClass())) {
executorService = (ExecutorService) object;
continue;
} else if (QueryService.class.isAssignableFrom(object.getClass())) {
queryService = (QueryService) object;
continue;
} else if (ProcessInstanceMigrationService.class.isAssignableFrom(object.getClass())) {
processInstanceMigrationService = (ProcessInstanceMigrationService) object;
continue;
} else if (ProcessInstanceAdminService.class.isAssignableFrom(object.getClass())) {
processInstanceAdminService = (ProcessInstanceAdminService) object;
continue;
} else if (UserTaskAdminService.class.isAssignableFrom(object.getClass())) {
userTaskAdminService = (UserTaskAdminService) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
} else if (AdvanceRuntimeDataService.class.isAssignableFrom(object.getClass())) {
advanceRuntimeDataService = (AdvanceRuntimeDataService) object;
continue;
}
}
List<Object> components = new ArrayList<Object>(6);
DefinitionServiceBase definitionServiceBase = new DefinitionServiceBase(definitionService, context);
ProcessServiceBase processServiceBase = new ProcessServiceBase(processService, definitionService, runtimeDataService, context);
UserTaskServiceBase userTaskServiceBase = new UserTaskServiceBase(userTaskService, context);
RuntimeDataServiceBase runtimeDataServiceBase = new RuntimeDataServiceBase(runtimeDataService, advanceRuntimeDataService, context);
ExecutorServiceBase executorServiceBase = new ExecutorServiceBase(executorService, context);
QueryDataServiceBase queryDataServiceBase = new QueryDataServiceBase(queryService, context);
DocumentServiceBase documentServiceBase = new DocumentServiceBase(context);
ProcessAdminServiceBase processAdminServiceBase = new ProcessAdminServiceBase(processInstanceMigrationService, processInstanceAdminService, runtimeDataService, context);
UserTaskAdminServiceBase userTaskAdminServiceBase = new UserTaskAdminServiceBase(userTaskAdminService, context);
components.add(new ProcessResource(processServiceBase, runtimeDataServiceBase, context));
components.add(new RuntimeDataResource(runtimeDataServiceBase, context));
components.add(new DefinitionResource(definitionServiceBase, context));
components.add(new UserTaskResource(userTaskServiceBase, runtimeDataServiceBase, context));
components.add(new ExecutorResource(executorServiceBase, context));
components.add(new QueryDataResource(queryDataServiceBase, context));
components.add(new DocumentResource(documentServiceBase, context));
components.add(new ProcessAdminResource(processAdminServiceBase, context));
components.add(new UserTaskAdminResource(userTaskAdminServiceBase, context));
return components;
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class OptaplannerRestApplicationComponentsService 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();
}
SolverServiceBase solverServiceBase = 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 (SolverServiceBase.class.isAssignableFrom(object.getClass())) {
solverServiceBase = (SolverServiceBase) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
}
}
List<Object> components = new ArrayList<Object>(1);
components.add(new SolverResource(solverServiceBase));
return components;
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class DroolsRestApplicationComponentsService 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();
}
KieContainerCommandService batchCommandService = null;
KieServerRegistry context = null;
for (Object object : services) {
if (KieContainerCommandService.class.isAssignableFrom(object.getClass())) {
batchCommandService = (KieContainerCommandService) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
}
}
List<Object> components = new ArrayList<Object>(1);
if (SupportedTransports.REST.equals(type)) {
components.add(new CommandResource(batchCommandService, context));
}
return components;
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class KeepLatestContainerOnlyPolicy method apply.
@Override
public void apply(KieServerRegistry kieServerRegistry, KieServer kieServer) {
DefaultRestControllerImpl controller = new DefaultRestControllerImpl(kieServerRegistry);
List<String> containerAliases = kieServerRegistry.getContainerAliases();
if (containerAliases.isEmpty()) {
logger.debug("No containers found, quiting");
return;
}
for (String alias : containerAliases) {
List<KieContainerInstanceImpl> containerInstances = kieServerRegistry.getContainersForAlias(alias);
if (containerInstances.isEmpty() || containerInstances.size() == 1) {
logger.debug("Containers for alias {} are already on expected level (number of containers is {})", alias, containerInstances.size());
continue;
}
String latestContainerId = LatestContainerLocator.get().locateContainer(alias, containerInstances);
final Map<String, String> report = new HashMap<>();
containerInstances.stream().filter(kci -> !kci.getContainerId().equals(latestContainerId)).filter(kci -> !kci.getStatus().equals(KieContainerStatus.CREATING)).forEach(kci -> {
ServiceResponse<Void> response = kieServer.disposeContainer(kci.getContainerId());
report.put(kci.getContainerId(), response.getType().toString());
logger.debug("Dispose of container {} completed with {} message {}", kci.getContainerId(), response.getType().toString(), response.getMsg());
if (response.getType().equals(ServiceResponse.ResponseType.SUCCESS)) {
controller.stopContainer(kci.getContainerId());
}
});
logger.info("KeepLatestContainerOnlyPolicy applied to {} successfully (report {})", alias, report);
}
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class TaskAssigningRuntimeRestApplicationComponentsService method getAppComponents.
@Override
public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
if (!OWNER_EXTENSION.equals(extension)) {
return Collections.emptyList();
}
TaskAssigningRuntimeServiceBase taskAssigningRuntimeServiceBase = 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) {
if (TaskAssigningRuntimeServiceBase.class.isAssignableFrom(object.getClass())) {
taskAssigningRuntimeServiceBase = (TaskAssigningRuntimeServiceBase) object;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
}
}
}
return Collections.singleton(new TaskAssigningRuntimeResource(taskAssigningRuntimeServiceBase, context));
}
Aggregations