[
https://issues.apache.org/jira/browse/MYFACES-3051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12998996#comment-12998996
]
Leonardo Uribe commented on MYFACES-3051:
-----------------------------------------
JK >> I disagree! What if we want to cache the instance per webapp?
Why do you disagree? we need concrete and logical reasons to take decisions. I
invite you to tell us possible use cases to support this behavior.
JK >> Really? The best? It is a really easy fix for us
Remember the code committed does not solve fully the problem.
JK >> (note that the code is already committed - that's not the patch)
The fact that the code was committed does not means the code should be let as
is and we can't revert it.
JK >> and you want to tell all OSGi users to provide their custom
ResourceHandler for MyFaces' internal resources like jsf.js. I'm sorry, but
this is stupid.
I'm not saying that. It is possible to fix the problem with load jsf.js and
oamSubmit.js without use the proposed MyfacesClassloader. I'm objecting the
form, not the content.
It's inevitable OSGi users require to implement some SPI interfaces to make
MyFaces work. Why? because OSGi impose a displine about how to manage
classloader stuff. To make MyFaces work in OSGi it required to implement the
following interfaces:
- ServiceProviderFinder : To look for META-INF/services/[jsf or myfaces
factoryname] files. It is required to override this one, so it can use OSGi
code to look on the bundles.
- AnnotationProvider : To scan annotations
- FaceletConfigResourceProvider : To look for facelets taglib xml files.
- FacesConfigResourceProvider : To look for faces-config xml files.
- FacesConfigurationProvider/FacesConfigurationMerger (optional) : to
consolidate all config information.
- FactoryFinderProvider (soon) : To lookup and create factories.
The default implementation uses utility class method (ClassLoaderUtils and
others), but in some cases like we have on OSGi, those operations are expensive
and will not work correctly, so it is necessary to override them. Other thing
to consider is how OSGi "deploys" a war. There are different plugins (Spring
DM, PAX web extender, Equinox ...) with different config options, and all those
ones requires some customization. I invite you to try to setup one environment
(not the easy Spring DM because you can see there the TCCL hack, try make PAX
work) and you'll have a better idea.
Really all depends on how you configure OSGi and the plugin you use. But we
can't anticipate that, so the best is keep it open, provide the proper SPI
stuff so users can do whatever they want.
JK >> Does that sound acceptable to you?
Look this class:
org.apache.myfaces.shared.util.ClassLoaderExtension
Long time ago, a code was committed to extend the method Class.forName(String
name). Look the method on ClassUtils.classForName(). It think it is better to
add to ClassLoaderExtensions getResource() and getResourceAsStream(). Note that
stuff is used by extscript, so it is well tested and it has a lot of sense to
add there (because is a class loader extension, right?).
> 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
> Assignee: Jakob Korherr
> Attachments: MYFACES-3051-first-draft.patch,
> MYFACES-3051-impl-and-shared-2.patch, MYFACES-3051-impl-and-shared.patch
>
>
> 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