Search code examples
javacdi

get real class name for cdi managed bean


Is there a way to get hold of the real class name for a CDI managed instance? I need the real class name to match on it, but I get Client Weld Proxy names when invoking getClass method. much appreciated.


Solution

  • As far as I could understand there is not reliable way to get a hold of real class behind the proxy. As a matter of fact there might not be a real class after all. What I ended up doing is to check the classname string to see it it matches the crazy string Weld attaches to class name. If it is not, then you are dealing with the real class. But if it is, get the superclass of the proxy. That is the class you are looking for.