Search in sources :

Example 16 with ServiceResponsesList

use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.

the class WebSocketKieServerClient method updateScanner.

@Override
public ServiceResponse<KieScannerResource> updateScanner(String id, KieScannerResource resource) {
    CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new UpdateScannerCommand(id, resource)));
    ServiceResponse<KieScannerResource> response = (ServiceResponse<KieScannerResource>) sendCommandToAllSessions(script, new WebSocketServiceResponse(true, (message) -> {
        ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
        return list.getResponses().get(0);
    })).getResponses().get(0);
    return response;
}
Also used : ServiceResponsesList(org.kie.server.api.model.ServiceResponsesList) WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) UpdateScannerCommand(org.kie.server.api.commands.UpdateScannerCommand) KieScannerResource(org.kie.server.api.model.KieScannerResource) WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) CommandScript(org.kie.server.api.commands.CommandScript)

Example 17 with ServiceResponsesList

use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.

the class CommandScriptMessageHandler method onMessage.

@Override
public String onMessage(String message) {
    CommandScript script = deserialize(message, CommandScript.class);
    String capability = TARGET_CAPABILITY;
    boolean hasBPMCommand = script.getCommands().stream().anyMatch(cmd -> cmd instanceof DescriptorCommand);
    if (hasBPMCommand) {
        capability = KieServerConstants.CAPABILITY_BPM;
    }
    KieContainerCommandService<?> executor = null;
    for (KieServerExtension extension : context.getServerExtensions()) {
        KieContainerCommandService<?> tmp = extension.getAppComponents(KieContainerCommandService.class);
        if (tmp != null && extension.getImplementedCapability().equalsIgnoreCase(capability)) {
            executor = tmp;
            logger.debug("Extension {} returned command executor {} with capability {}", extension, executor, extension.getImplementedCapability());
            break;
        }
    }
    if (executor == null) {
        throw new IllegalStateException("No executor found for script execution");
    }
    // 4. process request
    ServiceResponsesList response = executor.executeScript(script, MarshallingFormat.JSON, null);
    String reply = serialize(response);
    return reply;
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponsesList(org.kie.server.api.model.ServiceResponsesList) KieServerExtension(org.kie.server.services.api.KieServerExtension) CommandScript(org.kie.server.api.commands.CommandScript)

Example 18 with ServiceResponsesList

use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.

the class WebSocketKieServerClient method getServerInfo.

@Override
public ServiceResponse<KieServerInfo> getServerInfo() {
    CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new GetServerInfoCommand()));
    ServiceResponse<KieServerInfo> response = (ServiceResponse<KieServerInfo>) sendCommand(script, new WebSocketServiceResponse(true, (message) -> {
        ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
        return list.getResponses().get(0);
    })).getResponses().get(0);
    return response;
}
Also used : ServiceResponsesList(org.kie.server.api.model.ServiceResponsesList) WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) CommandScript(org.kie.server.api.commands.CommandScript) GetServerInfoCommand(org.kie.server.api.commands.GetServerInfoCommand) KieServerInfo(org.kie.server.api.model.KieServerInfo)

Example 19 with ServiceResponsesList

use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.

the class WebSocketKieServerClient method listContainers.

@Override
public ServiceResponse<KieContainerResourceList> listContainers(KieContainerResourceFilter containerFilter) {
    CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new ListContainersCommand(containerFilter)));
    ServiceResponse<KieContainerResourceList> response = (ServiceResponse<KieContainerResourceList>) sendCommand(script, new WebSocketServiceResponse(true, (message) -> {
        ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
        return list.getResponses().get(0);
    })).getResponses().get(0);
    return response;
}
Also used : ServiceResponsesList(org.kie.server.api.model.ServiceResponsesList) ListContainersCommand(org.kie.server.api.commands.ListContainersCommand) KieContainerResourceList(org.kie.server.api.model.KieContainerResourceList) WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) CommandScript(org.kie.server.api.commands.CommandScript)

Example 20 with ServiceResponsesList

use of org.kie.server.api.model.ServiceResponsesList in project droolsjbpm-integration by kiegroup.

the class WebSocketKieServerClient method disposeContainer.

@Override
public ServiceResponse<Void> disposeContainer(String id) {
    CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DisposeContainerCommand(id)));
    ServiceResponse<Void> response = (ServiceResponse<Void>) sendCommandToAllSessions(script, new WebSocketServiceResponse(true, (message) -> {
        ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class);
        return list.getResponses().get(0);
    })).getResponses().get(0);
    return response;
}
Also used : ServiceResponsesList(org.kie.server.api.model.ServiceResponsesList) WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) WebSocketServiceResponse(org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse) CommandScript(org.kie.server.api.commands.CommandScript) DisposeContainerCommand(org.kie.server.api.commands.DisposeContainerCommand)

Aggregations

ServiceResponsesList (org.kie.server.api.model.ServiceResponsesList)30 ServiceResponse (org.kie.server.api.model.ServiceResponse)23 KieServerCommand (org.kie.server.api.model.KieServerCommand)18 CommandScript (org.kie.server.api.commands.CommandScript)17 WebSocketServiceResponse (org.kie.server.controller.websocket.common.handlers.WebSocketServiceResponse)13 ArrayList (java.util.ArrayList)9 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)5 KieContainerResource (org.kie.server.api.model.KieContainerResource)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 JMSException (javax.jms.JMSException)4 CreateContainerCommand (org.kie.server.api.commands.CreateContainerCommand)4 DisposeContainerCommand (org.kie.server.api.commands.DisposeContainerCommand)4 Wrapped (org.kie.server.api.model.Wrapped)4 TextMessage (javax.jms.TextMessage)3 Test (org.junit.Test)3 UpdateReleaseIdCommand (org.kie.server.api.commands.UpdateReleaseIdCommand)3 UpdateScannerCommand (org.kie.server.api.commands.UpdateScannerCommand)3 KieServicesException (org.kie.server.api.exception.KieServicesException)3 ReleaseId (org.kie.server.api.model.ReleaseId)3 IOException (java.io.IOException)2