[ 
https://issues.apache.org/jira/browse/MYFACES-3051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12997739#comment-12997739
 ] 

Jakob Korherr commented on MYFACES-3051:
----------------------------------------

This method from ResourceHandlerImpl is a perfect example for the ClassLoader 
mechansim I am describing:

    private static ResourceBundle getBundle(FacesContext facesContext, Locale 
locale, String bundleName)
    {
        try
        {
            // First we try the JSF implementation class loader
            return ResourceBundle.getBundle(bundleName, locale, 
ResourceHandlerImpl.class.getClassLoader());
        }
        catch (MissingResourceException ignore1)
        {
            try
            {
                // Next we try the JSF API class loader
                return ResourceBundle.getBundle(bundleName, locale, 
ResourceHandler.class.getClassLoader());
            }
            catch (MissingResourceException ignore2)
            {
                try
                {
                    // Last resort is the context class loader
                    return ResourceBundle.getBundle(bundleName, locale, 
ClassUtils.getContextClassLoader());
                }
                catch (MissingResourceException damned)
                {
                    return null;
                }
            }
        }
    }

> Use multiple ClassLoaders to find resources (not only ContextClassLoader)
> -------------------------------------------------------------------------
>
>                 Key: MYFACES-3051
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3051
>             Project: MyFaces Core
>          Issue Type: Bug
>    Affects Versions: 2.0.4
>         Environment: OSGi
>            Reporter: Jakob Korherr
>
> In most parts of the code we only use the ContextClassLoader to find Classes 
> and Resources. However, in some parts we also use the ClassLoader of the 
> current Class or of a specific Class (e.g. to use myfaces-api and/or 
> myfaces-impl ClassLoader, see ApplicationImpl.getResourceBundle(), 
> BeanValidator.postSetValidationGroups(), ResourceHandlerImpl.getBundle() or 
> FactoryFinder for example).
> IMO we should unify this code and maybe provide a custom ClassLoader that 
> encapsulates three ClassLoaders (ContextClassLoader, myfaces-api and 
> myfaces-impl). This most certainly would solve a lot of OSGi related problems.
> WDYT?

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to