1 32 33 package com.jeantessier.classreader; 34 35 import java.io.*; 36 37 import org.apache.log4j.*; 38 39 public class PermissiveDispatcher implements ClassfileLoaderDispatcher { 40 public int dispatch(String filename) { 41 int result; 42 43 if (filename.endsWith(".zip")) { 44 result = ACTION_ZIP; 45 Logger.getLogger(getClass()).debug("Dispatching \"" + filename + "\": ACTION_ZIP"); 46 } else if (filename.endsWith(".jar")) { 47 result = ACTION_JAR; 48 Logger.getLogger(getClass()).debug("Dispatching \"" + filename + "\": ACTION_JAR"); 49 } else if (filename.endsWith(".class")) { 50 result = ACTION_CLASS; 51 Logger.getLogger(getClass()).debug("Dispatching \"" + filename + "\": ACTION_CLASS"); 52 } else if (new File(filename).isDirectory()) { 53 result = ACTION_DIRECTORY; 54 Logger.getLogger(getClass()).debug("Dispatching \"" + filename + "\": ACTION_DIRECTORY"); 55 } else if (filename.endsWith("/") || 56 filename.endsWith(".bat") || 57 filename.endsWith(".css") || 58 filename.endsWith(".dtd") || 59 filename.endsWith(".gif") || 60 filename.endsWith(".htm") || 61 filename.endsWith(".html") || 62 filename.endsWith(".java") || 63 filename.endsWith(".jpeg") || 64 filename.endsWith(".jpg") || 65 filename.endsWith(".js") || 66 filename.endsWith(".jsp") || 67 filename.endsWith("MANIFEST.MF") || 68 filename.endsWith(".properties") || 69 filename.endsWith(".ps") || 70 filename.endsWith(".txt") || 71 filename.endsWith(".xml") || 72 filename.endsWith(".xsl")) { 73 result = ACTION_IGNORE; 74 Logger.getLogger(getClass()).debug("Dispatching \"" + filename + "\": ACTION_IGNORE"); 75 } else { 76 result = ACTION_ZIP; 77 Logger.getLogger(getClass()).debug("Dispatching \"" + filename + "\": ACTION_ZIP"); 78 } 79 80 return result; 81 } 82 } 83 | Popular Tags |