Top Description Inners Fields Constructors Methods
com.thoughtworks.paranamer

public Class CachingParanamer

extends Object
implements Paranamer
Class Inheritance
All Implemented Interfaces
com.thoughtworks.paranamer.Paranamer
Known Direct Subclasses
com.thoughtworks.paranamer.CachingParanamer.WithoutWeakReferences
Imports
java.lang.reflect.AccessibleObject, java.util.Collections, .Map, .WeakHashMap, java.util.concurrent.ConcurrentHashMap

Implementation of Paranamer which delegate to another Paranamer implementation, adding caching functionality to speed up usage. It also uses a WeakHashmap as an implementation detail (wrapped in Collections.synchronizedMap(..)), to allow large usages to garbage collect things as big as whole classloaders (after working through all the refs that originated from that classloader). Tomcat and other 'containers' do this during hot application deployment, undeployment and most importantly for Paranamer redeployment. Basically, this will allow a perm-gen usage keeps growing scenario.
Authors
Paul Hammant, Mauro Talevi

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
CachingParanamer.WithoutWeakReferences

This implementation has a better concurrent design (ConcurrentHashMap) which has a better strategy to implement concurrency: segments instead of synchronized.

Field Summary

Modifier and TypeField and Description
public static final String
private final Paranamer
private final Map<AccessibleObject, String[]>

Constructor Summary

AccessConstructor and Description
public
CachingParanamer()

Uses a DefaultParanamer as the implementation it delegates to.

public
CachingParanamer(Paranamer
the paranamer instance to use
delegate
)

Specify a Paranamer instance to delegates to.

Method Summary

Modifier and TypeMethod and Description
public String[]
lookupParameterNames(AccessibleObject
the Method or Constructor for which the parameter names are looked up.
methodOrConstructor
)

Implements com.thoughtworks.paranamer.Paranamer.lookupParameterNames.

Lookup the parameter names of a given method.
public String[]
lookupParameterNames(AccessibleObject
the Method or Constructor for which the parameter names are looked up.
methodOrCtor
,
boolean
whether to throw an exception if no Paranamer data found (versus return null).
throwExceptionIfMissing
)

Implements com.thoughtworks.paranamer.Paranamer.lookupParameterNames.

Lookup the parameter names of a given method.
protected Map<AccessibleObject, String[]>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

__PARANAMER_DATAback to summary
public static final String __PARANAMER_DATA
delegateback to summary
private final Paranamer delegate
methodCacheback to summary
private final Map<AccessibleObject, String[]> methodCache

Constructor Detail

CachingParanamerback to summary
public CachingParanamer()

Uses a DefaultParanamer as the implementation it delegates to.

CachingParanamerback to summary
public CachingParanamer(Paranamer delegate)

Specify a Paranamer instance to delegates to.

Parameters
delegate:Paranamer

the paranamer instance to use

Method Detail

lookupParameterNamesback to summary
public String[] lookupParameterNames(AccessibleObject methodOrConstructor)

Implements com.thoughtworks.paranamer.Paranamer.lookupParameterNames.

Doc from com.thoughtworks.paranamer.Paranamer.lookupParameterNames.

Lookup the parameter names of a given method.

Parameters
methodOrConstructor:AccessibleObject

the Method or Constructor for which the parameter names are looked up.

Returns:String[]

A list of the parameter names.

lookupParameterNamesback to summary
public String[] lookupParameterNames(AccessibleObject methodOrCtor, boolean throwExceptionIfMissing)

Implements com.thoughtworks.paranamer.Paranamer.lookupParameterNames.

Doc from com.thoughtworks.paranamer.Paranamer.lookupParameterNames.

Lookup the parameter names of a given method.

Parameters
methodOrCtor:AccessibleObject

the Method or Constructor for which the parameter names are looked up.

throwExceptionIfMissing:boolean

whether to throw an exception if no Paranamer data found (versus return null).

Returns:String[]

A list of the parameter names.

makeMethodCacheback to summary
protected Map<AccessibleObject, String[]> makeMethodCache()
com.thoughtworks.paranamer back to summary

public Class CachingParanamer.WithoutWeakReferences

extends CachingParanamer
Class Inheritance

This implementation has a better concurrent design (ConcurrentHashMap) which has a better strategy to implement concurrency: segments instead of synchronized. It also drops the underlying WeakHashMap implementation as that can't work with ConcurrentHashMap with some risk of growing permgen for a certain class of usage. So instead of wrapping via 'Collections.synchronizedMap(new WeakHashMap())' we now have 'new ConcurrentHashMap()'

Field Summary

Inherited from com.thoughtworks.paranamer.CachingParanamer:
__PARANAMER_DATA

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected Map<AccessibleObject, String[]>
Inherited from com.thoughtworks.paranamer.CachingParanamer:
lookupParameterNameslookupParameterNames

Constructor Detail

WithoutWeakReferencesback to summary
public WithoutWeakReferences()
WithoutWeakReferencesback to summary
public WithoutWeakReferences(Paranamer delegate)

Method Detail

makeMethodCacheback to summary
protected Map<AccessibleObject, String[]> makeMethodCache()

Overrides com.thoughtworks.paranamer.CachingParanamer.makeMethodCache.

Annotations
@Override