S
Sébastien de Mapias
Hi,
This is a newbie question... I've just read that using a proxy inside
application code is quite unusual, and that it's mostly used in
frameworks... In an app I've inherited, I find the following lines:
DFLT_SESS_FACT = HibernateSupport.getSessionFactory
("hibernate.cfg.xml",
JdbcStuffDAO.class.getClassLoader
(),
new StuffBaseEntityInterceptor());
[...]
public IStuffService2 getStuffService(String p_user,
String p_password,
ApplicationCode
p_applicationCode,
SessionFactory
p_sessionFactory)
throws StuffException
{
JdbcStuffServiceImpl l_service =
new JdbcStuffServiceImpl(p_user,p_applicationCode,new
JdbcStuffDAO(p_sessionFactory));
IStuffService2 l_proxy =
(IStuffService2)Proxy.newProxyInstance
(JdbcStuffFactory.class.getClassLoader(),
new Class[] {IStuffService2.class},
new HibernateSessionInvocationHandler
(DFLT_SESS_FACT,l_service,l_service.getLocale()));
return l_proxy;
}
I'm not familiar with this Proxy thing... What purpose does it serve ?
I've noticed this method could return 'l_service' as well (cause
JdbcStuffServiceImpl implements IStuffService2), and thus have:
{
JdbcStuffServiceImpl l_service =
new JdbcStuffServiceImpl(p_user,p_applicationCode,new
JdbcStuffDAO(p_sessionFactory));
return l_service;
}
but I haven't tested it.
What did the guy who wrote these lines want to achieve ? (he's left,
so
I can't ask him...)
Thanks for your help...
Regards,
Sébastien
This is a newbie question... I've just read that using a proxy inside
application code is quite unusual, and that it's mostly used in
frameworks... In an app I've inherited, I find the following lines:
DFLT_SESS_FACT = HibernateSupport.getSessionFactory
("hibernate.cfg.xml",
JdbcStuffDAO.class.getClassLoader
(),
new StuffBaseEntityInterceptor());
[...]
public IStuffService2 getStuffService(String p_user,
String p_password,
ApplicationCode
p_applicationCode,
SessionFactory
p_sessionFactory)
throws StuffException
{
JdbcStuffServiceImpl l_service =
new JdbcStuffServiceImpl(p_user,p_applicationCode,new
JdbcStuffDAO(p_sessionFactory));
IStuffService2 l_proxy =
(IStuffService2)Proxy.newProxyInstance
(JdbcStuffFactory.class.getClassLoader(),
new Class[] {IStuffService2.class},
new HibernateSessionInvocationHandler
(DFLT_SESS_FACT,l_service,l_service.getLocale()));
return l_proxy;
}
I'm not familiar with this Proxy thing... What purpose does it serve ?
I've noticed this method could return 'l_service' as well (cause
JdbcStuffServiceImpl implements IStuffService2), and thus have:
{
JdbcStuffServiceImpl l_service =
new JdbcStuffServiceImpl(p_user,p_applicationCode,new
JdbcStuffDAO(p_sessionFactory));
return l_service;
}
but I haven't tested it.
What did the guy who wrote these lines want to achieve ? (he's left,
so
I can't ask him...)
Thanks for your help...
Regards,
Sébastien