tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kkoli...@apache.org
Subject svn commit: r1201242 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/tomcat/util/IntrospectionUtils.java test/org/apache/catalina/tribes/demos/IntrospectionUtils.java webapps/docs/changelog.xml
Date Sat, 12 Nov 2011 10:18:08 GMT
Author: kkolinko
Date: Sat Nov 12 10:18:08 2011
New Revision: 1201242

URL: http://svn.apache.org/viewvc?rev=1201242&view=rev
Log:
Merged revisions 1201235-1201237 from tomcat/trunk:
Deprecate unused methods in IntrospectionUtils classes
Remove unused code from "tribes/demos" copy of IntrospectionUtils

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
    tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Nov 12 10:18:08 2011
@@ -1 +1 @@
-/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096
 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175798,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254,1186257,1186377-1186379,1186479-1186480,1186712,1186743,1186750,1186763,1186890-1186892,1186894,1186949,1187018,1187027-1187028,1187381,1187
 753,1187755,1187775,1187801,1187806,1187809,1187827,1188301,1188303-1188305,1188399,1188822,1188930-1188931,1189116,1189129,1189183,1189240,1189256,1189386,1189413-1189414,1189477,1189685,1189805,1189857,1189864,1189882,1190034,1190185,1190279,1190339,1190371,1190388-1190389,1190474,1190481,1194915,1195222-1195223,1195531,1195899,1195905,1195943,1195949,1195953,1195955,1195965,1195968,1196175,1196212,1196223,1196304-1196305,1196735,1196825,1196827,1197158,1197261,1197263,1197299-1197300,1197305,1197339-1197340,1197343,1197382,1197386-1197387,1197480,1197578,1198497,1198528,1198552,1198602,1198604,1198607,1198622,1198640,1198696,1198707,1199418,1199432,1199436,1199513,1199529,1199980,1199996,1200056,1200089,1200106-1200107,1200263,1200316,1200320,1200398-1200399,1200445-1200446,1200555,1200627,1200696,1200725,1200937,1200941,1201069,1201087,1201180
+/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096
 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175798,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254,1186257,1186377-1186379,1186479-1186480,1186712,1186743,1186750,1186763,1186890-1186892,1186894,1186949,1187018,1187027-1187028,1187381,1187
 753,1187755,1187775,1187801,1187806,1187809,1187827,1188301,1188303-1188305,1188399,1188822,1188930-1188931,1189116,1189129,1189183,1189240,1189256,1189386,1189413-1189414,1189477,1189685,1189805,1189857,1189864,1189882,1190034,1190185,1190279,1190339,1190371,1190388-1190389,1190474,1190481,1194915,1195222-1195223,1195531,1195899,1195905,1195943,1195949,1195953,1195955,1195965,1195968,1196175,1196212,1196223,1196304-1196305,1196735,1196825,1196827,1197158,1197261,1197263,1197299-1197300,1197305,1197339-1197340,1197343,1197382,1197386-1197387,1197480,1197578,1198497,1198528,1198552,1198602,1198604,1198607,1198622,1198640,1198696,1198707,1199418,1199432,1199436,1199513,1199529,1199980,1199996,1200056,1200089,1200106-1200107,1200263,1200316,1200320,1200398-1200399,1200445-1200446,1200555,1200627,1200696,1200725,1200937,1200941,1201069,1201087,1201180,1201235-1201237

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java?rev=1201242&r1=1201241&r2=1201242&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java Sat Nov 12 10:18:08
2011
@@ -30,8 +30,6 @@ import java.util.Hashtable;
 import java.util.StringTokenizer;
 import java.util.Vector;
 
-// Depends: JDK1.1
-
 /**
  * Utils for introspection and reflection
  */
