I am testing using iBatis DAO with iBatis SqlMaps in a web application. Right now I have a BaseService that looks like this:
public abstract class BaseService { public static final String DAO_XML_PATH = "com/intrust/anykey/database/dao/iBatis/dao.xml"; protected DaoManager daoManager; public BaseService(){ try{ final Reader reader = Resources.getResourceAsReader(DAO_XML_PATH); daoManager = DaoManagerBuilder.buildDaoManager(reader); }catch(IOException e) { e.printStackTrace(); } } } All my Service class extend this base service. What I would like to know is if there is a way to load the daoManager into the ServletContext somehow so that I am not parsing the dao.xml file with every service request. I'd like to do it once when the Webapp loads and just pull the daoManager from the ServletContext. Is it as easy as creating a ContextListener to do this? Is there one in the API that I don't know about? Writing my own isn't a problem though.