Static = One instance / jvm. So make sure you initialize your static variables in the factory in a particular order.
When you create a factory class, and make the objects as static and final, it is absolutely necessary that you initialize dependencies prior to the actual class.
Ex: my tfpService depends on the tfpDao so make sure you initialize the tfp dao fist and then the actual service. Else you get null ptr when you refernce tfpDao in tfpService.
private static final TFPDao tfpDao=new TFPDaoImpl();
private static final TFPParser tfpParser=new TFPParserImpl();
private static final TFPService tfpService=new TFPServiceImpl();
Tuesday, September 9, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment