Hi Richard,
This is the DAOFactory Singelton implementation
/****************************************/
public class DAOFactory {
private static final Logger logger =
Logger.getLogger(DAOFactory.class.getName());
private static final String resource = "dao.xml";
private static DAOFactory daoFactory = new DAOFactory();
private DaoManager daoManager = null;
private DAOFactory() {
Properties properties = null;
Reader reader = null;
try {
reader = Resources.getResourceAsReader(resource);
properties =
Resources.getResourceAsProperties("database.properties");
this.daoManager = DaoManagerBuilder.buildDaoManager(reader,
properties);
} catch (Exception e) {
logger.error("Error configuring the DAO Factory class",e);
}finally {
try {
if (reader != null) {
reader.close();
}
} catch (Exception e) {
logger.error("Error in closing the reader",e);
}
}
}
public static DAOFactory getInstance() {
return daoFactory;
}
public NCPlusAccountConsumerLinkDAO getNCPlusAccountConsumerLinkDAO() {
NCPlusAccountConsumerLinkDAO nCPlusAccountConsumerLinkDAO =
(NCPlusAccountConsumerLinkDAO)
daoManager.getDao(NCPlusAccountConsumerLinkDAO.class);
return nCPlusAccountConsumerLinkDAO;
}
public DaoManager getDaoManager() {
return this.daoManager;
}
}
/****************************************/
And this is how i use it
/****************************************/
public class AccountTransactionsWrapper {
public DaoManager getDaoManager() {
return getCDTDAOFActoryInstance().getDaoManager();
}
public void deleteByAccountUniqID(AccountConsumerLink linkBean)throws
Exception{
getNCPlusAccountConsumerLinkDAO().deleteByAccountUniqID(linkBean);
}
private static NCPlusAccountConsumerLinkDAO
getNCPlusAccountConsumerLinkDAO(){
return getCDTDAOFActoryInstance().getNCPlusAccountConsumerLinkDAO();
}
private static DAOFactory getCDTDAOFActoryInstance() {
return DAOFactory.getInstance();
}
}
/****************************************/
And in my code i call deleteByAccountUniqID() wherever required
Richard Yee wrote:
>
> Can you send you singleton code and your dao class code that calls it?
>
> Thx,
> R
>
> Sent from my iPhone
>
> On Jun 14, 2009, at 9:51 PM, ankurgur <[email protected]> wrote:
>
>>
>> Hi Richard,
>>
>> No i aam not closing my reader at all !!. thats a bug you helped me
>> find:-)).
>>
>> But talking about memory leak i have the implementation of Reader
>> logic on
>> singelton pattern. So could it be such a major issue?
>>
>> Regards,
>> Ankur
>>
>>
>> Richard Yee wrote:
>>>
>>> Are you closing your reader in a finally clause?
>>>
>>> Richard
>>>
>>> Sent from my iPhone
>>>
>>> On Jun 14, 2009, at 3:39 AM, ankurgur <[email protected]> wrote:
>>>
>>>>
>>>> Thnks Kai,
>>>>
>>>> Let me have a look at it.
>>>>
>>>> Regards,
>>>> Ankur
>>>>
>>>>
>>>> Kai Grabfelder-3 wrote:
>>>>>
>>>>> Hm I guess without some further information about your setup &
>>>>> environment
>>>>> it is hard to tell. imho there is
>>>>> only one known memory leak in 2.3.4 and that only affects
>>>>> redeployment of
>>>>> the app. Please describe your setup
>>>>> in more detail.
>>>>>
>>>>> I think you should have a look at the heap dump by yourself using
>>>>> for
>>>>> example eclipse MAT - a great tool for
>>>>> such tasks. With the heap dump you should be able to tell which
>>>>> classes
>>>>> are not garbage collected and which
>>>>> other classes are referencing them.
>>>>>
>>>>> cheers
>>>>>
>>>>> Kai
>>>>>
>>>>>
>>>>>
>>>>> --- Original Nachricht ---
>>>>> Absender: ankurgur
>>>>> Datum: 13.06.2009 11:51
>>>>>> Hi Kai,
>>>>>>
>>>>>> Thanks a ton for the reply. Yes we already have the singleton
>>>>>> pattern
>>>>>> implementation for our sqlmap client :-((.
>>>>>>
>>>>>> Any other ideas are most welcome.
>>>>>>
>>>>>> Regards,
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Memeory-leak-in-com.iBatis.sqlmap.engine.impl.SqlMapClientImpl-class-tp14105662p24028799.html
>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>
>
>
--
View this message in context:
http://www.nabble.com/Memeory-leak-in-com.iBatis.sqlmap.engine.impl.SqlMapClientImpl-class-tp14105662p24029708.html
Sent from the iBATIS - User - Java mailing list archive at Nabble.com.