public ServiceResponse<KieScannerResource> getScannerInfo(String id) { try { KieContainerInstance kci = context.getContainer(id); if (kci != null && kci.getKieContainer() != null) { KieScannerResource info = getScannerResource( kci ); kci.getResource().setScanner( info ); return new ServiceResponse<KieScannerResource>(ServiceResponse.ResponseType.SUCCESS, "Scanner info successfully retrieved", info); } else { return new ServiceResponse<KieScannerResource>(ServiceResponse.ResponseType.FAILURE, "Unknown container " + id + "."); } } catch (Exception e) { logger.error("Error retrieving scanner info for container '" + id + "'.", e); return new ServiceResponse<KieScannerResource>(ServiceResponse.ResponseType.FAILURE, "Error retrieving scanner info for container '" + id + "': " + e.getClass().getName() + ": " + e.getMessage()); } }
public ServiceResponse<KieContainerResourceList> listContainers() { try { List<KieContainerResource> containers = new ArrayList<KieContainerResource>(); for (KieContainerInstance instance : context.getContainers()) { containers.add(instance.getResource()); } KieContainerResourceList cil = new KieContainerResourceList(containers); return new ServiceResponse<KieContainerResourceList>(ServiceResponse.ResponseType.SUCCESS, "List of created containers", cil); } catch (Exception e) { logger.error("Error retrieving list of containers", e); return new ServiceResponse<KieContainerResourceList>(ServiceResponse.ResponseType.FAILURE, "Error listing containers: " + e.getClass().getName() + ": " + e.getMessage()); } }
public ServiceResponse<Void> disposeContainer(String containerId) { try { KieContainerInstance kci = (KieContainerInstance) context.removeContainer(containerId); if (kci != null) { synchronized (kci) {
KieContainerInstance kci = (KieContainerInstance) context.getContainer( containerId );
KieContainerInstance kci = context.getContainer(id); if (kci != null && kci.getKieContainer() != null) { ServiceResponse<KieScannerResource> result = null;
previous = context.addIfDoesntExist(containerId, ci); if (previous == null) { try {
public ServiceResponse<ReleaseId> updateContainerReleaseId(String id, ReleaseId releaseId) { if( releaseId == null ) { logger.error("Error updating releaseId for container '" + id + "'. ReleaseId is null."); return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Error updating releaseId for container " + id + ". ReleaseId is null. "); } try { KieContainerInstance kci = context.getContainer(id); // the following code is subject to a concurrent call to dispose(), but the cost of synchronizing it // would likely not be worth it. At this point a decision was made to fail the execution if a concurrent // call do dispose() is executed. if (kci != null && kci.getKieContainer() != null) { Results results = kci.getKieContainer().updateToVersion(releaseId); if (results.hasMessages(Level.ERROR)) { logger.error("Error updating releaseId for container " + id + " to version " + releaseId + "\nMessages: " + results.getMessages()); return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Error updating release id on container " + id + " to " + releaseId, kci.getResource().getReleaseId()); } else { return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.SUCCESS, "Release id successfully updated.", kci.getResource().getReleaseId()); } } else { return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Container " + id + " is not instantiated."); } } catch (Exception e) { logger.error("Error updating releaseId for container '" + id + "'", e); return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Error updating releaseId for container " + id + ": " + e.getClass().getName() + ": " + e.getMessage()); } }
public ServiceResponse<KieContainerResource> getContainerInfo(String id) { try { KieContainerInstance ci = context.getContainer(id); if (ci != null) { if( ci.getResource().getScanner() == null ) { ci.getResource().setScanner( getScannerResource( ci ) ); } return new ServiceResponse<KieContainerResource>(ServiceResponse.ResponseType.SUCCESS, "Info for container " + id, ci.getResource()); } return new ServiceResponse<KieContainerResource>(ServiceResponse.ResponseType.FAILURE, "Container " + id + " is not instantiated."); } catch (Exception e) { logger.error("Error retrieving info for container '" + id + "'", e); return new ServiceResponse<KieContainerResource>(ServiceResponse.ResponseType.FAILURE, "Error retrieving container info: " + e.getClass().getName() + ": " + e.getMessage()); } }
public KieServerImpl() { this.context = new KieContainersRegistryImpl(); }
public ServiceResponse<ReleaseId> getContainerReleaseId(String id) { try { KieContainerInstance ci = context.getContainer(id); if (ci != null) { return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.SUCCESS, "ReleaseId for container " + id, ci.getResource().getReleaseId()); } return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Container " + id + " is not instantiated."); } catch (Exception e) { logger.error("Error retrieving releaseId for container '" + id + "'", e); return new ServiceResponse<ReleaseId>(ServiceResponse.ResponseType.FAILURE, "Error retrieving container releaseId: " + e.getClass().getName() + ": " + e.getMessage()); } }