donaldp 01/12/29 14:11:11
Modified: src/java/org/apache/avalon/excalibur/i18n
ResourceManager.java
Log:
When requesting a Resources object for a specific class/package it is likely
that the resources will be loaded from same ClassLoader as specified
class/package.
As it stands now this will fail if the resources are loaded when
ContextClassLoader is not set to a class that can access passed in class. This
is common when you have a component call back into container - if container has
not loaded resources and tries to (in context of components callback) then this
will fail.
Revision Changes Path
1.11 +21 -8
jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/i18n/ResourceManager.java
Index: ResourceManager.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/i18n/ResourceManager.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- ResourceManager.java 12 Dec 2001 12:30:26 -0000 1.10
+++ ResourceManager.java 29 Dec 2001 22:11:11 -0000 1.11
@@ -26,12 +26,25 @@
*/
public final static Resources getBaseResources( final String baseName )
{
+ return getBaseResources( baseName, null );
+ }
+
+ /**
+ * Retrieve resource with specified basename.
+ *
+ * @param baseName the basename
+ * @param classLoader the classLoader to load resources from
+ * @return the Resources
+ */
+ public final static Resources getBaseResources( final String baseName,
+ final ClassLoader
classLoader )
+ {
//TODO: Make these weak references????
Resources packet = (Resources)c_resources.get( baseName );
-
+
if( null == packet )
{
- packet = new Resources( baseName );
+ packet = new Resources( baseName, classLoader );
c_resources.put( baseName, packet );
}
@@ -52,7 +65,7 @@
/**
* Retrieve resource for specified Classes package.
- * The basename is determined by name of classes package
+ * The basename is determined by name of classes package
* postfixed with ".Resources".
*
* @param clazz the Class
@@ -60,12 +73,12 @@
*/
public final static Resources getPackageResources( final Class clazz )
{
- return getBaseResources( getPackageResourcesBaseName( clazz ) );
+ return getBaseResources( getPackageResourcesBaseName( clazz ),
clazz.getClassLoader() );
}
/**
* Retrieve resource for specified Class.
- * The basename is determined by name of Class
+ * The basename is determined by name of Class
* postfixed with "Resources".
*
* @param clazz the Class
@@ -73,12 +86,12 @@
*/
public final static Resources getClassResources( final Class clazz )
{
- return getBaseResources( getClassResourcesBaseName( clazz ) );
+ return getBaseResources( getClassResourcesBaseName( clazz ),
clazz.getClassLoader() );
}
/**
* Retrieve resource basename for specified Classes package.
- * The basename is determined by name of classes package
+ * The basename is determined by name of classes package
* postfixed with ".Resources".
*
* @param clazz the Class
@@ -111,7 +124,7 @@
/**
* Retrieve resource basename for specified Class.
- * The basename is determined by name of Class
+ * The basename is determined by name of Class
* postfixed with "Resources".
*
* @param clazz the Class
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>