org.apache.tomcat.util

Class IntrospectionUtils


public final class IntrospectionUtils
extends java.lang.Object

Utils for introspection and reflection

Nested Class Summary

static interface
IntrospectionUtils.AttributeHolder
static interface
IntrospectionUtils.PropertySource

Field Summary

static String
PATH_SEPARATOR

Method Summary

static void
addJarsFromClassPath(Vector jars, String cp)
add elements from the classpath cp to a Vector jars as file URLs (We use Vector for JDK 1.1 compat).
static void
addToClassPath(Vector cpV, String dir)
Add all the jar files in a dir to the classpath, represented as a Vector of URLs.
static void
addToolsJar(Vector v)
static void
callMain(Class c, args[] )
static Object
callMethod0(Object target, String methodN)
static Object
callMethod1(Object target, String methodN, Object param1, String typeParam1, ClassLoader cl)
static Object
callMethodN(Object target, String methodN, params[] , typeParams[] )
static String
capitalize(String name)
Reverse of Introspector.decapitalize
static String
classPathAdd(urls[] , String cp)
Adds classpath entries from a vector of URL's to the "tc_path_add" System property.
static void
displayClassPath(String msg, URL[] cp)
Debug method, display the classpath
static void
execute(Object proxy, String method)
Call execute() - any ant-like task should work
static String[]
findBooleanSetters(Class c)
static Method
findMethod(Class c, String name, params[] )
static Method[]
findMethods(Class c)
static String[]
findVoidSetters(Class c)
static Object
getAttribute(Object proxy, String n)
Call void getAttribute( String )
static URL[]
getClassPath(String dir, String cpath, String cpathProp, boolean addTools)
Construct a URL classpath from files in a directory, a cpath property, and tools.jar.
static URL[]
getClassPath(Vector v)
Return a URL[] that can be used to construct a class loader
static String[]
getFilesByExt(String ld, String ext)
Return all files with a given extension in a dir
static Object
getProperty(Object o, String name)
static URL
getURL(String base, String file)
Construct a file url from a file, using a base dir
static ClassLoader
getURLClassLoader(urls[] , ClassLoader parent)
Construct a URLClassLoader.
static String
guessInstall(String installSysProp, String homeSysProp, String jarName)
static String
guessInstall(String installSysProp, String homeSysProp, String jarName, String classFile)
Guess a product install/home by analyzing the class path.
static boolean
hasHook(Object obj, String methodN)
Test if the object implements a particular method
static boolean
processArgs(Object proxy, args[] )
static boolean
processArgs(Object proxy, args[] , args0[] , args1[] , Hashtable aliases)
static String
replaceProperties(String value, Hashtable staticProp, dynamicProp[] )
Replace ${NAME} with the property value
static String
replaceProperties(String value, Object getter)
Replace ${NAME} with the property value
static void
setAttribute(Object proxy, String n, Object v)
Call void setAttribute( String ,Object )
static void
setProperty(Object o, String name)
static void
setProperty(Object o, String name, String value)
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).
static String
unCapitalize(String name)

Field Details

PATH_SEPARATOR

public static String PATH_SEPARATOR

Method Details

addJarsFromClassPath

public static void addJarsFromClassPath(Vector jars,
                                        String cp)
            throws IOException,
                   MalformedURLException
add elements from the classpath cp to a Vector jars as file URLs (We use Vector for JDK 1.1 compat).

Parameters:


addToClassPath

public static void addToClassPath(Vector cpV,
                                  String dir)
Add all the jar files in a dir to the classpath, represented as a Vector of URLs.


addToolsJar

public static void addToolsJar(Vector v)


callMain

public static void callMain(Class c,
                            args[] )
            throws Exception


callMethod0

public static Object callMethod0(Object target,
                                 String methodN)
            throws Exception


callMethod1

public static Object callMethod1(Object target,
                                 String methodN,
                                 Object param1,
                                 String typeParam1,
                                 ClassLoader cl)
            throws Exception


callMethodN

public static Object callMethodN(Object target,
                                 String methodN,
                                 params[] ,
                                 typeParams[] )
            throws Exception


capitalize

public static String capitalize(String name)
Reverse of Introspector.decapitalize


classPathAdd

public static String classPathAdd(urls[] ,
                                  String cp)
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.


displayClassPath

public static void displayClassPath(String msg,
                                    URL[] cp)
Debug method, display the classpath


execute

public static void execute(Object proxy,
                           String method)
            throws Exception
Call execute() - any ant-like task should work


findBooleanSetters

public static String[] findBooleanSetters(Class c)


findMethod

public static Method findMethod(Class c,
                                String name,
                                params[] )


findMethods

public static Method[] findMethods(Class c)


findVoidSetters

public static String[] findVoidSetters(Class c)


getAttribute

public static Object getAttribute(Object proxy,
                                  String n)
            throws Exception
Call void getAttribute( String )


getClassPath

public static URL[] getClassPath(String dir,
                                 String cpath,
                                 String cpathProp,
                                 boolean addTools)
            throws IOException,
                   MalformedURLException
Construct a URL classpath from files in a directory, a cpath property, and tools.jar.


getClassPath

public static URL[] getClassPath(Vector v)
Return a URL[] that can be used to construct a class loader


getFilesByExt

public static String[] getFilesByExt(String ld,
                                     String ext)
Return all files with a given extension in a dir


getProperty

public static Object getProperty(Object o,
                                 String name)


getURL

public static URL getURL(String base,
                         String file)
Construct a file url from a file, using a base dir


getURLClassLoader

public static ClassLoader getURLClassLoader(urls[] ,
                                            ClassLoader parent)
Construct a URLClassLoader. Will compile and work in JDK1.1 too.


guessInstall

public static String guessInstall(String installSysProp,
                                  String homeSysProp,
                                  String jarName)


guessInstall

public static String guessInstall(String installSysProp,
                                  String homeSysProp,
                                  String jarName,
                                  String classFile)
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.


hasHook

public static boolean hasHook(Object obj,
                              String methodN)
Test if the object implements a particular method


processArgs

public static boolean processArgs(Object proxy,
                                  args[] )
            throws Exception


processArgs

public static boolean processArgs(Object proxy,
                                  args[] ,
                                  args0[] ,
                                  args1[] ,
                                  Hashtable aliases)
            throws Exception


replaceProperties

public static String replaceProperties(String value,
                                       Hashtable staticProp,
                                       dynamicProp[] )
Replace ${NAME} with the property value


replaceProperties

public static String replaceProperties(String value,
                                       Object getter)
Replace ${NAME} with the property value


setAttribute

public static void setAttribute(Object proxy,
                                String n,
                                Object v)
            throws Exception
Call void setAttribute( String ,Object )


setProperty

public static void setProperty(Object o,
                               String name)


setProperty

public static void setProperty(Object o,
                               String name,
                               String value)
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).


unCapitalize

public static String unCapitalize(String name)


Copyright B) 2000-2003 Apache Software Foundation. All Rights Reserved.