[jboss-user] [JBoss Seam] - Re: @factory and Contexts

mnrz do-not-reply at jboss.com
Sat Oct 28 05:46:29 EDT 2006


Hi

In my opinion you should create a factory class in which you choose proper instance to select from database depend on given locale.

for example, if you support two locales you should have something like this:

interface Country {}

class CountryEnglish implement Country{}

class CountryFrench implements Country{}

then your factory class:
class CountryFactory {
   static Country getInctance(int localeId){
              if(localeId == ENGLISH){
                   return new CountryEnglish();
               }
              if(localeId == FRENCH){
                   return new CountryFrench();
               }
    }
}

and you should put EntityManager in those two class and call them to select from database instead of calling "em" directly.

hope this help.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3981514#3981514

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3981514



More information about the jboss-user mailing list