[hibernate-dev] Accessing annotation properties values

Steve Ebersole steve at hibernate.org
Thu Oct 4 22:05:03 EDT 2012


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 at hibernate.org
http://hibernate.org


More information about the hibernate-dev mailing list