I have a small doubt from the EJB 3.0 in Action book,
Here it is...To look up a resource from the helper class, you have to reference the reouurce in the EJB class as follows,
@Resource(name="jdbc/actionBazaarDB", mappedName="jdbc/actionBazaarDS", type=javax.sql.Datasource.class)
public class PlaceBidBean implements PlaceBid
You can look up the resource either from the EJB or the helper class as follows:
Context ctx = new InitialContext ();
DataSource ds = (DataSource) ctx.lookup("java:comp/env/jdbc/ActionBazaarDB);
I understand that we cannot use DI in un-managed classes, but from the above code, how will my @Resource Annotation know which helper class to look for doing the DI?
Originally posted by Mihai Radulescu:
in your example you deal with a managed class because you use the @Stateless annotation.
The container will use the mappedName together with the name to inject the needed instance.
Where will the container look for the mappedName?