Groovy 1.7.0

org.codehaus.groovy.runtime.metaclass
Class MetaClassRegistryImpl

java.lang.Object
  org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl
All Implemented Interfaces:
MetaClassRegistry

class MetaClassRegistryImpl
extends Object

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

author:
James Strachan
author:
John Wilson
author:
Jochen Theodorou
author:
Graeme Rocher
author:
Alex Tkachman
version:
$Revision: 18555 $


Field Summary
static int DONT_LOAD_DEFAULT

static int LOAD_DEFAULT

 
Constructor Summary
MetaClassRegistryImpl()

MetaClassRegistryImpl(int loadDefault)

MetaClassRegistryImpl(boolean useAccessible)

method will be called to enable access to all methods when using reflection

MetaClassRegistryImpl(int loadDefault, boolean useAccessible)

 
Method Summary
void addMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener)

Adds a listener for constant meta classes.

protected void fireConstantMetaClassUpdate(Class c, MetaClass newMc)

Causes the execution of all registered listeners.

static MetaClassRegistry getInstance(int includeExtension)

Singleton of MetaClassRegistry.

FastArray getInstanceMethods()

MetaClass getMetaClass(Class theClass)

MetaClass getMetaClass(Object obj)

MetaClassCreationHandle getMetaClassCreationHandler()

Gets a handle internally used to create MetaClass implementations WARNING: experimental code, likely to change soon

MetaClassRegistryChangeEventListener[] getMetaClassRegistryChangeEventListeners()

Gets an array of of all registered ConstantMetaClassListener instances.

FastArray getStaticMethods()

Iterator iterator()

Returns an iterator to iterate over all constant meta classes.

void removeMetaClass(Class theClass)

void removeMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener)

Removes a constant meta class listener.

void setMetaClass(Class theClass, MetaClass theMetaClass)

Registers a new MetaClass in the registry to customize the type

void setMetaClass(Object obj, MetaClass theMetaClass)

void setMetaClassCreationHandle(MetaClassCreationHandle handle)

Sets a handle internally used to create MetaClass implementations.

boolean useAccessible()

 
Methods inherited from class Object
wait, wait, wait, hashCode, getClass, equals, toString, notify, notifyAll
 

Field Detail

DONT_LOAD_DEFAULT

static final int DONT_LOAD_DEFAULT


LOAD_DEFAULT

static final int LOAD_DEFAULT


 
Constructor Detail

MetaClassRegistryImpl

public MetaClassRegistryImpl()


MetaClassRegistryImpl

public MetaClassRegistryImpl(int loadDefault)


MetaClassRegistryImpl

public MetaClassRegistryImpl(boolean useAccessible)
param:
useAccessible defines whether or not the AccessibleObject#setAccessible method will be called to enable access to all methods when using reflection


MetaClassRegistryImpl

public MetaClassRegistryImpl(int loadDefault, boolean useAccessible)


 
Method Detail

addMetaClassRegistryChangeEventListener

public void addMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener)
Adds a listener for constant meta classes.
param:
listener the listener


fireConstantMetaClassUpdate

protected void fireConstantMetaClassUpdate(Class c, MetaClass newMc)
Causes the execution of all registered listeners. This method is used mostly internal to kick of the listener notification. It can also be used by subclasses to achieve the same.
param:
c the class
param:
newMc the new MetaClass


getInstance

public static MetaClassRegistry getInstance(int includeExtension)
Singleton of MetaClassRegistry.
param:
includeExtension
return:
the registry


getInstanceMethods

public FastArray getInstanceMethods()


getMetaClass

public final MetaClass getMetaClass(Class theClass)


getMetaClass

public MetaClass getMetaClass(Object obj)


getMetaClassCreationHandler

public MetaClassCreationHandle getMetaClassCreationHandler()
Gets a handle internally used to create MetaClass implementations WARNING: experimental code, likely to change soon
return:
the handle


getMetaClassRegistryChangeEventListeners

public MetaClassRegistryChangeEventListener[] getMetaClassRegistryChangeEventListeners()
Gets an array of of all registered ConstantMetaClassListener instances.


getStaticMethods

public FastArray getStaticMethods()


iterator

public Iterator iterator()
Returns an iterator to iterate over all constant meta classes. This iterator can be seen as making a snapshot of the current state of the registry. The snapshot will include all meta classes that has been used unless they are already collected. Collected meta classes will be skipped automatically, so you can expect that each element of the iteration is not null. Calling this method is thread safe, the usage of the iterator is not.
return:
the iterator.


removeMetaClass

public void removeMetaClass(Class theClass)


removeMetaClassRegistryChangeEventListener

public void removeMetaClassRegistryChangeEventListener(MetaClassRegistryChangeEventListener listener)
Removes a constant meta class listener.
param:
listener the listener


setMetaClass

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


setMetaClass

public void setMetaClass(Object obj, MetaClass theMetaClass)


setMetaClassCreationHandle

public void setMetaClassCreationHandle(MetaClassCreationHandle handle)
Sets a handle internally used to create MetaClass implementations. When replacing the handle with a custom version, you should reuse the old handle to keep custom logic and to use the default logic as fall back. WARNING: experimental code, likely to change soon
param:
handle the handle


useAccessible

public boolean useAccessible()


 

Copyright © 2003-2009 The Codehaus. All rights reserved.