[jboss-user] [JBoss Seam] - Re: ResourceBundle in Database

Zerg-Spirit do-not-reply at jboss.com
Fri Sep 7 05:49:41 EDT 2007


Ok, then I must do something wrong, that's for sure.

I have overriden 2 classes:
ResourceLoader and MessageFactory

ResourceLoader:
@Scope(SESSION)
  | @BypassInterceptors
  | @Name("org.jboss.seam.core.resourceLoader")
  | public class ExtendedResourceLoader extends
  | 		org.jboss.seam.core.ResourceLoader {
  | 	...
  | 
  | 	@Override
  | 	@Observer("org.jboss.seam.localeSelected")
  | 	public ResourceBundle loadBundle(String bundleName) {
  | 	
  | 		try {
  | 			if (DBControl.getInstance().isDirty(
  | 					org.jboss.seam.core.Locale.instance().toString())) 
  |                                  //If the current locale is dirty, we create a new bundle.
  |                                  ResourceBundle bundle = DBControl.getInstance().newBundle(
  | 						bundleName, Locale.instance(), "Db",
  | 						Thread.currentThread().getContextClassLoader(), true);
  |                                 return bundle;
  |                        else {
  | 				ResourceBundle bundle = ResourceBundle.getBundle(bundleName,
  | 						Locale.instance(), Thread.currentThread()
  | 								.getContextClassLoader(), DBControl
  | 								.getInstance());
  | 				return bundle;
  | 			}

messageFactory:

@Scope(SESSION)
  | @BypassInterceptors
  | @Name("org.jboss.seam.international.messagesFactory")
  | public class SeamMessages extends Messages {
  | @Override
  | 	public Map<String,String> createMap(){
  | 		ResourceBundle resourceBundle = org.jboss.seam.core.ResourceBundle.instance();
  |                 //That retrived bundle doesn't match the newly created bundle in ResourceLoader overriden class, so the created map isn't matching the current state of the database.
  | 
  | ...
  | public static Map<String, String> instance()
  | 	{
  | 
  | 		if ( !Contexts.isSessionContextActive() )
  | 		{
  | 			throw new IllegalStateException("no event context active");
  | 		}
  | 		
  | 		return (Map<String, String>) Component.getInstance("org.jboss.seam.international.messages", true);
  | 	}

DBcontrol is a custom class extending Control class to instanciate ResourceBundles that are loading data from the database (this mecanism works since when the app is deployed, the correct messages are loaded, as well as when I'm changing the locale).
So basically, when I changed a message and reload the locale, the change isn't performed on messages map.

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

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



More information about the jboss-user mailing list