-
1. Re: Proxy classes lose original class annotations
meetoblivion Dec 20, 2015 12:32 PM (in response to shamoh)If you know you're dealing with MyBean, why not pass in MyBean.class instead of myBean.getClass() ?
-
2. Re: Proxy classes lose original class annotations
shamoh Dec 20, 2015 4:51 PM (in response to meetoblivion)This is just an simplified example. In real application I don't use MyBean class name and use interfaces or "search" all sub-classes using @Instance annotation.
-
3. Re: Proxy classes lose original class annotations
meetoblivion Dec 20, 2015 5:30 PM (in response to shamoh)Could you maybe provide more information about your use case? My hunch is that this is a case for annotation processing within a CDI extension, instead of the way you may be doing it.
And actually, based on what you're describing, it seems like the issue is fixed w/ @Inherited. What you're requesting goes against the intention of @Inherited - you're trying to make annotations always inherited.
-
4. Re: Proxy classes lose original class annotations
shamoh Dec 20, 2015 5:40 PM (in response to meetoblivion)Let's say I want to "find" / inject all instances of JAX-RS Application implementations. And then and I would like to read JAX-RS ApplicationPath annotation on it.
In this example the ApplicationPath is not my annotation and is not annotated by @Inherited. I think that this should be implementation detail of CDI implementation that it uses some proxy technology. It does not look transparent to me that injected instance of MyBean does not contain same annotations as written by developer directly on the MyBean class.
-
5. Re: Proxy classes lose original class annotations
meetoblivion Dec 20, 2015 5:54 PM (in response to shamoh)This definitely sounds like a case for using a CDI extension, instead of runtime lookup. Your extension can subscribe to
@Observes @WithAnnotation(ApplicationPath.class) ProcessAnnotatedType pat
and then get the real runtime configuration there, making it accessible from your extension instead of looked up here.
Here's how its done in the ResteasyCdiExtension.
-
6. Re: Proxy classes lose original class annotations
shamoh Dec 26, 2015 6:53 PM (in response to meetoblivion)Hello.
JAX-RS Application was just an example. I would like to expect that each injected proxy bean contains same annotations as written at original bean. (As well as 3rd party libraries that are not CDI aware.)
I tried to write myself CDI extension but was not able to pass original bean annotation instances to proxy bean. I'm not sure it is even possible. Or I have used it wrong way.
Thanks,
Libor