Skip to content

Instantly share code, notes, and snippets.

@sebersole
Last active August 29, 2015 14:22
Show Gist options
  • Save sebersole/64be856cfddd54c4eb76 to your computer and use it in GitHub Desktop.
Save sebersole/64be856cfddd54c4eb76 to your computer and use it in GitHub Desktop.
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