I have a bunch of dependencies written as fast binary web services (aka Ejb3.1). Here is the service delcaration:
@Remote
public interface MyService {...}
You would inject an EJB into a servlet or managed bean with the following syntax:
@EJB
MyService myService;
I don't want to use the @EJB injection however. I'd like to use plain vanilla CDI:
@Inject
MyService myService;
One way to accomplish this would be to Create a @Produces method for every EJB:
@Produces MyService produceMyService(InjectionPoint ijp){
//jndi lookup for MyService interface
}
However, InjectionPoint is capable of giving you all the information you need, such as the target class name (MyService in this case).
Is there a way in CDI to do something like this? I'd want to call this producer last, if the required injection point couldn't be fulfilled in any other manner.
@Produces Object produce(InjectionPoint ijp){
Class ejbInterface = ijp.getType();
//jndi lookup for ejbInterface
}
This is a confusing post, so ask clarification questions. Thanks a ton!