Top Description Inners Fields Constructors Methods
org.codehaus.groovy.runtime.metaclass

public Class ThreadManagedMetaBeanProperty

extends MetaBeanProperty
Class Inheritance
Imports
groovy.lang.Closure, .MetaBeanProperty, .MetaMethod, org.codehaus.groovy.reflection.CachedClass, .ReflectionCache, org.codehaus.groovy.util.ManagedConcurrentMap, .ReferenceBundle, java.lang.reflect.Modifier, java.util.concurrent.ConcurrentHashMap

This MetaBeanProperty will create a pseudo property whose value is bound to an object using weak references. The values will go out of scope and be garbage collected when the object is collected In fact, this class should be called ExpandoProperty.
Since
1.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
ThreadManagedMetaBeanProperty.ThreadBoundGetter

Accesses the ThreadBound state of the property as a getter

private class
ThreadManagedMetaBeanProperty.ThreadBoundSetter

Sets the ThreadBound state of the property like a setter

Field Summary

Modifier and TypeField and Description
private final Class<T>
private final ThreadManagedMetaBeanProperty.ThreadBoundGetter
private Object
private Closure<V>
private final ManagedConcurrentMap<K, V>
private static final ConcurrentHashMap<String, ManagedConcurrentMap<K, V>>
private final ThreadManagedMetaBeanProperty.ThreadBoundSetter
private static final ReferenceBundle

Constructor Summary

AccessConstructor and Description
public
ThreadManagedMetaBeanProperty(Class<T>
The class that declares the property
declaringClass
,
String
The name of the property
name
,
Class<T>
The type of the property
type
,
Object
The properties initial value
iv
)

Constructs a new ThreadManagedBeanProperty for the given arguments

public
ThreadManagedMetaBeanProperty(Class<T>
The class that declares the property
declaringClass
,
String
The name of the property
name
,
Class<T>
The type of the property
type
,
Closure<V>
The closure responsible for creating the initial value
initialValueCreator
)

Constructs a new ThreadManagedBeanProperty for the given arguments

Method Summary

Modifier and TypeMethod and Description
public MetaMethod
getGetter()

Overrides groovy.lang.MetaBeanProperty.getGetter.

Get the getter method.
public synchronized Object

Returns:

The initial value
getInitialValue
()

Retrieves the initial value of the ThreadBound property

public synchronized Object
private static ManagedConcurrentMap<K, V>
public MetaMethod
getSetter()

Overrides groovy.lang.MetaBeanProperty.getSetter.

Get the setter method.
public void
setInitialValueCreator(Closure<V>
The closure responsible for creating the initial value
callable
)

Closure responsible for creating the initial value of thread-managed bean properties

Inherited from groovy.lang.MetaBeanProperty:
getFieldgetModifiersgetPropertysetFieldsetProperty

Field Detail

declaringClassback to summary
private final Class<T> declaringClass
getterback to summary
private final ThreadManagedMetaBeanProperty.ThreadBoundGetter getter

Hides groovy.lang.MetaBeanProperty.getter.

initialValueback to summary
private Object initialValue
initialValueCreatorback to summary
private Closure<V> initialValueCreator
instance2Propback to summary
private final ManagedConcurrentMap<K, V> instance2Prop
PROPNAME_TO_MAPback to summary
private static final ConcurrentHashMap<String, ManagedConcurrentMap<K, V>> PROPNAME_TO_MAP
setterback to summary
private final ThreadManagedMetaBeanProperty.ThreadBoundSetter setter

Hides groovy.lang.MetaBeanProperty.setter.

SOFT_BUNDLEback to summary
private static final ReferenceBundle SOFT_BUNDLE

Constructor Detail

ThreadManagedMetaBeanPropertyback to summary
public ThreadManagedMetaBeanProperty(Class<T> declaringClass, String name, Class<T> type, Object iv)

Constructs a new ThreadManagedBeanProperty for the given arguments

Parameters
declaringClass:Class<T>

The class that declares the property

name:String

The name of the property

type:Class<T>

The type of the property

iv:Object

The properties initial value

ThreadManagedMetaBeanPropertyback to summary
public ThreadManagedMetaBeanProperty(Class<T> declaringClass, String name, Class<T> type, Closure<V> initialValueCreator)

Constructs a new ThreadManagedBeanProperty for the given arguments

Parameters
declaringClass:Class<T>

The class that declares the property

name:String

The name of the property

type:Class<T>

The type of the property

initialValueCreator:Closure<V>

The closure responsible for creating the initial value

Method Detail

getGetterback to summary
public MetaMethod getGetter()

Overrides groovy.lang.MetaBeanProperty.getGetter.

Doc from groovy.lang.MetaBeanProperty.getGetter.

Get the getter method.

Returns:MetaMethod

the getter method for this property.

getInitialValueback to summary
public synchronized Object getInitialValue()

Retrieves the initial value of the ThreadBound property

Returns:Object

The initial value

getInitialValueback to summary
public synchronized Object getInitialValue(Object object)
getInstance2PropNameback to summary
private static ManagedConcurrentMap<K, V> getInstance2PropName(String name)
getSetterback to summary
public MetaMethod getSetter()

Overrides groovy.lang.MetaBeanProperty.getSetter.

Doc from groovy.lang.MetaBeanProperty.getSetter.

Get the setter method.

Returns:MetaMethod

the setter method for this property.

setInitialValueCreatorback to summary
public void setInitialValueCreator(Closure<V> callable)

Closure responsible for creating the initial value of thread-managed bean properties

Parameters
callable:Closure<V>

The closure responsible for creating the initial value

org.codehaus.groovy.runtime.metaclass back to summary

