Announcement Announcement Module
Collapse
No announcement yet.
internationalization with a stateless application Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • internationalization with a stateless application

    Hi,

    My application is a SOAP backend (using CXF). I use a rich domain model.

    I have a User business object with a getLocale() method to know the language in which to display a message.

    I also have a CXF interceptor which is responsible for authentication (and with a ThreadLocal<User>) that I can inject inside the services (this is the beauty of CXF interceptors !) BUT I can not inject it inside a business object.

    In my business object, I have somthing like :
    String msg = String.format("hey {0], you are doing a wrong thing !", "dude");

    This is used to throw an exception

    With i18N, I envision something like :
    String msg = i18n.getMsg("hey {0], you are doing a wrong thing !", cxfUser.get().getLocale())
    msg = String.format((msg, "dude");

    How do I inject the i18n and cxfUser beans inside the business object that is not created by spring (and there can be a lot of business objects !)

    I investigate and found that :
    1/ my business object throws an exception like new AppI18NException("hey {0], you are doing a wrong thing !", "dude") (and I can pass many arguments to the ctor) and then a service (with i18n and cxfUser injected) catch this excpetion to throw a AppException
    2/ there is a dark mecanism with AOP to injectthe services at runtime

    My question is : what is the best option ? Is there any other option ?

    I tend to favour the 1st option but I like some external advices.

    Thanks
Working...
X