|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--ahc.generic.AttributeGetterFactory
This class serves as a factory for different kinds of AttributeGetter implementations. The purpose of an AttributeGetter is to retrieve arbitrary attributes from the objects that are reachable via get methods from the original object; for a more detailed description see AttributeGetter.
Traditionally, such lookups are done using reflection. That has the disadvantage of being very slow. So this factory offers three different implementations with different trade-offs - see the descriptions of the actual create methods for details.
The following list contains the results of one performance measurement I made. These results should of course be taken with a grain of salt, but they give a rough idea of what to expect for long running applications. The results are durations, so less is better.
classloader implementations: | 18 |
caching reflection: | 190 |
non-caching reflection: | 2120 |
Constructor Summary | |
AttributeGetterFactory()
|
Method Summary | |
static AttributeGetter |
createCachingReflectionGetter()
This implementation uses reflection but performs aggressive caching of intermediate results. |
static AttributeGetter |
createClassLoaderGetter()
This method creates and returns an AttributeGetter implementation that is based on a custom classloader implementation. |
static AttributeGetter |
createNonCachingReflectionGetter()
This method creates a straightforward implementation that uses reflection and does no caching whatsoever. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public AttributeGetterFactory()
Method Detail |
public static AttributeGetter createClassLoaderGetter()
A specific class is created (and cached) for every type of object and every access path. That leads to several specific aspects of this implementation:
public static AttributeGetter createNonCachingReflectionGetter()
As indicated above, this approach is several orders of magnitude slower than the classloader approach, so the only reason to use it is to save memory by avoiding caching.
public static AttributeGetter createCachingReflectionGetter()
This implementation is usually far slower than the classloader implementation and uses significantly more cache memory, but optimization by the JIT compiler happens faster. The only context I am aware of where you might want to use this implementation is in an EJB container where the spec prohibits the use of custom class loaders.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |