java - CDI: Discovering beans from multiple ClassLoaders -
i'm facing problem cdi extension. im using beforebeandiscovery method add together multiple classes cdi bean discovery:
public void beforebeandiscovery(@observes beforebeandiscovery bbd, beanmanager beanmanager) { class clazz = myclassloader.loadclass("com.my.example.clazz"); final annotatedtype<?> annotatedtype = beanmanager.createannotatedtype(clazz); bbd.addannotatedtype(annotatedtype, annotatedtype.tostring()); }
this working fine , beans discovered. problem occurs when i'm loading classes multiple classloaders. every time classloader changes added classes previous classloader lost.
this how load classes multiple classloaders:
(myclassloader cl : classloaders) { (class<?> clazz : cl.getclasses()) { final annotatedtype<?> annotatedtype = beanmanager.createannotatedtype(clazz); bbd.addannotatedtype(annotatedtype, annotatedtype.tostring()); } }
can please explain me why happens , how can avoid behavior?
thanks in advance. best regards, gerry
java classloader cdi
No comments:
Post a Comment