Last active
August 29, 2015 14:22
-
-
Save sebersole/64be856cfddd54c4eb76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AnnotationFactory { | |
@SuppressWarnings("unchecked") | |
public static <T extends Annotation> T create(AnnotationDescriptor descriptor) { | |
//TODO round 34ms to generate the proxy, hug! is Javassist Faster? | |
//TODO prebuild the javax.persistence and org.hibernate.annotations classes? | |
Class<T> proxyClass = (Class<T>) Proxy.getProxyClass( descriptor.type().getClassLoader(), descriptor.type() ); | |
InvocationHandler handler = new AnnotationProxy( descriptor ); | |
try { | |
return getProxyInstance( proxyClass, handler ); | |
} | |
catch (RuntimeException e) { | |
throw e; | |
} | |
catch (Exception e) { | |
throw new RuntimeException( e ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment