Try using the UserDao Interface in a static context within the
LoginService by using a DAOManager to initialize the service. This is
cleaner (in my opinion) then using a web container.
e.g.
public class LoginServiceSkeleton {
private static IUserDAO userDao;
static {
Reader in =
com.ibatis.common.util.Resources.getResourceAsReader("/path/to/ibatis/da
o-config.xml);
com.ibatis.dao.client.DaoManager manager =
com.ibatis.dao.client.DaoManagerBuilder.buildDaoManager(in);
userDao = (IUserDAO )manager.getDao(IUserDAO .class);
}
...
}
- Doug
-----Original Message-----
From: Vyacheslav Yakovenko [mailto:[EMAIL PROTECTED]
Sent: Monday, September 11, 2006 1:06 PM
To: [email protected]
Subject: [Axis2] Integrating iBatis DAO with Axis2
I'm trying to integrate iBatis DAO with Axis2 and have some problem.
I'll try to explain it on the sample that I found at the
axis2-1.0-docs.zip/xdocs/tools/1_0
//iBatis DAO invocation/CodegenToolReference.html:
/**
* LoginServiceSkeleton java skeleton for the axisService
*/
public class LoginServiceSkeleton {
public login.types.ReturnWebLoginElementDocument webLogin
(login.types.WebLoginElementDocument param0 ){
//iBatis DAO invocation
UserDAOImpl usrDao = new UserDAOImpl();
UserKey key = new UserKey();
key.setId(new Integer(1));
User user = userDao.selectUser(key);
}
}
As you see at this example I'm creating DAO object implisetly at the
ws-method - it's not a good approach because it is very expensive
operation. I want to create a UserDAOImpl instance only once and store
it under the "application" context. It'll solve some problems, because
UserDAOImpl is responsible for DB connection pool also.
So, I want something like this (scratch only):
public login.types.ReturnWebLoginElementDocument webLogin
(login.types.WebLoginElementDocument param0 ){
//iBatis DAO invocation
UserDAOImpl usrDao = cntxt.getUserDaoInstance();
...
}
The main question is: how i can receive access to TomCat's application
context inside a ws-methods? I tried to search the Axis 1.4 and Axis 2
documentation but didn't find any information that can help me. So, your
comments will be very helpful.
--
Thanks,
Vaclav
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]