@Override public ServiceResponse<KieContainerResource> createContainer(String id, KieContainerResource resource) { if( config.isRest() ) { return makeHttpPutRequestAndCreateServiceResponse( baseURI + "/containers/" + id, resource, KieContainerResource.class ); } else { CommandScript script = new CommandScript( Collections.singletonList( (KieServerCommand) new CreateContainerCommand( resource ) ) ); return (ServiceResponse<KieContainerResource>) executeJmsCommand( script ).getResponses().get( 0 ); } }
public ServiceResponsesList executeScript(CommandScript commands) { List<ServiceResponse<? extends Object>> responses = new ArrayList<ServiceResponse<? extends Object>>(); if( commands != null ) { for (KieServerCommand command : commands.getCommands()) { if (command instanceof CreateContainerCommand) { responses.add(createContainer(((CreateContainerCommand) command).getContainer().getContainerId(), ((CreateContainerCommand) command).getContainer())); } else if (command instanceof GetServerInfoCommand) { responses.add(getInfo()); } else if (command instanceof ListContainersCommand) { responses.add(listContainers()); } else if (command instanceof CallContainerCommand) { responses.add(callContainer(((CallContainerCommand) command).getContainerId(), ((CallContainerCommand) command).getPayload())); } else if (command instanceof DisposeContainerCommand) { responses.add(disposeContainer(((DisposeContainerCommand) command).getContainerId())); } else if (command instanceof GetContainerInfoCommand ) { responses.add(getContainerInfo(((GetContainerInfoCommand) command).getContainerId())); } else if (command instanceof GetScannerInfoCommand ) { responses.add(getScannerInfo(((GetScannerInfoCommand) command).getContainerId())); } else if (command instanceof UpdateScannerCommand ) { responses.add(updateScanner(((UpdateScannerCommand) command).getContainerId(), ((UpdateScannerCommand) command).getScanner())); } else if (command instanceof UpdateReleaseIdCommand ) { responses.add(updateContainerReleaseId(((UpdateReleaseIdCommand) command).getContainerId(), ((UpdateReleaseIdCommand) command).getReleaseId())); } } } return new ServiceResponsesList(responses); }
responses.add(this.kieServer.createContainer(((CreateContainerCommand) command).getContainer().getContainerId(), ((CreateContainerCommand) command).getContainer())); } else if (command instanceof GetServerInfoCommand) { responses.add(this.kieServer.getInfo());
@Override public ServiceResponse<KieContainerResource> createContainer(String id, KieContainerResource resource) { CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new CreateContainerCommand(resource))); ServiceResponse<KieContainerResource> response = (ServiceResponse<KieContainerResource>) sendCommandToAllSessions(script, new WebSocketServiceResponse(true, (message) -> { ServiceResponsesList list = WebSocketUtils.unmarshal(message, ServiceResponsesList.class); return list.getResponses().get(0); })).getResponses().get(0); return response; }
@Override public ServiceResponse<KieContainerResource> createContainer(String id, KieContainerResource resource) { if( config.isRest() ) { return makeHttpPutRequestAndCreateServiceResponse( loadBalancer.getUrl() + "/containers/" + id, resource, KieContainerResource.class ); } else { CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new CreateContainerCommand(resource))); ServiceResponse<KieContainerResource> response = (ServiceResponse<KieContainerResource>) executeJmsCommand(script, null, null, id).getResponses().get(0); return getResponseOrNullIfNoResponse(response); } }