Peter Donald wrote:
This just broke clas caching. If you want this you need to use cache keyed to both local and bundle. However in the scenario you are using it I would recomend you backout this change and just instantiate the Resource object directly. The ResourceManager is only intended for use when you want to cache the resources but as you dont really then you should probably not use it.I want the resource object cached but the establishment is directing that the cached resource is established with respect to a particular locale. I don't see how this breaks caching because I want the behaviour of Resource per class. I simply want to override the default establishment of the locale. Please take another look - I think you will find that class caching is working just fine - but I'm interested in any specific issues or respective suggestions you may have.
Steve.
On Mon, 27 Jan 2003 14:14, [EMAIL PROTECTED] wrote:
mcconnell 2003/01/26 19:14:16
Modified: i18n default.properties
i18n/src/java/org/apache/avalon/excalibur/i18n
ResourceManager.java
Log:
Updates to support explicit declaration of a locale to the
ResoureManager.
Revision Changes Path
1.8 +1 -1 jakarta-avalon-excalibur/i18n/default.properties
Index: default.properties
===================================================================
RCS file: /home/cvs/jakarta-avalon-excalibur/i18n/default.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- default.properties 25 Jun 2002 03:19:53 -0000 1.7
+++ default.properties 27 Jan 2003 03:14:16 -0000 1.8
@@ -56,7 +56,7 @@
dist.name = ${name}-${version}
# name of jar file
-jar.name = ${name}-${version}.jar
+jar.name = ${name}-${package-version}.jar
# property indicating directory where all distribution archives are
placed dist.base = distributions
1.18 +29 -1 jakarta-avalon-excalibur/i18n/src/java/org/apache/avalon/excalibur/i18n/Res
ourceManager.java
Index: ResourceManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/i18n/src/java/org/apache/avalon/excalibu
r/i18n/ResourceManager.java,v retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- ResourceManager.java 31 Aug 2002 04:56:08 -0000 1.17
+++ ResourceManager.java 27 Jan 2003 03:14:16 -0000 1.18
@@ -7,6 +7,7 @@
*/
package org.apache.avalon.excalibur.i18n;
+import java.util.Locale;
import java.lang.ref.WeakReference;
import java.util.HashMap;
@@ -45,10 +46,24 @@
public synchronized static final Resources getBaseResources( final
String baseName, final ClassLoader classLoader ) {
+ return getBaseResources( baseName, Locale.getDefault(),
classLoader ); + }
+
+ /**
+ * 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 Locale locale, + final ClassLoader classLoader ) + {
Resources resources = getCachedResource( baseName );
if( null == resources )
{
- resources = new Resources( baseName, classLoader );
+ resources = new Resources( baseName, locale, classLoader );
putCachedResource( baseName, resources );
}
@@ -137,6 +152,19 @@
{
return getBaseResources( getPackageResourcesBaseName( clazz ),
clazz.getClassLoader() ); }
+
+ /**
+ * Retrieve resource for package relative to the specified class and
locale. + *
+ * @param clazz the Class
+ * @param locale the locale
+ * @return the Resources
+ */
+ public static final Resources getPackageResources( final Class
clazz, Locale locale ) + {
+ return getBaseResources( getPackageResourcesBaseName( clazz ),
locale, clazz.getClassLoader() ); + }
+
/**
* Retrieve resource for specified Class.
-- Stephen J. McConnell mailto:[EMAIL PROTECTED] http://www.osm.net --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]