About Question com.enthuware.ets.scbcd.v5.2.34 : what will happen to when the dependecy injectionfails
Posted: Sun Jan 02, 2011 12:42 am
Consider the following stateless session bean code:
@Stateless
public class TellerBean implements
com.enthu.ejbplus.TellerRemote{
@Resource
SessionContext sctx;
@Resource(name="location")
String loc = "default";
public double getBalance(int acctid) throws NoAccountException{
try {
Context ic = new InitialContext();
loc = (String) ic.lookup("java:comp/env/location");
System.out.println(loc);
} catch (Exception ex) {
System.out.println("Exception in looking up = " +ex);
}
System.out.println(loc);
return 2.0;
}
}
This bean is deployed without any deployment descriptor.
the given answer is "default" will be printed.
My question is what will happen in the dependency Injection fails in @Resource(name="location")
?
@Stateless
public class TellerBean implements
com.enthu.ejbplus.TellerRemote{
@Resource
SessionContext sctx;
@Resource(name="location")
String loc = "default";
public double getBalance(int acctid) throws NoAccountException{
try {
Context ic = new InitialContext();
loc = (String) ic.lookup("java:comp/env/location");
System.out.println(loc);
} catch (Exception ex) {
System.out.println("Exception in looking up = " +ex);
}
System.out.println(loc);
return 2.0;
}
}
This bean is deployed without any deployment descriptor.
the given answer is "default" will be printed.
My question is what will happen in the dependency Injection fails in @Resource(name="location")
?