W dniu 2011-06-14 11:46, Jakob Korherr pisze:
Hi,
Actually you should not directly use stuff from myfaces-impl (package
org.apache.myfaces.*). Theses classes are implementation specific and
not built for extensions!
If you need some base code, you should copy (or shade) it!
Regards,
Jakob
It is impossible (or only I cannot find a way) to provide my own
FaceletCache in approach that you suggest.
If I want to provide my own implementation of FaceletCache (suppose:
MyFaceletCache) I am also obligated to provide implementation of
Facelet. I cannot use DefaultFacelet class due to the fact that it is
final has package access and is placed in myfaces-impl. So I am creating
MyDefaultFacelet (copy-paste from DefaultFacelet). Now I am bound to
DefaultFaceletContext. Due to the fact that I cannot use
DefaultFaceletContext (the same story: final, package class and placed
in myfaces-impl). So I am creating MyDefaultFaceletContext (copy-paste
from DefaultFaceletContext). Now everything should be ok (despite the
fact that now I am resposible for maintaining code of MyFaceleteCache,
MyDefaultFacelet and MyDefaultFaceletContext. And every [brilliant]
change that will be made I have to recreate in my code).
But it is not working ! Why ? Lets look into constructor of
DefaultFaceletFactory (DefaultFaceletFactory(Compiler, ResourceResolver,
long)). Lines 131-134
Method setMemberFactoriesMethod =
FaceletCache.class.getDeclaredMethod("setMemberFactories", new
Class[]{FaceletCache.MemberFactory.class,
FaceletCache.MemberFactory.class});
setMemberFactoriesMethod.setAccessible(true);
setMemberFactoriesMethod.invoke(_faceletCache, faceletFactory,
viewMetadataFaceletFactory);
faceletFactory and viewMetadataFaceletFactory are created in those
constructor and are bound to those class.
This lines makes that my FaceletCache (MyFaceletCache) is bound to
DefaultFaceletFactory, so in fact I am bound to DefaultFacelet. So how I
can provide my own FaceletCache that is not bound to DefaultFacelet ?
Of course normally if I could put MyFaceletCache in
org.apache.myfaces.view.facelets.impl package. Now I can implement my
own MyFaceletCache that is extending FaceletCache<DefaultFacelet>.
I am not extending anything but using appropriate implementation of
Facelet. But in OSGi it is impossible to do so. Even if I put my class
in appropriate package, class MyFaceletCache and DefaultFacelet will be
loaded by different ClassLoaders and in fact will not be considered to
be placed in the same package. As a result IllegalAccessError will be
thrown.
The only solution for me, is to make class DefaultFaclet public
(DefaultFacletContext also ?). Will it broke some security or
architectonical assumptions ?
I hope that you can understand what I have written. If not, please
describe whuch part is not clear to you. I will try to describe the
problem in other way.
--
Pozdrawiam,
Kamil Soboń
iso.poczta(at)gmail.com
sobon(at)student.agh.edu.pl