Hi,

Actually when you directly instantiate a class, you bypass CDI.  In order
to use CDI, your servlet needs this:

@Inject
private Exam exam;

Within the class itself.

John


On Sun, May 4, 2014 at 5:53 AM, john77eipe <[email protected]> wrote:

> I'm a start in CDI.
>
> To test CDI. I created 2 classes.
>
> public class Exam {
>         @Inject
>         private Student student;
>
>         private int examCode;
>
>         @PostConstruct
>         private void init(){
>                 System.out.println("Init in Exam");
>                 this.setExamCode(11);
>         }
> }
>
> public class Student {
>         private String name;
>
>         @PostConstruct
>         public void init(){
>                 System.out.println("Init in Student");
>                 this.name = "John Eipe";
>         }
> }
>
>
> Isn't it possible to do this in Servlet's doGet.
>
> Exam exam = new Exam();
> System.out.println(exam);
>
> But I don't see Injection happening.
>
>
>
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/TomEE-and-CDI-tp4669131.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>

Reply via email to