You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2011/11/12 11:12:57 UTC

svn commit: r1201239 - /tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java

Author: kkolinko
Date: Sat Nov 12 10:12:57 2011
New Revision: 1201239

URL: http://svn.apache.org/viewvc?rev=1201239&view=rev
Log:
Remove unused deprecated methods from IntrospectionUtils

Modified:
    tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java

Modified: tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java?rev=1201239&r1=1201238&r2=1201239&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java Sat Nov 12 10:12:57 2011
@@ -18,17 +18,12 @@
 package org.apache.tomcat.util;
 
 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;
 
 /**
  * Utils for introspection and reflection
@@ -39,98 +34,6 @@ public final class IntrospectionUtils {
     private static final org.apache.juli.logging.Log log=
         org.apache.juli.logging.LogFactory.getLog( IntrospectionUtils.class );
 
-    /**
-     * 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();
-        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 )
-     * @deprecated Not used
-     */
-    @Deprecated
-    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 )
-     * @deprecated Not used
-     */
-    @Deprecated
-    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.
-     * @deprecated Not used
-     */
-    @Deprecated
-    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);
@@ -226,47 +129,6 @@ 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);
-            for (int i = 0; i < cp.length; i++) {
-                log.debug(cp[i].getFile());
-            }
-        }
-    }
-
-    /**
-     * @deprecated Used only by deprecated method
-     */
-    @Deprecated
-    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.
-     * @deprecated Not used
-     */
-    @Deprecated
-    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).
@@ -458,29 +320,6 @@ public final class IntrospectionUtils {
     }
 
     /**
-     * @deprecated Not used
-     */
-    @Deprecated
-    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,
@@ -546,195 +385,6 @@ 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;
-        }
-        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.
-     * @deprecated Is used only by deprecated method
-     */
-    @Deprecated
-    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();
-        }
-    }
-
-    /**
-     * @deprecated Is used only by deprecated method
-     */
-    @Deprecated
-    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
-     * @deprecated Is used only by deprecated method
-     */
-    @Deprecated
-    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
-     * @deprecated Is used only by deprecated method
-     */
-    @Deprecated
-    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 ;)
-     * @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");
-        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
-     * @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++) {
-            urls[i] = v.elementAt(i);
-        }
-        return urls;
-    }
-
-    /**
-     * 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 {
-        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 --------------------
     public static void clear() {
         objectMethods.clear();
@@ -783,47 +433,6 @@ public final class IntrospectionUtils {
         return null;
     }
 
-    /** 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());
-            for (int i = 0; i < myMethods.length; i++) {
-                if (methodN.equals(myMethods[i].getName())) {
-                    // check if it's overridden
-                    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;
-    }
-
-    /**
-     * @deprecated Not used
-     */
-    @Deprecated
-    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 callMethod1(Object target, String methodN,
             Object param1, String typeParam1, ClassLoader cl) throws Exception {
         if (target == null || param1 == null) {
@@ -952,14 +561,4 @@ public final class IntrospectionUtils {
 
     }
 
-    /**
-     * @deprecated Is used only by deprecated method
-     */
-    @Deprecated
-    public static interface AttributeHolder {
-
-        public void setAttribute(String key, Object o);
-
-    }
-
 }



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