Java EE 7 - Injection into Runnable/Callable object
Continuing this question, i have a situation... I'm using a Producer/Consumer pattern to consuming a list of objects. My Class Consumer is a implementation of Runnable.
public class MYConsumer implements Runnable{
@EJB
private MYService myService;
private BlockingQueue<> queue;
public MYConsumer (BlockingQueue<> q){
this.queue=q;
}
@Override
public void run() {
/** Error is here**/
myService.insert();
}
}
The implementation of the Pattern is working fine, but when i try to use myService, it is Null. The container not injecting the Service. I know it is because the Container knows only instances created by itself.
But how can overcome this problem? Thanks