Sorry, I didn't write. Class B is also @Dependent
среда, 21 декабря 2016 г., 19:07:49 UTC+3 пользователь iJava написал:
>
> Hi all
>
> I have problem with nested injection - I always get null.
> I have two classes:
> @Dependent
> public class ClassA{
> @Inject ClassB classB;
>
> public void testMe(){
> if (classB==null){
> System.out.println("null") ;//I ALWAYS GET NULL HERE
> }else{
> System.out.println("NOT null") ;
> }
> }
> }
>
> public class ClassB{} // THIS CLASS IS LOCATED IN THE SAME PACKAGE
> This is the way I create instance of ClassA
> ServiceReference<?> sr = bundleContext.getServiceReference(BeanManager.
> class.getName());
> BeanManager beanManager = (BeanManager) bundleContext.getService(sr);
> Bean<?> bean = (Bean<?>)beanManager.resolve(beanManager.getBeans(ClassA.
> class));
> ClassA classA= (ClassA) beanManager.getReference(bean, bean.getBeanClass
> (), beanManager.createCreationalContext(bean));
>
> How to explain it?
>
> Best regards, Pavel
>
--
--
------------------
OPS4J - http://www.ops4j.org - [email protected]
---
You received this message because you are subscribed to the Google Groups
"OPS4J" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.