Done in rev 898648. Thanks for pointing that out - I didn't think anyone would 
be using those methods.

Background info for anyone who might be interested:

At the 2007 Developers Conference, it was mentioned that clearing caches in 
OFBiz didn't clear the UI labels. The only way to see changes in UI labels 
files was to restart OFBiz. David Jones mentioned we would have to write our 
own ResourceBundle class to have the ability to reload UI labels. I filed that 
suggestion in my head and saved it for later.

Months later David suggested using XML files and the xml:lang attribute to 
store UI label files. I offered to develop that idea and decided to address the 
UI label caching issue at the same time.

I spent time researching the subject and learned that Sun had made the 
ResourceBundle more flexible in version 6. Some of the issues we were facing 
would be solved in Java 6, but we were sticking to Java 5 at the time.

So, in the process of implementing the OFBiz custom XML file format and caching 
UI label files, I added methods and classes to UtilProperties.java that mimic 
the Java 6 classes in anticipation of the project switching to it someday. It 
never occurred to me that users would use those methods.

-Adrian


--- On Tue, 1/12/10, Adrian Crum <[email protected]> wrote:

> From: Adrian Crum <[email protected]>
> Subject: Re: svn commit: r898338 - 
> /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
> To: [email protected]
> Date: Tuesday, January 12, 2010, 8:16 PM
> Those public methods were created in
> anticipation of the Java 6 classes that will replace them. I
> can put them back and deprecate them instead.
> 
> -Adrian
> 
> 
> --- On Tue, 1/12/10, Adam Heath <[email protected]>
> wrote:
> 
> > From: Adam Heath <[email protected]>
> > Subject: Re: svn commit: r898338 -
> /ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
> > To: [email protected]
> > Date: Tuesday, January 12, 2010, 5:17 PM
> > [email protected]
> > wrote:
> > > Author: adrianc
> > > Date: Tue Jan 12 14:24:36 2010
> > > New Revision: 898338
> > > 
> > > URL: http://svn.apache.org/viewvc?rev=898338&view=rev
> > > Log:
> > > First pass at converting UtilProperties.java to
> Java
> > 6, plus some small code cleanups.
> > 
> > Where exactly is the 1.6 syntax you are using?  It's
> > not in making
> > more class fields static.  It's not in removing the
> > public methods(you
> > may have broken external code, please add the public
> static
> > methods
> > back).  It's not in removing the DCL pattern.
> > 
> > > 
> > > Modified:
> > > 
> >
>    ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
> > > 
> > > Modified:
> >
> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
> > > URL: 
> > > http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java?rev=898338&r1=898337&r2=898338&view=diff
> > >
> >
> ==============================================================================
> > > ---
> >
> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
> > (original)
> > > +++
> >
> ofbiz/trunk/framework/base/src/org/ofbiz/base/util/UtilProperties.java
> > Tue Jan 12 14:24:36 2010
> > > @@ -57,26 +57,20 @@
> > >   * (see the <a
> >
> href="#xmlToProperties(java.io.InputStream,%20java.util.Locale,%20java.util.Properties)">xmlToProperties</a>
> > >   * method).</p>
> > >   */
> > > -...@suppresswarnings("serial")
> > > -public class UtilProperties implements
> > java.io.Serializable {
> > > +public class UtilProperties {
> > >  
> > >      public static final String module
> > = UtilProperties.class.getName();
> > > -
> > >      /** An instance of the generic
> > cache for storing the non-locale-specific properties.
> > >       *  Each Properties
> > instance is keyed by the resource String.
> > >       */
> > > -    protected static UtilCache<String,
> > Properties> resourceCache =
> >
> UtilCache.createUtilCache("properties.UtilPropertiesResourceCache");
> > > -
> > > +    protected static final
> > UtilCache<String, Properties> resourceCache =
> >
> UtilCache.createUtilCache("properties.UtilPropertiesResourceCache");
> > >      /** An instance of the generic
> > cache for storing the non-locale-specific properties.
> > >       *  Each Properties
> > instance is keyed by the file's URL.
> > >       */
> > > -    protected static UtilCache<String,
> > Properties> urlCache =
> >
> UtilCache.createUtilCache("properties.UtilPropertiesUrlCache");
> > > -
> > > -    public static final Locale LOCALE_ROOT
> > = new Locale("", "", "");
> > > -
> > > -    protected static Locale fallbackLocale
> > = null;
> > > -    protected static Set<Locale>
> > defaultCandidateLocales = null;
> > > -    protected static Set<String>
> > propertiesNotFound = FastSet.newInstance();
> > > +    protected static final
> > UtilCache<String, Properties> urlCache =
> >
> UtilCache.createUtilCache("properties.UtilPropertiesUrlCache");
> > > +    protected static final
> > Set<String> propertiesNotFound =
> > FastSet.newInstance();
> > > +    protected static final Locale
> > fallbackLocale = createFallbackLocale();
> > > +    protected static final
> > Set<Locale> defaultCandidateLocales =
> > createDefaultCandidateLocales();
> > >  
> > >      /** Compares the specified
> > property to the compareString, returns true if they
> are the
> > same, false otherwise
> > >       * @param resource The
> > name of the resource - if the properties file is
> > 'webevent.properties', the resource name is
> 'webevent'
> > > @@ -606,21 +600,16 @@
> > >       *
> > <code>general.properties</code>.
> > >       * @return The
> > configured fallback locale
> > >       */
> > > -    public static Locale
> > getFallbackLocale() {
> > > -        if (fallbackLocale ==
> > null) {
> > > -           
> > synchronized (UtilProperties.class) {
> > > -             
> >   if (fallbackLocale == null) {
> > > -             
> >       String locale =
> > getPropertyValue("general",
> "locale.properties.fallback");
> > > -             
> >       if (UtilValidate.isNotEmpty(locale)) {
> > > -             
> >           fallbackLocale =
> > UtilMisc.parseLocale(locale);
> > > -             
> >       }
> > > -             
> >       if (fallbackLocale == null) {
> > > -             
> >           fallbackLocale =
> > UtilMisc.parseLocale("en");
> > > -             
> >       }
> > > -             
> >   }
> > > -            }
> > > +    protected static Locale
> > createFallbackLocale() {
> > > +        String locale =
> > getPropertyValue("general",
> "locale.properties.fallback");
> > > +        Locale result = null;
> > > +        if
> > (UtilValidate.isNotEmpty(locale)) {
> > > +            result =
> > UtilMisc.parseLocale(locale);
> > > +        }
> > > +        if (result == null) {
> > > +            result =
> > UtilMisc.parseLocale("en");
> > >          }
> > > -        return fallbackLocale;
> > > +        return result;
> > >      }
> > >  
> > >      /** Converts a Locale instance to
> > a candidate Locale list. The list
> > > @@ -647,19 +636,12 @@
> > >       * the
> > <code>LOCALE_ROOT</code> (empty) locale -
> in
> > that order.
> > >       * @return A list of
> > default candidate locales.
> > >       */
> > > -    public static Set<Locale>
> > getDefaultCandidateLocales() {
> > > -        if
> > (defaultCandidateLocales == null) {
> > > -           
> > synchronized (UtilProperties.class) {
> > > -             
> >   if (defaultCandidateLocales == null) {
> > > -             
> >       defaultCandidateLocales =
> > FastSet.newInstance();
> > > -             
> >      
> >
> defaultCandidateLocales.addAll(localeToCandidateList(Locale.getDefault()));
> > > -             
> >       // Change to Locale.ROOT in Java 6
> > > -             
> >      
> > defaultCandidateLocales.add(LOCALE_ROOT);
> > > -             
> >      
> >
> defaultCandidateLocales.addAll(localeToCandidateList(getFallbackLocale()));
> > > -             
> >   }
> > > -            }
> > > -        }
> > > -        return
> > defaultCandidateLocales;
> > > +    protected static Set<Locale>
> > createDefaultCandidateLocales() {
> > > +        Set<Locale> result
> > = FastSet.newInstance();
> > > +       
> >
> result.addAll(localeToCandidateList(Locale.getDefault()));
> > > +       
> > result.addAll(localeToCandidateList(fallbackLocale));
> > > +        result.add(Locale.ROOT);
> > > +        return result;
> > 
> > You changed the position that ROOT gets added.
> > 
> > Additionally, you should have done this as multiple
> > commits, changing
> > LOCALE_ROOT local variable to Locale.ROOT, then
> changing
> > the method
> > implementations.
> > 
> > 
> > >      }
> > >  
> > >      /** Returns a list of candidate
> > locales based on a supplied locale.
> > > @@ -671,12 +653,12 @@
> > >       */
> > >      public static List<Locale>
> > getCandidateLocales(Locale locale) {
> > >          // Java 6
> > conformance
> > > -        if
> > (LOCALE_ROOT.equals(locale)) {
> > > +        if
> > (Locale.ROOT.equals(locale)) {
> > >              return
> > UtilMisc.toList(locale);
> > >          }
> > >          Set<Locale>
> > localeSet = FastSet.newInstance();
> > >         
> > localeSet.addAll(localeToCandidateList(locale));
> > > -       
> > localeSet.addAll(getDefaultCandidateLocales());
> > > +       
> > localeSet.addAll(defaultCandidateLocales);
> > >          List<Locale>
> > localeList = FastList.newInstance();
> > >         
> > localeList.addAll(localeSet);
> > >          return localeList;
> > > 
> > > 
> > 
> > 
> 
> 
> 
> 



Reply via email to