Do something like the following. Then you simply call the static
getDaoManager() method.
package com.foo.myapp.dao.sqlmap;
import com.ibatis.common.resources.Resources;
import com.ibatis.dao.client.DaoManager;
import com.ibatis.dao.client.DaoManagerBuilder;
import java.io.Reader;
public class DaoConfig {
private static final DaoManager daoManager;
static {
try {
String resource = "com/foo/myapp/config/dao.xml";
Reader reader = Resources.getResourceAsReader(resource);
daoManager = DaoManagerBuilder.buildDaoManager(reader);
} catch (Exception e) {
throw new RuntimeException("Could not initialize DaoConfig.
Cause: " + e);
}
}
public static DaoManager getDaomanager() {
return daoManager;
}
}
Brandon
On Mon, 07 Mar 2005 07:09:03 -0800, Richard Yee <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm developing an application using the iBATIS DaoManager and currently
> store the dao's that I get by calling DaoManager.getDao( ) in the
> application context at the application startup.. I was wondering if this is
> correct. Should I instead be storing the DaoManager in the application
> context at startup and then calling the getDao() method from it for each
> request?
>
> Thanks,
>
> Richard
>
>