Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] advising jsp's for i18n (because of problem withhibernate property)

Rauol,
 
Are the JSP tags also using reflection to get access to the underlying data hence the problem picking out via a call join point?
 
What about converting it back into execution join point and use something like cflow to exclude calls from Hibernate?
 
I assume then given your structure you have no Value Objects that sit on top of your Hibernate objects?  If you did you could wire it in at that level potentially.
 
Ron

________________________________

From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Raoul Schmidiger
Sent: Wed 4/5/2006 1:30 PM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] advising jsp's for i18n (because of problem withhibernate 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 

<<winmail.dat>>


Back to the top