コード例 #1
0
 private ServiceResponse<KieScannerResource> startScanner(
     String id, KieScannerResource resource, KieContainerInstance kci) {
   if (kci.getScanner() == null) {
     ServiceResponse<KieScannerResource> response = createScanner(id, kci);
     if (ResponseType.FAILURE.equals(response.getType())) {
       return response;
     }
   }
   if (KieScannerStatus.STOPPED.equals(mapStatus(kci.getScanner().getStatus()))
       && resource.getPollInterval() != null) {
     kci.getScanner().start(resource.getPollInterval());
     return new ServiceResponse<KieScannerResource>(
         ServiceResponse.ResponseType.SUCCESS,
         "Kie scanner successfuly created.",
         new KieScannerResource(mapStatus(kci.getScanner().getStatus())));
   } else if (!KieScannerStatus.STOPPED.equals(mapStatus(kci.getScanner().getStatus()))) {
     return new ServiceResponse<KieScannerResource>(
         ServiceResponse.ResponseType.FAILURE,
         "Invalid kie scanner status: " + mapStatus(kci.getScanner().getStatus()),
         new KieScannerResource(mapStatus(kci.getScanner().getStatus())));
   } else if (resource.getPollInterval() == null) {
     return new ServiceResponse<KieScannerResource>(
         ServiceResponse.ResponseType.FAILURE,
         "Invalid polling interval: " + resource.getPollInterval(),
         new KieScannerResource(mapStatus(kci.getScanner().getStatus())));
   }
   return new ServiceResponse<KieScannerResource>(
       ServiceResponse.ResponseType.FAILURE,
       "Unknown error starting scanner. Scanner was not started." + resource,
       new KieScannerResource(mapStatus(kci.getScanner().getStatus())));
 }
コード例 #2
0
 private ServiceResponse<KieScannerResource> disposeScanner(
     String id, KieScannerResource resource, KieContainerInstance kci) {
   if (kci.getScanner() == null) {
     return new ServiceResponse<KieScannerResource>(
         ServiceResponse.ResponseType.SUCCESS,
         "Invalid call. Scanner already disposed. ",
         new KieScannerResource(KieScannerStatus.DISPOSED));
   }
   if (KieScannerStatus.STARTED.equals(mapStatus(kci.getScanner().getStatus()))
       || KieScannerStatus.SCANNING.equals(mapStatus(kci.getScanner().getStatus()))) {
     ServiceResponse<KieScannerResource> response = stopScanner(id, resource, kci);
     if (ResponseType.FAILURE.equals(response.getType())) {
       return response;
     }
   }
   kci.getScanner().shutdown();
   kci.setScanner(null);
   return new ServiceResponse<KieScannerResource>(
       ServiceResponse.ResponseType.SUCCESS,
       "Kie scanner successfuly shutdown.",
       new KieScannerResource(KieScannerStatus.DISPOSED));
 }