@@ -43,7 +41,9 @@ public final class IntrospectionUtils {
 
     /**
      * Call execute() - any ant-like task should work
+     * @deprecated Not used
      */
+    @Deprecated
     public static void execute(Object proxy, String method) throws Exception {
         Method executeM = null;
         Class<?> c = proxy.getClass();
@@ -58,7 +58,9 @@ public final class IntrospectionUtils {
 
     /**
      * Call void setAttribute( String ,Object )
+     * @deprecated Not used
      */
+    @Deprecated
     public static void setAttribute(Object proxy, String n, Object v)
             throws Exception {
         if (proxy instanceof AttributeHolder) {
@@ -85,7 +87,9 @@ public final class IntrospectionUtils {
 
     /**
      * Call void getAttribute( String )
+     * @deprecated Not used
      */
+    @Deprecated
     public static Object getAttribute(Object proxy, String n) throws Exception {
         Method executeM = null;
         Class<?> c = proxy.getClass();
@@ -102,7 +106,9 @@ public final class IntrospectionUtils {
 
     /**
      * Construct a URLClassLoader. Will compile and work in JDK1.1 too.
+     * @deprecated Not used
      */
+    @Deprecated
     public static ClassLoader getURLClassLoader(URL urls[], ClassLoader parent) {
         try {
             Class<?> urlCL = Class.forName("java.net.URLClassLoader");
@@ -221,7 +227,9 @@ public final class IntrospectionUtils {
 
     /**
      * Debug method, display the classpath
+     * @deprecated Not used
      */
+    @Deprecated
     public static void displayClassPath(String msg, URL[] cp) {
         if (log.isDebugEnabled()) {
             log.debug(msg);
@@ -231,6 +239,10 @@ public final class IntrospectionUtils {
         }
     }
 
+    /**
+     * @deprecated Used only by deprecated method
+     */
+    @Deprecated
     public static final String PATH_SEPARATOR = System.getProperty("path.separator");
 
     /**
@@ -238,7 +250,9 @@ public final class IntrospectionUtils {
      * property. This System property lists the classpath entries common to web
      * applications. This System property is currently used by Jasper when its
      * JSP servlet compiles the Java file for a JSP.
+     * @deprecated Not used
      */
+    @Deprecated
     public static String classPathAdd(URL urls[], String cp) {
         if (urls == null)
             return cp;
@@ -444,7 +458,9 @@ public final class IntrospectionUtils {
     }
 
     /**
+     * @deprecated Not used
      */
+    @Deprecated
     public static void setProperty(Object o, String name) {
         String setter = "set" + capitalize(name);
         try {
@@ -530,6 +546,10 @@ public final class IntrospectionUtils {
         return new String(chars);
     }
 
+    /**
+     * @deprecated Not used
+     */
+    @Deprecated
     public static String unCapitalize(String name) {
         if (name == null || name.length() == 0) {
             return name;
@@ -544,7 +564,9 @@ public final class IntrospectionUtils {
     /**
      * Add all the jar files in a dir to the classpath, represented as a Vector
      * of URLs.
+     * @deprecated Is used only by deprecated method
      */
+    @Deprecated
     public static void addToClassPath(Vector<URL> cpV, String dir) {
         try {
             String cpComp[] = getFilesByExt(dir, ".jar");
@@ -561,6 +583,10 @@ public final class IntrospectionUtils {
         }
     }
 
+    /**
+     * @deprecated Is used only by deprecated method
+     */
+    @Deprecated
     public static void addToolsJar(Vector<URL> v) {
         try {
             // Add tools.jar in any case
@@ -588,7 +614,9 @@ public final class IntrospectionUtils {
 
     /**
      * Return all files with a given extension in a dir
+     * @deprecated Is used only by deprecated method
      */
+    @Deprecated
     public static String[] getFilesByExt(String ld, String ext) {
         File dir = new File(ld);
         String[] names = null;
@@ -609,7 +637,9 @@ public final class IntrospectionUtils {
 
     /**
      * Construct a file url from a file, using a base dir
+     * @deprecated Is used only by deprecated method
      */
+    @Deprecated
     public static URL getURL(String base, String file) {
         try {
             File baseF = new File(base);
@@ -637,7 +667,9 @@ public final class IntrospectionUtils {
      *   separated by path.separator delimiters.
      * @throws IOException If an I/O error occurs
      * @throws MalformedURLException Doh ;)
+     * @deprecated Is used only by deprecated method
      */
+    @Deprecated
     public static void addJarsFromClassPath(Vector<URL> jars, String cp)
             throws IOException, MalformedURLException {
         String sep = System.getProperty("path.separator");
@@ -660,7 +692,9 @@ public final class IntrospectionUtils {
 
     /**
      * Return a URL[] that can be used to construct a class loader
+     * @deprecated Is used only by deprecated method
      */
+    @Deprecated
     public static URL[] getClassPath(Vector<URL> v) {
         URL[] urls = new URL[v.size()];
         for (int i = 0; i < v.size(); i++) {
@@ -672,7 +706,9 @@ public final class IntrospectionUtils {
     /**
      * Construct a URL classpath from files in a directory, a cpath property,
      * and tools.jar.
+     * @deprecated Not used
      */
+    @Deprecated
     public static URL[] getClassPath(String dir, String cpath,
             String cpathProp, boolean addTools) throws IOException,
             MalformedURLException {
@@ -749,7 +785,9 @@ public final class IntrospectionUtils {
 
     /** Test if the object implements a particular
      *  method
+     * @deprecated Not used
      */
+    @Deprecated
     public static boolean hasHook(Object obj, String methodN) {
         try {
             Method myMethods[] = findMethods(obj.getClass());
@@ -775,6 +813,10 @@ public final class IntrospectionUtils {
         return false;
     }
 
+    /**
+     * @deprecated Not used
+     */
+    @Deprecated
     public static void callMain(Class<?> c, String args[]) throws Exception {
         Class<?> p[] = new Class[1];
         p[0] = args.getClass();
@@ -806,6 +848,10 @@ public final class IntrospectionUtils {
         return m.invoke(target, new Object[] { param1 });
     }
 
+    /**
+     * @deprecated Not used, though compliments callMethod1 and callMethodN here
+     */
+    @Deprecated
     public static Object callMethod0(Object target, String methodN)
             throws Exception {
         if (target == null) {
@@ -826,7 +872,11 @@ public final class IntrospectionUtils {
         return m.invoke(target, emptyArray);
     }
 
-    static Object[] emptyArray = new Object[] {};
+    /**
+     * @deprecated Used only by deprecated method
+     */
+    @Deprecated
+    private static final Object[] emptyArray = new Object[] {};
 
     public static Object callMethodN(Object target, String methodN,
             Object params[], Class<?> typeParams[]) throws Exception {
@@ -902,6 +952,10 @@ public final class IntrospectionUtils {
 
     }
 
+    /**
+     * @deprecated Is used only by deprecated method
+     */
+    @Deprecated
     public static interface AttributeHolder {
 
         public void setAttribute(String key, Object o);

Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java?rev=1201242&r1=1201241&r2=1201242&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java Sat
Nov 12 10:18:08 2011
@@ -17,20 +17,11 @@
 
 package org.apache.catalina.tribes.demos;
 
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.InetAddress;
-import java.net.MalformedURLException;
-import java.net.URL;
 import java.net.UnknownHostException;
 import java.util.Hashtable;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-// Depends: JDK1.1
 
 /**
  * Utils for introspection and reflection
@@ -42,218 +33,6 @@ public final class IntrospectionUtils {
         org.apache.juli.logging.LogFactory.getLog( IntrospectionUtils.class );
 
     /**
-     * Call execute() - any ant-like task should work
-     */
-    public static void execute(Object proxy, String method) throws Exception {
-        Method executeM = null;
-        Class<?> c = proxy.getClass();
-        Class<?> params[] = new Class[0];
-        //  params[0]=args.getClass();
-        executeM = findMethod(c, method, params);
-        if (executeM == null) {
-            throw new RuntimeException("No execute in " + proxy.getClass());
-        }
-        executeM.invoke(proxy, (Object[]) null);//new Object[] { args });
-    }
-
-    /**
-     * Call void setAttribute( String ,Object )
-     */
-    public static void setAttribute(Object proxy, String n, Object v)
-            throws Exception {
-        if (proxy instanceof AttributeHolder) {
-            ((AttributeHolder) proxy).setAttribute(n, v);
-            return;
-        }
-
-        Method executeM = null;
-        Class<?> c = proxy.getClass();
-        Class<?> params[] = new Class[2];
-        params[0] = String.class;
-        params[1] = Object.class;
-        executeM = findMethod(c, "setAttribute", params);
-        if (executeM == null) {
-            if (log.isDebugEnabled())
-                log.debug("No setAttribute in " + proxy.getClass());
-            return;
-        }
-        if (log.isDebugEnabled())
-            log.debug("Setting " + n + "=" + v + "  in " + proxy);
-        executeM.invoke(proxy, new Object[] { n, v });
-        return;
-    }
-
-    /**
-     * Call void getAttribute( String )
-     */
-    public static Object getAttribute(Object proxy, String n) throws Exception {
-        Method executeM = null;
-        Class<?> c = proxy.getClass();
-        Class<?> params[] = new Class[1];
-        params[0] = String.class;
-        executeM = findMethod(c, "getAttribute", params);
-        if (executeM == null) {
-            if (log.isDebugEnabled())
-                log.debug("No getAttribute in " + proxy.getClass());
-            return null;
-        }
-        return executeM.invoke(proxy, new Object[] { n });
-    }
-
-    /**
-     * Construct a URLClassLoader. Will compile and work in JDK1.1 too.
-     */
-    public static ClassLoader getURLClassLoader(URL urls[], ClassLoader parent) {
-        try {
-            Class<?> urlCL = Class.forName("java.net.URLClassLoader");
-            Class<?> paramT[] = new Class[2];
-            paramT[0] = urls.getClass();
-            paramT[1] = ClassLoader.class;
-            Method m = findMethod(urlCL, "newInstance", paramT);
-            if (m == null)
-                return null;
-
-            ClassLoader cl = (ClassLoader) m.invoke(urlCL, new Object[] { urls,
-                    parent });
-            return cl;
-        } catch (ClassNotFoundException ex) {
-            // jdk1.1
-            return null;
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            return null;
-        }
-    }
-
-    public static String guessInstall(String installSysProp,
-            String homeSysProp, String jarName) {
-        return guessInstall(installSysProp, homeSysProp, jarName, null);
-    }
-
-    /**
-     * Guess a product install/home by analyzing the class path. It works for
-     * product using the pattern: lib/executable.jar or if executable.jar is
-     * included in classpath by a shell script. ( java -jar also works )
-     *
-     * Insures both "install" and "home" System properties are set. If either or
-     * both System properties are unset, "install" and "home" will be set to the
-     * same value. This value will be the other System property that is set, or
-     * the guessed value if neither is set.
-     */
-    public static String guessInstall(String installSysProp,
-            String homeSysProp, String jarName, String classFile) {
-        String install = null;
-        String home = null;
-
-        if (installSysProp != null)
-            install = System.getProperty(installSysProp);
-
-        if (homeSysProp != null)
-            home = System.getProperty(homeSysProp);
-
-        if (install != null) {
-            if (home == null)
-                System.getProperties().put(homeSysProp, install);
-            return install;
-        }
-
-        // Find the directory where jarName.jar is located
-
-        String cpath = System.getProperty("java.class.path");
-        String pathSep = System.getProperty("path.separator");
-        StringTokenizer st = new StringTokenizer(cpath, pathSep);
-        while (st.hasMoreTokens()) {
-            String path = st.nextToken();
-            //      log( "path " + path );
-            if (path.endsWith(jarName)) {
-                home = path.substring(0, path.length() - jarName.length());
-                try {
-                    if ("".equals(home)) {
-                        home = new File("./").getCanonicalPath();
-                    } else if (home.endsWith(File.separator)) {
-                        home = home.substring(0, home.length() - 1);
-                    }
-                    File f = new File(home);
-                    String parentDir = f.getParent();
-                    if (parentDir == null)
-                        parentDir = home; // unix style
-                    File f1 = new File(parentDir);
-                    install = f1.getCanonicalPath();
-                    if (installSysProp != null)
-                        System.getProperties().put(installSysProp, install);
-                    if (home == null && homeSysProp != null)
-                        System.getProperties().put(homeSysProp, install);
-                    return install;
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                }
-            } else {
-                String fname = path + (path.endsWith("/") ? "" : "/")
-                        + classFile;
-                if (new File(fname).exists()) {
-                    try {
-                        File f = new File(path);
-                        String parentDir = f.getParent();
-                        if (parentDir == null)
-                            parentDir = path; // unix style
-                        File f1 = new File(parentDir);
-                        install = f1.getCanonicalPath();
-                        if (installSysProp != null)
-                            System.getProperties().put(installSysProp, install);
-                        if (home == null && homeSysProp != null)
-                            System.getProperties().put(homeSysProp, install);
-                        return install;
-                    } catch (Exception ex) {
-                        ex.printStackTrace();
-                    }
-                }
-            }
-        }
-
-        // if install directory can't be found, use home as the default
-        if (home != null) {
-            System.getProperties().put(installSysProp, home);
-            return home;
-        }
-
-        return null;
-    }
-
-    /**
-     * Debug method, display the classpath
-     */
-    public static void displayClassPath(String msg, URL[] cp) {
-        if (log.isDebugEnabled()) {
-            log.debug(msg);
-            for (int i = 0; i < cp.length; i++) {
-                log.debug(cp[i].getFile());
-            }
-        }
-    }
-
-    public static final String PATH_SEPARATOR =
-        System.getProperty("path.separator");
-
-    /**
-     * Adds classpath entries from a vector of URL's to the "tc_path_add" System
-     * property. This System property lists the classpath entries common to web
-     * applications. This System property is currently used by Jasper when its
-     * JSP servlet compiles the Java file for a JSP.
-     */
-    public static String classPathAdd(URL urls[], String cp) {
-        if (urls == null)
-            return cp;
-
-        for (int i = 0; i < urls.length; i++) {
-            if (cp != null)
-                cp += PATH_SEPARATOR + urls[i].getFile();
-            else
-                cp = urls[i].getFile();
-        }
-        return cp;
-    }
-
-    /**
      * Find a method with the right name If found, call the method ( if param is
      * int or boolean we'll convert value to the right type before) - that means
      * you can have setDebug(1).
@@ -392,129 +171,6 @@ public final class IntrospectionUtils {
         return false;
     }
 
-    public static Object getProperty(Object o, String name) {
-        String getter = "get" + capitalize(name);
-        String isGetter = "is" + capitalize(name);
-
-        try {
-            Method methods[] = findMethods(o.getClass());
-            Method getPropertyMethod = null;
-
-            // First, the ideal case - a getFoo() method
-            for (int i = 0; i < methods.length; i++) {
-                Class<?> paramT[] = methods[i].getParameterTypes();
-                if (getter.equals(methods[i].getName()) && paramT.length == 0) {
-                    return methods[i].invoke(o, (Object[]) null);
-                }
-                if (isGetter.equals(methods[i].getName()) && paramT.length == 0)
{
-                    return methods[i].invoke(o, (Object[]) null);
-                }
-
-                if ("getProperty".equals(methods[i].getName())) {
-                    getPropertyMethod = methods[i];
-                }
-            }
-
-            // Ok, no setXXX found, try a getProperty("name")
-            if (getPropertyMethod != null) {
-                Object params[] = new Object[1];
-                params[0] = name;
-                return getPropertyMethod.invoke(o, params);
-            }
-
-        } catch (IllegalArgumentException ex2) {
-            log.warn("IAE " + o + " " + name, ex2);
-        } catch (SecurityException ex1) {
-            if (log.isDebugEnabled())
-                log.debug("IntrospectionUtils: SecurityException for " +
-                        o.getClass() + " " + name + ")", ex1);
-        } catch (IllegalAccessException iae) {
-            if (log.isDebugEnabled())
-                log.debug("IntrospectionUtils: IllegalAccessException for " +
-                        o.getClass() + " " + name + ")", iae);
-        } catch (InvocationTargetException ie) {
-            if (log.isDebugEnabled())
-                log.debug("IntrospectionUtils: InvocationTargetException for " +
-                        o.getClass() + " " + name + ")");
-        }
-        return null;
-    }
-
-    /**
-     */
-    public static void setProperty(Object o, String name) {
-        String setter = "set" + capitalize(name);
-        try {
-            Method methods[] = findMethods(o.getClass());
-            // find setFoo() method
-            for (int i = 0; i < methods.length; i++) {
-                Class<?> paramT[] = methods[i].getParameterTypes();
-                if (setter.equals(methods[i].getName()) && paramT.length == 0) {
-                    methods[i].invoke(o, new Object[] {});
-                    return;
-                }
-            }
-        } catch (Exception ex1) {
-            if (log.isDebugEnabled())
-                log.debug("IntrospectionUtils: Exception for " +
-                        o.getClass() + " " + name, ex1);
-        }
-    }
-
-    /**
-     * Replace ${NAME} with the property value
-     */
-    public static String replaceProperties(String value,
-            Hashtable<Object,Object> staticProp, PropertySource dynamicProp[]) {
-        if (value.indexOf("$") < 0) {
-            return value;
-        }
-        StringBuilder sb = new StringBuilder();
-        int prev = 0;
-        // assert value!=nil
-        int pos;
-        while ((pos = value.indexOf("$", prev)) >= 0) {
-            if (pos > 0) {
-                sb.append(value.substring(prev, pos));
-            }
-            if (pos == (value.length() - 1)) {
-                sb.append('$');
-                prev = pos + 1;
-            } else if (value.charAt(pos + 1) != '{') {
-                sb.append('$');
-                prev = pos + 1; // XXX
-            } else {
-                int endName = value.indexOf('}', pos);
-                if (endName < 0) {
-                    sb.append(value.substring(pos));
-                    prev = value.length();
-                    continue;
-                }
-                String n = value.substring(pos + 2, endName);
-                String v = null;
-                if (staticProp != null) {
-                    v = (String) staticProp.get(n);
-                }
-                if (v == null && dynamicProp != null) {
-                    for (int i = 0; i < dynamicProp.length; i++) {
-                        v = dynamicProp[i].getProperty(n);
-                        if (v != null) {
-                            break;
-                        }
-                    }
-                }
-                if (v == null)
-                    v = "${" + n + "}";
-
-                sb.append(v);
-                prev = endName + 1;
-            }
-        }
-        if (prev < value.length())
-            sb.append(value.substring(prev));
-        return sb.toString();
-    }
-
     /**
      * Reverse of Introspector.decapitalize
      */
@@ -527,176 +183,11 @@ public final class IntrospectionUtils {
         return new String(chars);
     }
 
-    public static String unCapitalize(String name) {
-        if (name == null || name.length() == 0) {
-            return name;
-        }
-        char chars[] = name.toCharArray();
-        chars[0] = Character.toLowerCase(chars[0]);
-        return new String(chars);
-    }
-
-    // -------------------- Class path tools --------------------
-
-    /**
-     * Add all the jar files in a dir to the classpath, represented as a Vector
-     * of URLs.
-     */
-    public static void addToClassPath(Vector<URL> cpV, String dir) {
-        try {
-            String cpComp[] = getFilesByExt(dir, ".jar");
-            if (cpComp != null) {
-                int jarCount = cpComp.length;
-                for (int i = 0; i < jarCount; i++) {
-                    URL url = getURL(dir, cpComp[i]);
-                    if (url != null)
-                        cpV.addElement(url);
-                }
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-    }
-
-    public static void addToolsJar(Vector<URL> v) {
-        try {
-            // Add tools.jar in any case
-            File f = new File(System.getProperty("java.home")
-                    + "/../lib/tools.jar");
-
-            if (!f.exists()) {
-                // On some systems java.home gets set to the root of jdk.
-                // That's a bug, but we can work around and be nice.
-                f = new File(System.getProperty("java.home") + "/lib/tools.jar");
-                if (f.exists()) {
-                    if (log.isDebugEnabled())
-                        log.debug("Detected strange java.home value "
-                            + System.getProperty("java.home")
-                            + ", it should point to jre");
-                }
-            }
-            URL url = new URL("file", "", f.getAbsolutePath());
-
-            v.addElement(url);
-        } catch (MalformedURLException ex) {
-            ex.printStackTrace();
-        }
-    }
-
-    /**
-     * Return all files with a given extension in a dir
-     */
-    public static String[] getFilesByExt(String ld, String ext) {
-        File dir = new File(ld);
-        String[] names = null;
-        final String lext = ext;
-        if (dir.isDirectory()) {
-            names = dir.list(new FilenameFilter() {
-                @Override
-                public boolean accept(File d, String name) {
-                    if (name.endsWith(lext)) {
-                        return true;
-                    }
-                    return false;
-                }
-            });
-        }
-        return names;
-    }
-
-    /**
-     * Construct a file url from a file, using a base dir
-     */
-    public static URL getURL(String base, String file) {
-        try {
-            File baseF = new File(base);
-            File f = new File(baseF, file);
-            String path = f.getCanonicalPath();
-            if (f.isDirectory()) {
-                path += "/";
-            }
-            if (!f.exists())
-                return null;
-            return new URL("file", "", path);
-        } catch (Exception ex) {
-            ex.printStackTrace();
-            return null;
-        }
-    }
-
-    /**
-     * Add elements from the classpath <i>cp </i> to a Vector <i>jars </i>
as
-     * file URLs (We use Vector for JDK 1.1 compat).
-     * <p>
-     *
-     * @param jars The jar list
-     * @param cp a String classpath of directory or jar file elements
-     *   separated by path.separator delimiters.
-     * @throws IOException If an I/O error occurs
-     * @throws MalformedURLException Doh ;)
-     */
-    public static void addJarsFromClassPath(Vector<URL> jars, String cp)
-            throws IOException, MalformedURLException {
-        String sep = System.getProperty("path.separator");
-        StringTokenizer st;
-        if (cp != null) {
-            st = new StringTokenizer(cp, sep);
-            while (st.hasMoreTokens()) {
-                File f = new File(st.nextToken());
-                String path = f.getCanonicalPath();
-                if (f.isDirectory()) {
-                    path += "/";
-                }
-                URL url = new URL("file", "", path);
-                if (!jars.contains(url)) {
-                    jars.addElement(url);
-                }
-            }
-        }
-    }
-
-    /**
-     * Return a URL[] that can be used to construct a class loader
-     */
-    public static URL[] getClassPath(Vector<URL> v) {
-        URL[] urls = new URL[v.size()];
-        for (int i = 0; i < v.size(); i++) {
-            urls[i] = v.elementAt(i);
-        }
-        return urls;
-    }
-
+    // -------------------- other utils --------------------
     /**
-     * Construct a URL classpath from files in a directory, a cpath property,
-     * and tools.jar.
+     * @deprecated Not used, but code must be updated to call it
      */
-    public static URL[] getClassPath(String dir, String cpath,
-            String cpathProp, boolean addTools) throws IOException,
-            MalformedURLException {
-        Vector<URL> jarsV = new Vector<URL>();
-        if (dir != null) {
-            // Add dir/classes first, if it exists
-            URL url = getURL(dir, "classes");
-            if (url != null)
-                jarsV.addElement(url);
-            addToClassPath(jarsV, dir);
-        }
-
-        if (cpath != null)
-            addJarsFromClassPath(jarsV, cpath);
-
-        if (cpathProp != null) {
-            String cpath1 = System.getProperty(cpathProp);
-            addJarsFromClassPath(jarsV, cpath1);
-        }
-
-        if (addTools)
-            addToolsJar(jarsV);
-
-        return getClassPath(jarsV);
-    }
-
-    // -------------------- other utils --------------------
+    @Deprecated
     public static void clear() {
         objectMethods.clear();
     }
@@ -714,172 +205,4 @@ public final class IntrospectionUtils {
         return methods;
     }
 
-    @SuppressWarnings("null")
-    public static Method findMethod(Class<?> c, String name,
-            Class<?> params[]) {
-        Method methods[] = findMethods(c);
-        if (methods == null)
-            return null;
-        for (int i = 0; i < methods.length; i++) {
-            if (methods[i].getName().equals(name)) {
-                Class<?> methodParams[] = methods[i].getParameterTypes();
-                if (methodParams == null)
-                    if (params == null || params.length == 0)
-                        return methods[i];
-                if (params == null)
-                    if (methodParams == null || methodParams.length == 0)
-                        return methods[i];
-                if (params.length != methodParams.length)
-                    continue;
-                boolean found = true;
-                for (int j = 0; j < params.length; j++) {
-                    if (params[j] != methodParams[j]) {
-                        found = false;
-                        break;
-                    }
-                }
-                if (found)
-                    return methods[i];
-            }
-        }
-        return null;
-    }
-
-    /** Test if the object implements a particular
-     *  method
-     */
-    public static boolean hasHook(Object obj, String methodN) {
-        try {
-            Method myMethods[] = findMethods(obj.getClass());
-            for (int i = 0; i < myMethods.length; i++) {
-                if (methodN.equals(myMethods[i].getName())) {
-                    // check if it's overriden
-                    Class<?> declaring = myMethods[i].getDeclaringClass();
-                    Class<?> parentOfDeclaring = declaring.getSuperclass();
-                    // this works only if the base class doesn't extend
-                    // another class.
-
-                    // if the method is declared in a top level class
-                    // like BaseInterceptor parent is Object, otherwise
-                    // parent is BaseInterceptor or an intermediate class
-                    if (!"java.lang.Object".equals(parentOfDeclaring.getName())) {
-                        return true;
-                    }
-                }
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-        return false;
-    }
-
-    public static void callMain(Class<?> c, String args[]) throws Exception {
-        Class<?> p[] = new Class[1];
-        p[0] = args.getClass();
-        Method m = c.getMethod("main", p);
-        m.invoke(c, new Object[] { args });
-    }
-
-    public static Object callMethod0(Object target, String methodN)
-            throws Exception {
-        if (target == null) {
-            if (log.isDebugEnabled())
-                log.debug("IntrospectionUtils: Assert: Illegal params " +
-                        target);
-            return null;
-        }
-        if (log.isDebugEnabled())
-            log.debug("IntrospectionUtils: callMethod0 " +
-                    target.getClass().getName() + "." + methodN);
-
-        Class<?> params[] = new Class[0];
-        Method m = findMethod(target.getClass(), methodN, params);
-        if (m == null)
-            throw new NoSuchMethodException(target.getClass().getName() + " "
-                    + methodN);
-        return m.invoke(target, emptyArray);
-    }
-
-    static Object[] emptyArray = new Object[] {};
-
-    public static Object callMethodN(Object target, String methodN,
-            Object params[], Class<?> typeParams[]) throws Exception {
-        Method m = null;
-        m = findMethod(target.getClass(), methodN, typeParams);
-        if (m == null) {
-            if (log.isDebugEnabled())
-                log.debug("IntrospectionUtils: Can't find method " + methodN +
-                        " in " + target + " CLASS " + target.getClass());
-            return null;
-        }
-        Object o = m.invoke(target, params);
-
-        if (log.isDebugEnabled()) {
-            // debug
-            StringBuilder sb = new StringBuilder();
-            sb.append("" + target.getClass().getName() + "." + methodN + "( ");
-            for (int i = 0; i < params.length; i++) {
-                if (i > 0)
-                    sb.append(", ");
-                sb.append(params[i]);
-            }
-            sb.append(")");
-            log.debug("IntrospectionUtils:" + sb.toString());
-        }
-        return o;
-    }
-
-    public static Object convert(String object, Class<?> paramType) {
-        Object result = null;
-        if ("java.lang.String".equals(paramType.getName())) {
-            result = object;
-        } else if ("java.lang.Integer".equals(paramType.getName())
-                || "int".equals(paramType.getName())) {
-            try {
-                result = new Integer(object);
-            } catch (NumberFormatException ex) {
-            }
-            // Try a setFoo ( boolean )
-        } else if ("java.lang.Boolean".equals(paramType.getName())
-                || "boolean".equals(paramType.getName())) {
-            result = Boolean.valueOf(object);
-
-            // Try a setFoo ( InetAddress )
-        } else if ("java.net.InetAddress".equals(paramType
-                .getName())) {
-            try {
-                result = InetAddress.getByName(object);
-            } catch (UnknownHostException exc) {
-                if (log.isDebugEnabled())
-                    log.debug("IntrospectionUtils: Unable to resolve host name:" +
-                            object);
-            }
-
-            // Unknown type
-        } else {
-            if (log.isDebugEnabled())
-                log.debug("IntrospectionUtils: Unknown type " +
-                        paramType.getName());
-        }
-        if (result == null) {
-            throw new IllegalArgumentException("Can't convert argument: " + object);
-        }
-        return result;
-    }
-
-    // -------------------- Get property --------------------
-    // This provides a layer of abstraction
-
-    public static interface PropertySource {
-
-        public String getProperty(String key);
-
-    }
-
-    public static interface AttributeHolder {
-
-        public void setAttribute(String key, Object o);
-
-    }
-
 }

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1201242&r1=1201241&r2=1201242&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Sat Nov 12 10:18:08 2011
@@ -204,6 +204,10 @@
         Improve special attributes handling in Request object by using hash
         table lookup instead of series of string comparisons. (kkolinko)
       </update>
+      <scode>
+        Deprecate unused methods in <code>IntrospectionUtils</code> class.
+        (kkolinko)
+      </scode>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message