Probably you can cache it by AnnotationInstance, so maybe something
like this instead:
class AnnotationProxyBuilder {
private final Map annotationProxyMap = new ...;
public <T> T getAnnotationProxy(final AnnotationInstance
annotationInstance, final Class<T> annotationClass) {
T annotationProxy = (T) annotationProxyMap.get(
annotationInstance );
if ( annotationProxy == null ) {
annotationProxy = buildAnnotationProxy( annotationInstance,
annotationClass );
annotationProxyMap.put( annotationInstance, annotationProxy
);
}
return annotationProxy;
}
private <T> T buildAnnotationProxy(final AnnotationInstance
annotationInstance, final Class<T> annotationClass) {
// as before...
}
}
--
steve(a)hibernate.org
http://hibernate.org