pack-priv Class ThreadManagedMetaBeanProperty.ThreadBoundGetter

extends MetaMethod
Class Inheritance

Accesses the ThreadBound state of the property as a getter

Field Summary

Modifier and TypeField and Description
private final String
Inherited from groovy.lang.MetaMethod:
EMPTY_ARRAY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public CachedClass
getDeclaringClass()

Implements abstract groovy.lang.MetaMethod.getDeclaringClass.

Gets the class where this method is declared
public int
getModifiers()

Implements abstract groovy.lang.MetaMethod.getModifiers.

Returns the modifiers for this method
public String
getName()

Implements abstract groovy.lang.MetaMethod.getName.

Returns the name of the method represented by this class
public Class<T>
getReturnType()

Implements abstract groovy.lang.MetaMethod.getReturnType.

Access the return type for this method
public Object
invoke(Object
The object this method should be invoked on
object
,
Object[]
The arguments for the method if applicable
arguments
)

Implements abstract groovy.lang.MetaMethod.invoke.

Invoke this method
Inherited from groovy.lang.MetaMethod:
checkParametersclonedoMethodInvokeequalequalgetDescriptorgetMopNamegetSignatureisAbstractisCacheableisMethodisPrivateisProtectedisPublicisSameisStaticprocessDoMethodInvokeExceptiontoString

Field Detail

nameback to summary
private final String name

Constructor Detail

ThreadBoundGetterback to summary
public ThreadBoundGetter(String name)

Method Detail

getDeclaringClassback to summary
public CachedClass getDeclaringClass()

Implements abstract groovy.lang.MetaMethod.getDeclaringClass.

Doc from groovy.lang.MetaMethod.getDeclaringClass.

Gets the class where this method is declared

Returns:CachedClass

class of this method

getModifiersback to summary
public int getModifiers()

Implements abstract groovy.lang.MetaMethod.getModifiers.

Doc from groovy.lang.MetaMethod.getModifiers.

Returns the modifiers for this method

Returns:int

modifiers as an int.

getNameback to summary
public String getName()

Implements abstract groovy.lang.MetaMethod.getName.

Doc from groovy.lang.MetaMethod.getName.

Returns the name of the method represented by this class

Returns:String

name of this method

getReturnTypeback to summary
public Class<T> getReturnType()

Implements abstract groovy.lang.MetaMethod.getReturnType.

Doc from groovy.lang.MetaMethod.getReturnType.

Access the return type for this method

Returns:Class<T>

the return type of this method

invokeback to summary
public Object invoke(Object object, Object[] arguments)

Implements abstract groovy.lang.MetaMethod.invoke.

Doc from groovy.lang.MetaMethod.invoke.

Invoke this method

Parameters
object:Object

The object this method should be invoked on

arguments:Object[]

The arguments for the method if applicable

Returns:Object

The return value of the invocation

org.codehaus.groovy.runtime.metaclass back to summary

private Class ThreadManagedMetaBeanProperty.ThreadBoundSetter

extends MetaMethod
Class Inheritance

Sets the ThreadBound state of the property like a setter

Field Summary

Modifier and TypeField and Description
private final String
Inherited from groovy.lang.MetaMethod:
EMPTY_ARRAY

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public CachedClass
getDeclaringClass()

Implements abstract groovy.lang.MetaMethod.getDeclaringClass.

Gets the class where this method is declared
public int
getModifiers()

Implements abstract groovy.lang.MetaMethod.getModifiers.

Returns the modifiers for this method
public String
getName()

Implements abstract groovy.lang.MetaMethod.getName.

Returns the name of the method represented by this class
public Class<T>
getReturnType()

Implements abstract groovy.lang.MetaMethod.getReturnType.

Access the return type for this method
public Object
invoke(Object
The object this method should be invoked on
object
,
Object[]
The arguments for the method if applicable
arguments
)

Implements abstract groovy.lang.MetaMethod.invoke.

Invoke this method
Inherited from groovy.lang.MetaMethod:
checkParametersclonedoMethodInvokeequalequalgetDescriptorgetMopNamegetSignatureisAbstractisCacheableisMethodisPrivateisProtectedisPublicisSameisStaticprocessDoMethodInvokeExceptiontoString

Field Detail

nameback to summary
private final String name

Constructor Detail

ThreadBoundSetterback to summary
public ThreadBoundSetter(String name)

Method Detail

getDeclaringClassback to summary
public CachedClass getDeclaringClass()

Implements abstract groovy.lang.MetaMethod.getDeclaringClass.

Doc from groovy.lang.MetaMethod.getDeclaringClass.

Gets the class where this method is declared

Returns:CachedClass

class of this method

getModifiersback to summary
public int getModifiers()

Implements abstract groovy.lang.MetaMethod.getModifiers.

Doc from groovy.lang.MetaMethod.getModifiers.

Returns the modifiers for this method

Returns:int

modifiers as an int.

getNameback to summary
public String getName()

Implements abstract groovy.lang.MetaMethod.getName.

Doc from groovy.lang.MetaMethod.getName.

Returns the name of the method represented by this class

Returns:String

name of this method

getReturnTypeback to summary
public Class<T> getReturnType()

Implements abstract groovy.lang.MetaMethod.getReturnType.

Doc from groovy.lang.MetaMethod.getReturnType.

Access the return type for this method

Returns:Class<T>

the return type of this method

invokeback to summary
public Object invoke(Object object, Object[] arguments)

Implements abstract groovy.lang.MetaMethod.invoke.

Doc from groovy.lang.MetaMethod.invoke.

Invoke this method

Parameters
object:Object

The object this method should be invoked on

arguments:Object[]

The arguments for the method if applicable

Returns:Object

The return value of the invocation