We are moving our legacy implementation to Spring IBatis model. I am kind of stuck in modeling these objects in cleaner way using Spring model
Lets say I have two classes [ Both of them are singleton ]
DAOImpl implements DAOInterface
CacheDAOImpl implements DAOInterface
Code snippet showing object initialization in CacheDAOImpl
.....
private static CacheDAOImpl ourInstance = new CacheDAOImpl();
public static CacheDAOImpl getInstance()
{
return ourInstance;
}
private CacheDAOImpl()
{
// intialiazes all caches
}
Code snippet from DAOImpl showing the CacheDAOImpl Object usage
private DAO getCacheDAO()
{
return CacheDAOImpl.getInstance();
}
@Override
public SomeObject lookUpId()
{
return getCacheDAO().lookUpId();
}
In the above implementation cache is initialized only when an method is invoked in DAOImpl whereas with Spring model of initialization, can we do this?. lazy-init may not work here as the object DAOImpl will always be accessed by non-lazy bean