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

pbrewer_uk do-not-reply at jboss.com
Wed Nov 14 07:17:24 EST 2007


I'm a bit puzzled as to why my custom resource loader isn't being called for anything other than page resource bundles. I'm using Seam 2.0.0.GA with Java 6:

components.xml

  |   ...
  |   <component name="org.jboss.seam.core.resourceLoader">
  |     <property name="bundleNames">
  |       <value>messages</value>
  |       <value>labels</value>
  |       <value>buttons</value>
  |       <value>content</value>
  |       <value>validation</value>
  |     </property>
  |   </component>
  |   ...
  | 

 DBResourceLoader.java

  | @Scope(ScopeType.STATELESS)
  | @BypassInterceptors
  | @Install(true)
  | @Name("org.jboss.seam.core.resourceLoader")
  | public class DBResourceLoader extends org.jboss.seam.core.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) {
  |     log.debug("Searching database resource loader for bundle #0", bundleName) ;
  |     return ResourceBundle.getBundle(bundleName, Locale.instance(), Thread.currentThread().getContextClassLoader(), DBControl.INSTANCE);
  |   }
  |  
  | }
  | 

And in the logs I can see from my debug message that it searches the bundle for the current page, but I can never see it trying to load the bundle names specified in components.xml.

If anyone can help or suggest any ides that would be greatly appreciated,
Thanks in advance, Pete



BTW: I found an oddity debugging the code. By putting a breakpoint at line 97 and 98, I hit the breakpoint at 97, step over that line and then never hit line 98. And I can't see any exceptions happening. Any ideas why?

org.jboss.seam.core.SeamResourceBundle.java

  | 95   protected Object handleGetObject(String key)
  | 96   {
  | 97     List<java.util.ResourceBundle> pageBundles = getPageResourceBundles();
  | 98     for (java.util.ResourceBundle pageBundle : pageBundles)
  | 99     {
  | 100      try
  | 101      {
  | 102        return interpolate(pageBundle.getObject(key));
  | 103      }
  | 104      catch (MissingResourceException mre) {}
  | 105    }
  | 106
  | 107    for (java.util.ResourceBundle littleBundle : getBundlesForCurrentLocale())
  | 108    {
  | 109      try
  | 110      {
  | 111        return interpolate( littleBundle.getObject(key) );
  | 112      }
  | 113      catch (MissingResourceException mre) {}
  | 114    }
  | 115
  | 116    return null; // superclass is responsible for throwing MRE
  | 117  }
  | 

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

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



More information about the jboss-user mailing list