import java.io.IOException; import java.nio.file.*; public class ListenDirectory { public static void main(String[] args) { Path path = Paths.get(args[0]); WatchService watchService = null; try { watchService = path.getFileSystem().newWatchService(); path.register(watchService, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_CREATE); } catch (IOException e) { e.printStackTrace(); } WatchKey key = null; try{ //infinite loop while((key = watchService.take())!=null){// blocks until a key is available // iterate for each event for(WatchEvent<?> event:key.pollEvents()){ switch(event.kind().name()){ case "OVERFLOW": System.out.println("Indicates that events might have been lost or discarded. It is not necessary to register for the OVERFLOW event to receive it."); break; case "ENTRY_MODIFY": System.out.println("File " + event.context() + " is changed!"); break; case "ENTRY_CREATE": System.out.println("File " + event.context() + " is created!"); break; case "ENTRY_DELETE": System.out.println("File " + event.context() + " is deleted!"); break; } } //resetting the key is important to receive subsequent notifications key.reset(); } }catch(InterruptedException e){return;} } }
Introduction Obfuscation is the act of reorganizing bytecode such that it becomes hard to decompile. Many developers rely on obfuscation to save their sensitive code from undesired eyes. Publishing jars without obfuscation may hinder competitiveness because rivals may take advantage of easily decompilable nature of java binaries. Objective Spring Boot applications make use of public interfaces, annotations which makes applications harder to obfuscate. Additionally, maven Spring Boot plugin creates a fat jar which contains all dependent jars. It is not viable to obfuscate the whole fat jar. Thus obfuscating Spring Boot applications is different than obfuscating regular java applications and requires a suitable strategy. Audience Those who use Spring Boot and Maven and wish to obfuscate their application using Proguard are the target audience for this article. Sample Application As the sample application, I will use elastic search synch application from my G...
Comments
Post a Comment