org.apache.velocity.util.introspection
Class IntrospectorBase

java.lang.Object
  extended by org.apache.velocity.util.introspection.IntrospectorBase
All Implemented Interfaces:
IntrospectorCacheListener
Direct Known Subclasses:
Introspector

public abstract class IntrospectorBase
extends Object
implements IntrospectorCacheListener

Lookup a a Method object for a particular class given the name of a method and its parameters. The first time the Introspector sees a class it creates a class method map for the class in question. Basically the class method map is a Hashtable where Method objects are keyed by a concatenation of the method name and the names of classes that make up the parameters. For example, a method with the following signature: public void method(String a, StringBuffer b) would be mapped by the key: "method" + "java.lang.String" + "java.lang.StringBuffer" This mapping is performed for all the methods in a class and stored for.

Version:
$Id: IntrospectorBase.java 477003 2006-11-20 01:14:22Z henning $
Author:
Jason van Zyl, Bob McWhirter, Attila Szegedi, Paulo Gaspar, Henning P. Schmiedehausen

Field Summary
protected  Log log
          Class logger
 
Constructor Summary
protected IntrospectorBase(Log log)
          C'tor.
 
Method Summary
protected  void clearCache()
          Deprecated. Use getIntrospectorCache().clear();
protected  ClassMap createClassMap(Class c)
          Deprecated. Use getIntrospectorCache().put(c);
protected  IntrospectorCache getIntrospectorCache()
          Return the internal IntrospectorCache object.
 Method getMethod(Class c, String name, Object[] params)
          Gets the method defined by name and params for the Class c.
protected  ClassMap lookupClassMap(Class c)
          Deprecated. Use getIntrospectorCache().get(c);
 void triggerClear()
          Gets called when the Cache is cleared.
 void triggerGet(Class c, ClassMap classMap)
          Gets called when a ClassMap is requested from the Cache.
 void triggerPut(Class c, ClassMap classMap)
          Gets called when a ClassMap is put into the Cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final Log log
Class logger

Constructor Detail

IntrospectorBase

protected IntrospectorBase(Log log)
C'tor.

Method Detail

getMethod

public Method getMethod(Class c,
                        String name,
                        Object[] params)
                 throws IllegalArgumentException,
                        MethodMap.AmbiguousException
Gets the method defined by name and params for the Class c.

Parameters:
c - Class in which the method search is taking place
name - Name of the method being searched for
params - An array of Objects (not Classes) that describe the the parameters
Returns:
The desired Method object.
Throws:
IllegalArgumentException - When the parameters passed in can not be used for introspection.
MethodMap.AmbiguousException - When the method map contains more than one match for the requested signature.

getIntrospectorCache

protected IntrospectorCache getIntrospectorCache()
Return the internal IntrospectorCache object.

Returns:
The internal IntrospectorCache object.

clearCache

protected void clearCache()
Deprecated. Use getIntrospectorCache().clear();

Clears the internal cache.


createClassMap

protected ClassMap createClassMap(Class c)
Deprecated. Use getIntrospectorCache().put(c);

Creates a class map for specific class and registers it in the cache. Also adds the qualified name to the name->class map for later Classloader change detection.

Parameters:
c - The class for which the class map gets generated.
Returns:
A ClassMap object.

lookupClassMap

protected ClassMap lookupClassMap(Class c)
Deprecated. Use getIntrospectorCache().get(c);

Lookup a given Class object in the cache. If it does not exist, check whether this is due to a class change and purge the caches eventually.

Parameters:
c - The class to look up.
Returns:
A ClassMap object or null if it does not exist in the cache.

triggerClear

public void triggerClear()
Description copied from interface: IntrospectorCacheListener
Gets called when the Cache is cleared.

Specified by:
triggerClear in interface IntrospectorCacheListener
See Also:
IntrospectorCacheListener.triggerClear()

triggerGet

public void triggerGet(Class c,
                       ClassMap classMap)
Description copied from interface: IntrospectorCacheListener
Gets called when a ClassMap is requested from the Cache.

Specified by:
triggerGet in interface IntrospectorCacheListener
Parameters:
c - The class object to look up.
classMap - The Class map to return. Might be null.
See Also:
IntrospectorCacheListener.triggerGet(Class, ClassMap)

triggerPut

public void triggerPut(Class c,
                       ClassMap classMap)
Description copied from interface: IntrospectorCacheListener
Gets called when a ClassMap is put into the Cache.

Specified by:
triggerPut in interface IntrospectorCacheListener
Parameters:
c - The class object to look up.
classMap - The Class map stored in the Cache. Is never null.
See Also:
IntrospectorCacheListener.triggerPut(Class, ClassMap)


Copyright © 2000-2007 The Apache Software Foundation. All Rights Reserved.