I have done my research before asking but no luck.
I have a StartUp Singleton bean. In this bean I have an @Inject @Any Instance. I loop all the implementations and try to check if the class is annotated with a custom annotation. All the implementations(all the classes that I want to inspect) are Stateful or Stateless beans. Sometime the class I want is found and I can perform getClass().isAnnotationPresent(ClassNameAnnotation.class)
Most of the times I get a proxy object and in this case I cannot perform the above check. I cannot find a way to get the real object. I have tried to get the SuperClass but not luck. I will attach some of the code so you can have a better idea.
@Singleton
@Startup
public class CacheLoader {
@Inject
@Any
private Instance<ClassNameA> aClasses;
.......
@Lock(LockType.READ)
public void evaluate() {
if (!aClasses.isUnsatisfied()) {
for (ClassNameA className : aClasses) {
if (className.getClass().isAnnotationPresent(ClassNameAnnotation.class)) {
....
}
}
}
}
}
I tried to use the SuperClass of the proxy object but it does not return what I want. I tried also via Proxy.getInvocationHandler(). Even when I check the methods Proxy.isProxyClass(getClass()) or isSynthetic() does not return that the object is a proxy.
Thank you!