コード例 #1
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));
 }
コード例 #2
0
 private ServiceResponse<KieScannerResource> stopScanner(
     String id, KieScannerResource resource, KieContainerInstance kci) {
   if (kci.getScanner() == null) {
     return new ServiceResponse<KieScannerResource>(
         ServiceResponse.ResponseType.FAILURE,
         "Invalid call. Scanner is not instantiated. ",
         new KieScannerResource(KieScannerStatus.DISPOSED));
   }
   if (KieScannerStatus.STARTED.equals(mapStatus(kci.getScanner().getStatus()))
       || KieScannerStatus.SCANNING.equals(mapStatus(kci.getScanner().getStatus()))) {
     kci.getScanner().stop();
     return new ServiceResponse<KieScannerResource>(
         ServiceResponse.ResponseType.SUCCESS,
         "Kie scanner successfuly stopped.",
         new KieScannerResource(mapStatus(kci.getScanner().getStatus())));
   } else {
     return new ServiceResponse<KieScannerResource>(
         ServiceResponse.ResponseType.FAILURE,
         "Invalid kie scanner status: " + mapStatus(kci.getScanner().getStatus()),
         new KieScannerResource(mapStatus(kci.getScanner().getStatus())));
   }
 }