Source:
public void created (Path path) { File createdFile = path.toFile(); LOG.info("Created called with " + createdFile); boolean succeeded = false; try { if (createdFile.getName().endsWith(".tar")) { LOG.info("Processing file at " + path); CustomProcessorInfo customProcessorInfo = this.getCustomProcessorInfo(createdFile); if (customProcessorInfo == null) { LOG.info("No information found for CustomProcessor in " + createdFile); return; } InputStream jarFile = this.getJarFile(customProcessorInfo, createdFile); if (jarFile == null) { LOG.info("No jar file found for CustomProcessor in " + createdFile); return; } File tempJarFile = FileUtil.writeInputStreamToTempFile(jarFile, ".jar"); ProxyUtil<CustomProcessor> customProcessorProxyUtil = new ProxyUtil<>(CustomProcessor.class); CustomProcessor customProcessor = customProcessorProxyUtil.loadClassFromJar(tempJarFile.getAbsolutePath(), customProcessorInfo.getCustomProcessorImpl()); InputStream imageFile = this.getImageFile(customProcessorInfo, createdFile); if (imageFile == null) { LOG.info("No image file found for CustomProcessor in " + createdFile); return; } jarFile.reset(); this.catalogService.addCustomProcessorInfo(customProcessorInfo, jarFile, imageFile); succeeded = true; } else { LOG.info("Failing unsupported file that was received: " + path); } } catch (IOException e) { LOG.warn("Exception occured while processing tar file: " + createdFile, e); } catch (ClassNotFoundException|InstantiationException|IllegalAccessException e) { LOG.warn("Could not load a class from jar file implementing CustomProcessor interface from " + createdFile, e); } finally { try { if (succeeded) { LOG.info("CustomProcessor uploaded successfully from " + createdFile + " Moving file to " + uploadSuccessPath); moveFileSuccess(createdFile); } else { LOG.info("CustomProcessor failed to upload from " + createdFile + " Moving file to " + uploadFailPath); moveFileFail(createdFile); } } catch (IOException e1) { LOG.warn("Error moving " + createdFile.getAbsolutePath() + " to " + (succeeded ? uploadSuccessPath : uploadFailPath), e1); } } }

Target:
public void created (Path path) { File createdFile = path.toFile(); LOG.info("Created called with " + createdFile); boolean succeeded = false; try { if (createdFile.getName().endsWith(".tar")) { LOG.info("Processing file at " + path); CustomProcessorInfo customProcessorInfo = this.getCustomProcessorInfo(createdFile); if (customProcessorInfo == null) { LOG.warn("No information found for CustomProcessor in " + createdFile); return; } InputStream jarFile = this.getJarFile(customProcessorInfo, createdFile); if (jarFile == null) { LOG.warn("No jar file found for CustomProcessor in " + createdFile); return; } File tempJarFile = FileUtil.writeInputStreamToTempFile(jarFile, ".jar"); ProxyUtil<CustomProcessor> customProcessorProxyUtil = new ProxyUtil<>(CustomProcessor.class); CustomProcessor customProcessor = customProcessorProxyUtil.loadClassFromJar(tempJarFile.getAbsolutePath(), customProcessorInfo.getCustomProcessorImpl()); InputStream imageFile = this.getImageFile(customProcessorInfo, createdFile); if (imageFile == null) { LOG.warn("No image file found for CustomProcessor in " + createdFile); return; } jarFile.reset(); this.catalogService.addCustomProcessorInfo(customProcessorInfo, jarFile, imageFile); succeeded = true; } else { LOG.info("Failing unsupported file that was received: " + path); } } catch (IOException e) { LOG.warn("Exception occured while processing tar file: " + createdFile, e); } catch (ClassNotFoundException|InstantiationException|IllegalAccessException e) { LOG.warn("Could not load a class from jar file implementing CustomProcessor interface from " + createdFile, e); } finally { try { if (succeeded) { LOG.info("CustomProcessor uploaded successfully from " + createdFile + " Moving file to " + uploadSuccessPath); moveFileToSuccessDirectory(createdFile); } else { LOG.warn("CustomProcessor failed to upload from " + createdFile + " Moving file to " + uploadFailPath); moveFileToFailDirectory(createdFile); } } catch (IOException e1) { LOG.warn("Error moving " + createdFile.getAbsolutePath() + " to " + (succeeded ? uploadSuccessPath : uploadFailPath), e1); } } }