deltaspike-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "rickqinj" <rickq...@aliyun.com>
Subject Restrictions of using BeanProvider?
Date Wed, 20 Jul 2016 07:13:43 GMT
Hello,The BeanProvider makes me confused for a few days. Could anyone help me out?The problem
in my case is that I cannot get an instance of a non-managed class by BeanProvider.getContextualReference()
method.I listed my case as following:
// DeltaSpike 1.4.2, Weld 1.1.31, CDI 1.0-SP4
//--Class A--public class A {    //member fields
    private B b;    //Constructor with parameters.    public A(String p1, String
p2, String p3) {        //...just do something.
    }    public B getInstanceOfB() {        b = BeanProvider.getContextualReference(B.class,
false);        return b;
    }
}
//--Class Caller--@Named
public class Caller {    //...    public void action() {        A a = new A("s1",
"s2", "s3");        B b = a.getInstanceOfB(); //<-------- I cannot get an instance
of B.    }    //...
}
The class A is a non-managed bean, and Caller is managed.
Am I do wrong with BeanProvider? What should I do to get the instance of B?Ps. I cannot make
the class A managed, it may cause refactoring of all project. (~that's awful~)And according
to the error log, it seems that a missing InjectionPoint may caused this problem.
Many thanks for your help!


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message