tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util StringManager.java
Date Sat, 05 Apr 2003 04:10:34 GMT
costin      2003/04/04 20:10:34

  Modified:    catalina/src/share/org/apache/catalina/util
                        StringManager.java
  Log:
  Ok, classloader problems still happen - and it's better to get some meaningfull
  messages ( the URLs ), and be able to debug the rest of the app. Otherwise  - you
  just get a stack trace.
  
  I think we should also switch to the StringManager in util, it has few more tricks.
  ResourceBundle is a very tricky class wrt class loaders
  
  Revision  Changes    Path
  1.2       +19 -4     jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/StringManager.java
  
  Index: StringManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/StringManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StringManager.java	18 Jul 2002 16:47:43 -0000	1.1
  +++ StringManager.java	5 Apr 2003 04:10:34 -0000	1.2
  @@ -69,6 +69,7 @@
   import java.util.Locale;
   import java.util.MissingResourceException;
   import java.util.ResourceBundle;
  +import java.net.URLClassLoader;
   
   /**
    * An internationalization / localization helper class which reduces
  @@ -112,7 +113,18 @@
   
       private StringManager(String packageName) {
           String bundleName = packageName + ".LocalStrings";
  -        bundle = ResourceBundle.getBundle(bundleName);
  +        try {
  +            bundle = ResourceBundle.getBundle(bundleName);
  +            return;
  +        } catch( MissingResourceException ex ) {
  +            ClassLoader cl=this.getClass().getClassLoader();
  +
  +            System.out.println("Can't find resource " + bundleName +
  +                    " " + cl);
  +            if( cl instanceof URLClassLoader ) {
  +                System.out.println( ((URLClassLoader)cl).getURLs());
  +            }
  +        }
       }
   
       /**
  @@ -130,6 +142,8 @@
   
           String str = null;
   
  +        if( bundle==null )
  +            return key;
           try {
               str = bundle.getString(key);
           } catch (MissingResourceException mre) {
  @@ -256,6 +270,7 @@
   
       public synchronized static StringManager getManager(String packageName) {
           StringManager mgr = (StringManager)managers.get(packageName);
  +
           if (mgr == null) {
               mgr = new StringManager(packageName);
               managers.put(packageName, mgr);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message