KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jac > util > SpeedLog


1 /*
2   Copyright (C) 2004 Laurent Martelli <laurent@aopsys.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU Lesser General Public License as
6   published by the Free Software Foundation; either version 2 of the
7   License, or (at your option) any later version.
8
9   This program is distributed in the hope that it will be useful,
10   but WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12   GNU Lesser General Public License for more details.
13
14   You should have received a copy of the GNU Lesser General Public
15   License along with this program; if not, write to the Free Software
16   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17   USA */

18
19 package org.objectweb.jac.util;
20
21 import java.io.FilenameFilter JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.List JavaDoc;
25 import net.sf.just4log.JustLog;
26 import org.apache.log4j.BasicConfigurator;
27 import org.apache.log4j.Level;
28 import org.apache.log4j.Logger;
29 import org.objectweb.jac.util.File;
30 import org.objectweb.jac.util.Files;
31
32 /**
33  * Command line tool to perform log optimization with just4log
34  */

35 public class SpeedLog {
36     /**
37      * Usage: <code>java org.objectweb.jac.util.SpeedLog <dir> [<dir> ...]</code>
38      *
39      * <p>Recursively optimize the loger invocations of in all .class files.</p>
40      */

41     public static void main(String JavaDoc[] args) throws IOException JavaDoc {
42         BasicConfigurator.configure();
43         Logger.getRootLogger().setLevel(Level.WARN);
44
45         for (int i=0; i<args.length; i++)
46         {
47             File file = new File(args[i]);
48             if (file.isDirectory()) {
49                  List JavaDoc classes =
50                     file.listFilesRecursively(
51                         Files.extensionFilenamFilter(".class"));
52                 Iterator JavaDoc it = classes.iterator();
53                 while(it.hasNext()) {
54                     File classFile = (File)it.next();
55                     try {
56                         JustLog.speedup(classFile,classFile);
57                     } catch(Exception JavaDoc e) {
58                         System.out.println("Failed to speed "+classFile);
59                     }
60                 }
61             } else {
62                 try {
63                     JustLog.speedup(file,file);
64                 } catch(Exception JavaDoc e) {
65                     System.out.println("Failed to speed "+file);
66                 }
67             }
68         }
69     }
70 }
71
Popular Tags