groovy.lang
Class MetaClassRegistry

java.lang.Object
  extended bygroovy.lang.MetaClassRegistry

public class MetaClassRegistry
extends Object

A registery of MetaClass instances which caches introspection & reflection information and allows methods to be dynamically added to existing classes at runtime

Version:
$Revision: 1.21 $
Author:
James Strachan

Field Summary
static int DONT_LOAD_DEFAULT
           
static int LOAD_DEFAULT
           
 
Constructor Summary
MetaClassRegistry()
           
MetaClassRegistry(boolean useAccessible)
           
MetaClassRegistry(int loadDefault)
           
 
Method Summary
 Constructor getDefinedConstructor(Class theClass, Class[] args)
           
 MetaMethod getDefinedMethod(Class theClass, String methodName, Class[] args, boolean isStatic)
           
static MetaClassRegistry getIntance(int includeExtension)
          Singleton of MetaClassRegistry.
 MetaClass getMetaClass(Class theClass)
           
 Class loadClass(ClassLoader loader, String name)
           
 Class loadClass(ClassLoader loader, String name, byte[] bytecode)
           
 Class loadClass(String name)
           
 Class loadClass(String name, byte[] bytecode)
          A helper class to load meta class bytecode into the class loader
 void removeMetaClass(Class theClass)
           
 void setMetaClass(Class theClass, MetaClass theMetaClass)
          Registers a new MetaClass in the registry to customize the type
 boolean useAccessible()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOAD_DEFAULT

public static final int LOAD_DEFAULT
See Also:
Constant Field Values

DONT_LOAD_DEFAULT

public static final int DONT_LOAD_DEFAULT
See Also:
Constant Field Values
Constructor Detail

MetaClassRegistry

public MetaClassRegistry()

MetaClassRegistry

public MetaClassRegistry(int loadDefault)

MetaClassRegistry

public MetaClassRegistry(boolean useAccessible)
Parameters:
useAccessible - defines whether or not the java.lang.reflect.AccessibleObject.setAccessible(); method will be called to enable access to all methods when using reflection
Method Detail

getMetaClass

public MetaClass getMetaClass(Class theClass)

removeMetaClass

public void removeMetaClass(Class theClass)

setMetaClass

public void setMetaClass(Class theClass,
                         MetaClass theMetaClass)
Registers a new MetaClass in the registry to customize the type

Parameters:
theClass -
theMetaClass -

useAccessible

public boolean useAccessible()

loadClass

public Class loadClass(String name,
                       byte[] bytecode)
                throws ClassNotFoundException
A helper class to load meta class bytecode into the class loader

Throws:
ClassNotFoundException

loadClass

public Class loadClass(ClassLoader loader,
                       String name,
                       byte[] bytecode)
                throws ClassNotFoundException
Throws:
ClassNotFoundException

loadClass

public Class loadClass(ClassLoader loader,
                       String name)
                throws ClassNotFoundException
Throws:
ClassNotFoundException

loadClass

public Class loadClass(String name)
                throws ClassNotFoundException
Throws:
ClassNotFoundException

getDefinedMethod

public MetaMethod getDefinedMethod(Class theClass,
                                   String methodName,
                                   Class[] args,
                                   boolean isStatic)

getDefinedConstructor

public Constructor getDefinedConstructor(Class theClass,
                                         Class[] args)

getIntance

public static MetaClassRegistry getIntance(int includeExtension)
Singleton of MetaClassRegistry. Shall we use threadlocal to store the instance?

Parameters:
includeExtension -
Returns:


Copyright © 2003-2005 The Codehaus. All Rights Reserved.