-
1. Re: Class annotations and weld proxies
ron_sigal Oct 20, 2017 7:14 PM (in response to ron_sigal)By the way, this question arises on [RESTEASY-1739] Order ParamConverterProviders and ExceptionMappers by @Priority - JBoss Issue Tracker
-
-
3. Re: Class annotations and weld proxies
ron_sigal Oct 21, 2017 10:38 AM (in response to mkouba)Ah, thanks, Martin.
One thing I've tried is just editing "org.jboss.resteasy.test.providers.priority.resource.ProviderPriorityFooParamConverterProviderAAA$Proxy$_$$_WeldClientProxy" to "org.jboss.resteasy.test.providers.priority.resource.ProviderPriorityFooParamConverterProviderAAA" and loading:
String o1Class = o1.getClass().getName();
o1Class = o1Class.substring(0, o1Class.indexOf("$"));
Class<?> o1Clazz = Thread.currentThread().getContextClassLoader().loadClass(o1Class);
Annotation[] o1as = o1Clazz.getAnnotations();
It works, but it's not very nice. After several years, though, I'm guessing that the naming convention of adding "$Proxy$_$$_WeldClientProxy" is likely to be around for a while. What do you think?
-Ron
-
4. Re: Class annotations and weld proxies
mkouba Oct 23, 2017 2:37 AM (in response to ron_sigal)1 of 1 people found this helpfulWell, since Weld 2.3 all "proxy" constructs (i.e. client proxies and subclasses) are marked with SYNTHETIC modifier. So you use this check to be sure. And since Weld 3.0.1 special marker interfaces are part of the API (see also api/weld/src/main/java/org/jboss/weld/proxy at 3.0.SP1 · weld/api · GitHub ). Also it's not necessary to parse the name and load the class again. Instead, inspect the subclass via reflection (Weld is using subclassing for both client proxies and interception).
-
5. Re: Class annotations and weld proxies
ron_sigal Oct 24, 2017 9:42 PM (in response to mkouba)Hey Martin,
The fact that the proxy class is a subclass of the original class - that's fantastically useful. I never knew that. I feel much better about the solution. It's so much simpler and prettier - just
Class<?> clazz = o.getClass();
clazz = clazz.isSynthetic() ? clazz.getSuperClass() : clazz;
Priority priority = clazz.getAnnotation(Priority.class);
Fantastic!!
Thanks,
Ron