[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[aspectj-users] advising jsp's for i18n (because of problem with hibernate property)
|
Title: advising jsp's for i18n (because of problem with hibernate property)
Hi aspectj users,
i have a problem with advising jsp's: in our app, we have some "dynamic i18n data". this is not the "static" stuff in the jsp's that can be translated through jsp tags. but instead, it is a buisness object that has multilingual descriptions of some sort.
the idea is to have i18n unaware business objects:
public String getProductName() {
return productName;
}
instead of
public String getProductName(Locale loc) {
if(loc.getLanguage().equals("en") {
return productNameEnglish;
}
...
return productNameDefault;
}
So i thought, i would use an aspect:
String around(): callGetProductName() {
final I18NInfo info = I18NInfo.get();
final Locale locale = info.getLocale();
final String language = locale.getLanguage();
System.out.println("GETTER: language: " + language);
if(!language.equals("en")) {
return fetchLanguageFromDB(language);
}
return proceed();
}
With a execution pointcut, this workes fine but since this property is mapped also by Hibernate, it doesn't. hibernate thinks, the value english value changed, when i return the french version and afterwards i have my french text in the db where the english should be.
To solve this i did the same with a call pointcut, since hibernate is accessing the method through refelction, it would not be touched by it. So i went on to precompile my JSP's and tried to advise the servlets:
This is what the compiled JSP, the servlet code looks like when accessing :
org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${product.productName}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));
so my pointcut is not hooking in here...
pointcut callGetProductName():
call(public String com.ip.model.product.IProduct.getProductName());
Any ideas how to solve my problem?
Thanks, raoul