avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leif Mortenson <l...@tanukisoftware.com>
Subject Re: cvs commit: avalon-excalibur/i18n/src/java/org/apache/avalon/excalibur/i18n ResourceManager.java
Date Mon, 19 Apr 2004 00:03:39 GMT
Stephen,
Stephen McConnell wrote:

> Just looking quickly over the cvs commit message - it seems to me that 
> there is at least one change which would break backward compatibility 
> (namely the addition of an parameter to the static public method 
> getBaseResource when compared to the released product signature). Can 
> this be corrected so the changes remain backward compatible with 1.2 
> as detailed under http://avalon.apache.org/excalibur/api/ ?

Thanks for thinking about compatibility.  The CVS diff looks like there 
is a problem
at first glance, but if you look lower, I made sure that all of the old 
public methods are
preserved.   The original method now does the following:

    public synchronized static final Resources getBaseResources( final 
String baseName,
                                                                 final 
ClassLoader classLoader )
    {
        return getBaseResources( baseName, null, classLoader );
    }

This is true with all of the other public methods as well.  There should 
be no
problems here.

> Second item - the addition of new public operations should also result 
> in the bumping of the project version from 1.2 to 1.3.0-dev.

I looked up on ibiblio and the avalon download page.  The latest release 
appeared
to have been 1.1?  I can up this to 1.3.0-dev if that is the correct 
thing to have done.
But it appeared that the version had already been bumped.

http://www.meisei-u.ac.jp/mirror/apache/dist/avalon/excalibur-i18n/jars/

Cheers,
Leif

