Leif:
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/ ?
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.
Cheers, Steve.
[EMAIL PROTECTED] 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--
|------------------------------------------------| | Magic by Merlin | | Production by Avalon | | | | http://avalon.apache.org/merlin | | http://dpml.net/merlin/distributions/latest | |------------------------------------------------|
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
