ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Clinton Begin" <clinton.be...@gmail.com>
Subject Re: DAO Framework - question on thread-safety
Date Tue, 24 Jun 2008 00:08:19 GMT
It's all thread safe, including getDao(Class).  Each instance will be thread
safe as well.

Clinton

On Mon, Jun 23, 2008 at 4:48 PM, mfs <farhan.sarwar@gmail.com> wrote:

>
> Guys,
>
> I am using ibatis DAO Framework and i had certain questions/concerns, that
> whether my current DAO Manager implementation is thread safe, since
> apparently the getDAO(MyDAOClass.class) method (which i am using to
> retrieve
> the dao implementation) isn't thread safe. Also Larry mentioned in one some
> other thread that there is one instance maintained of each DAO
> implementation and thats yet another reason which made to me ask this...
>
> class MyDAOManager
> {
>    private static DaoManager s_daoManager;
>
>    public static synchronized DaoManager getDaoManager()
>    {
>      Log log = LogFactory.getLog(DAOManager.class);
>      if (null == s_daoManager)
>      {
>          try
>          {
>              String daoXMLresource = "[path]/dao.xml";
>              Reader reader = Resources.getResourceAsReader(daoXMLresource);
>              s_daoManager = DaoManagerBuilder.buildDaoManager(reader);
>              log.info("DAOManager Initialized");
>          }
>          catch (IOException ioe)
>          {
>              throw new RuntimeException("Could not initialize DaoConfig.
> Cause: " + ioe);
>          }
>      }
>      return s_daoManager;
>    }
>
>    public static AccountDAO getAccountDao()
>    {
>        return (AccountDAO) getDaoManager().getDao(AccountDAO.class);
>    }
>
>    public static UserDAO getUserDao(Class interfaceClass)
>    {
>        return (UserDAO) getDaoManager().getDao(UserDAO.class);
>    }
>
> Thanks and Regards,
>
>
>
> --
> View this message in context:
> http://www.nabble.com/DAO-Framework---question-on-thread-safety-tp18080103p18080103.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>

Mime
View raw message