> leif@apache.org wrote:
>
>
>>        public synchronized static final Resources getBaseResources( 
>> final String baseName,
>>   +                                                                 
>> final Locale locale,
>>                                                                     
>> final ClassLoader classLoader )
>>        {
>>   -        Resources resources = getCachedResource( baseName );
>>   +        String cacheKey;
>>   +        if ( locale == null )
>>   +        {
>>   +            cacheKey = baseName;
>>   +        }
>>   +        else
>>   +        {
>>   +            cacheKey = baseName + "-" + locale.toString();
>>   +        }
>>   +          +        Resources resources = getCachedResource( 
>> cacheKey );
>>            if( null == resources )
>>            {
>>   -            resources = new Resources( baseName, classLoader );
>>   -            putCachedResource( baseName, resources );
>>   +            if ( locale == null )
>>   +            {
>>   +                resources = new Resources( baseName, classLoader );
>>   +            }
>>   +            else
>>   +            {
>>   +                resources = new Resources( baseName, locale, 
>> classLoader );
>>   +            }
>>   +              +            putCachedResource( cacheKey, resources );
>>            }
>>               return resources;
>>        }
>>           /**
>>   +     * Retrieve resource with specified basename.
>>   +     *
>>   +     * @param baseName the basename
>>   +     * @param classLoader the classLoader to load resources from
>>   +     *
>>   +     * @return the Resources
>>   +     */
>>   +    public synchronized static final Resources getBaseResources( 
>> final String baseName,
>>   +                                                                 
>> final ClassLoader classLoader )
>>   +    {
>>   +        return getBaseResources( baseName, null, classLoader );
>>   +    }
>>   +
>>   +    /**
>>         * Clear the cache of all resources currently loaded into the
>>         * system. This method is useful if you need to dump the complete
>>         * cache and because part of the application is reloading and
>>   @@ -92,26 +128,25 @@
>>        /**
>>         * Cache specified resource in weak reference.
>>         *
>>   -     * @param baseName the resource key
>>   +     * @param cacheKey the key used to reference the resource in 
>> the cache
>>         * @param resources the resources object
>>         */
>>   -    private synchronized static final void putCachedResource( 
>> final String baseName,
>>   +    private synchronized static final void putCachedResource( 
>> final String cacheKey,
>>                                                                  
>> final Resources resources )
>>        {
>>   -        c_resources.put( baseName,
>>   -                         new WeakReference( resources ) );
>>   +        c_resources.put( cacheKey, new WeakReference( resources ) );
>>        }
>>           /**
>>         * Retrieve cached resource.
>>         *
>>   -     * @param baseName the resource key
>>   +     * @param cacheKey the key used to reference the resource in 
>> the cache
>>   +     *
>>         * @return resources the resources object
>>         */
>>   -    private synchronized static final Resources getCachedResource( 
>> final String baseName )
>>   +    private synchronized static final Resources getCachedResource( 
>> final String cacheKey )
>>        {
>>   -        final WeakReference weakReference =
>>   -            (WeakReference)c_resources.get( baseName );
>>   +        final WeakReference weakReference = 
>> (WeakReference)c_resources.get( cacheKey );
>>            if( null == weakReference )
>>            {
>>                return null;
>>   @@ -127,11 +162,42 @@
>>         * The basename is determined by name postfixed with 
>> ".Resources".
>>         *
>>         * @param name the name to use when looking up resources
>>   +     * @param locale Locale of the requested Resources, null 
>> implies default locale
>>   +     *
>>   +     * @return the Resources
>>   +     */
>>   +    public static final Resources getResources( final String name, 
>> final Locale locale )
>>   +    {
>>   +        return getBaseResources( name + ".Resources", locale, null );
>>   +    }
>>   +
>>   +    /**
>>   +     * Retrieve resource for specified name.
>>   +     * The basename is determined by name postfixed with 
>> ".Resources".
>>   +     *
>>   +     * @param name the name to use when looking up resources
>>   +     *
>>         * @return the Resources
>>         */
>>        public static final Resources getResources( final String name )
>>        {
>>   -        return getBaseResources( name + ".Resources" );
>>   +        return getResources( name, null );
>>   +    }
>>   +
>>   +    /**
>>   +     * Retrieve resource for specified Classes package.
>>   +     * The basename is determined by name of classes package
>>   +     * postfixed with ".Resources".
>>   +     *
>>   +     * @param clazz the Class
>>   +     * @param locale Locale of the requested Resources, null 
>> implies default locale
>>   +     *
>>   +     * @return the Resources
>>   +     */
>>   +    public static final Resources getPackageResources( final Class 
>> clazz, final Locale locale )
>>   +    {
>>   +        return getBaseResources(
>>   +            getPackageResourcesBaseName( clazz ), locale, 
>> clazz.getClassLoader() );
>>        }
>>           /**
>>   @@ -140,11 +206,28 @@
>>         * postfixed with ".Resources".
>>         *
>>         * @param clazz the Class
>>   +     *
>>         * @return the Resources
>>         */
>>        public static final Resources getPackageResources( final Class 
>> clazz )
>>        {
>>   -        return getBaseResources( getPackageResourcesBaseName( 
>> clazz ), clazz.getClassLoader() );
>>   +        return getPackageResources( clazz, null );
>>   +    }
>>   +
>>   +    /**
>>   +     * Retrieve resource for specified Class.
>>   +     * The basename is determined by name of Class
>>   +     * postfixed with "Resources".
>>   +     *
>>   +     * @param clazz the Class
>>   +     * @param locale Locale of the requested Resources, null 
>> implies default locale
>>   +     *
>>   +     * @return the Resources
>>   +     */
>>   +    public static final Resources getClassResources( final Class 
>> clazz, final Locale locale )
>>   +    {
>>   +        return getBaseResources(
>>   +            getClassResourcesBaseName( clazz ), locale, 
>> clazz.getClassLoader() );
>>        }
>>           /**
>>   @@ -153,11 +236,12 @@
>>         * postfixed with "Resources".
>>         *
>>         * @param clazz the Class
>>   +     *
>>         * @return the Resources
>>         */
>>        public static final Resources getClassResources( final Class 
>> clazz )
>>        {
>>   -        return getBaseResources( getClassResourcesBaseName( clazz 
>> ), clazz.getClassLoader() );
>>   +        return getClassResources( clazz, null );
>>        }
>>           /**
>>   @@ -166,6 +250,7 @@
>>         * postfixed with ".Resources".
>>         *
>>         * @param clazz the Class
>>   +     *
>>         * @return the resource basename
>>         */
>>        public static final String getPackageResourcesBaseName( final 
>> Class clazz )
>>   @@ -199,6 +284,7 @@
>>         * postfixed with "Resources".
>>         *
>>         * @param clazz the Class
>>   +     *
>>         * @return the resource basename
>>         */
>>        public static final String getClassResourcesBaseName( final 
>> Class clazz )
>>      
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
>> For additional commands, e-mail: cvs-help@avalon.apache.org
>>
>>
>
>


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


Mime
View raw message