47 * - Rules are checked in sequence, in the same order as in the file, until a 48 * match is found or the end of the list is reached. 49 * 50 * Examples of rules: 51 * www\.sun\.com , sun%d.log 52 * yahoo\.com\/.*asf , yahoo.log 53 * 54 * @author jccollet 55 */ 56 public class HttpCapture { 57 private File file = null; 58 private boolean incoming = true; 59 private BufferedWriter out = null; 60 private static boolean initialized = false; 61 private static volatile ArrayList<Pattern> patterns = null; 62 private static volatile ArrayList<String> capFiles = null; 63 64 private static synchronized void init() { 65 initialized = true; 66 String rulesFile = java.security.AccessController.doPrivileged( 67 new java.security.PrivilegedAction<String>() { 68 public String run() { 69 return NetProperties.get("sun.net.http.captureRules"); 70 } 71 }); 72 if (rulesFile != null && !rulesFile.isEmpty()) { 73 BufferedReader in; 74 try { 75 in = new BufferedReader(new FileReader(rulesFile)); 76 } catch (FileNotFoundException ex) { 77 return; 78 } 79 try { 80 String line = in.readLine(); 81 while (line != null) { 82 line = line.trim(); 83 if (!line.startsWith("#")) { 84 // skip line if it's a comment 85 String[] s = line.split(","); 86 if (s.length == 2) { 87 if (patterns == null) { 88 patterns = new ArrayList<Pattern>(); 89 capFiles = new ArrayList<String>(); 90 } 91 patterns.add(Pattern.compile(s[0].trim())); 92 capFiles.add(s[1].trim()); 93 } 94 } 95 line = in.readLine(); 96 } 97 } catch (IOException ioe) { 98 99 } finally { 100 try { 101 in.close(); 102 } catch (IOException ex) { 103 } 104 } 105 } 106 } 107 108 private static synchronized boolean isInitialized() { 109 return initialized; | 47 * - Rules are checked in sequence, in the same order as in the file, until a 48 * match is found or the end of the list is reached. 49 * 50 * Examples of rules: 51 * www\.sun\.com , sun%d.log 52 * yahoo\.com\/.*asf , yahoo.log 53 * 54 * @author jccollet 55 */ 56 public class HttpCapture { 57 private File file = null; 58 private boolean incoming = true; 59 private BufferedWriter out = null; 60 private static boolean initialized = false; 61 private static volatile ArrayList<Pattern> patterns = null; 62 private static volatile ArrayList<String> capFiles = null; 63 64 private static synchronized void init() { 65 initialized = true; 66 String rulesFile = java.security.AccessController.doPrivileged( 67 new java.security.PrivilegedAction<>() { 68 public String run() { 69 return NetProperties.get("sun.net.http.captureRules"); 70 } 71 }); 72 if (rulesFile != null && !rulesFile.isEmpty()) { 73 BufferedReader in; 74 try { 75 in = new BufferedReader(new FileReader(rulesFile)); 76 } catch (FileNotFoundException ex) { 77 return; 78 } 79 try { 80 String line = in.readLine(); 81 while (line != null) { 82 line = line.trim(); 83 if (!line.startsWith("#")) { 84 // skip line if it's a comment 85 String[] s = line.split(","); 86 if (s.length == 2) { 87 if (patterns == null) { 88 patterns = new ArrayList<>(); 89 capFiles = new ArrayList<>(); 90 } 91 patterns.add(Pattern.compile(s[0].trim())); 92 capFiles.add(s[1].trim()); 93 } 94 } 95 line = in.readLine(); 96 } 97 } catch (IOException ioe) { 98 99 } finally { 100 try { 101 in.close(); 102 } catch (IOException ex) { 103 } 104 } 105 } 106 } 107 108 private static synchronized boolean isInitialized() { 109 return initialized; |