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

pbrewer_uk do-not-reply at jboss.com
Wed Nov 14 10:55:18 EST 2007


Ok I've solved that problem. Now I have a problem with seam caching resource bundles.

I'm using Java 6 to do my resource bundle caching, so I want to remove, disable or override the following method in org.jboss.seam.core.SeamResourceBundle.java:

  |    private List<java.util.ResourceBundle> getBundlesForCurrentLocale()
  |    {
  |       Locale instance = org.jboss.seam.core.Locale.instance();
  |       List<ResourceBundle> bundles = bundleCache.get(instance);
  |       if ( bundles==null )
  |       {
  |          bundles = loadBundlesForCurrentLocale();
  |          bundleCache.put(instance, bundles);
  |       }
  |       return bundles;
  | 
  |    }
  | 

Is it possible to override this method somehow? If so any pointers would be much appreciated.

Cheers, Pete.

BTW This is the solution to my previous problem: The trick is to not allow a MissingResourceException to be thrown.

  | @Scope(ScopeType.STATELESS)
  | @BypassInterceptors
  | @Install(true)
  | @Name("org.jboss.seam.core.resourceLoader")
  | public class DBResourceLoader extends ResourceLoader  {
  |   
  |   private Log log = Logging.getLog(DBResourceLoader.class) ;
  |   
  |   /** The serialVersionUID field */
  |   private static final long serialVersionUID = -7063164147487452966L;
  | 
  |   // Redefine how we load a resource bundle
  |   @Override
  |   public ResourceBundle loadBundle(String bundleName) {
  |     try {
  |       log.debug("Searching database resource loader for bundle #0", bundleName) ;
  |       return ResourceBundle.getBundle(bundleName, Locale.instance(), Thread.currentThread().getContextClassLoader(), DBControl.INSTANCE);
  |     } catch (MissingResourceException ex) {
  |       log.debug("Missing resource for bundleName #0", bundleName) ;
  |       return null;
  |     }
  | 
  |   }
  |  
  | }
  | 

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

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



More information about the jboss-user mailing list