JSF2: How are the *.taglib.xml files discovered in jsf-impl.jar?
Asked Answered
A

1

4

In jsf-impl.jar (which can be found on mvnrepository.com), the *.taglib.xml files are located in directory com/sun/faces/metadata/taglib/.

I don't understand how they're discovered in this case, because chapter 10.3.2 of the JSF 2 specification says:

10.3.2 Facelet Tag Library mechanism

...

The run time must support two modes of discovery for Facelet tag library descriptors

  • Via declaration in the web.xml, as specified in Section 11.1.3 “Application Configuration Parameters”

  • Via auto discovery by placing the tag library descriptor file within a jar on the web application classpath, naming the file so that it ends with “.taglib.xml”, without the quotes, and placing the file in the META-INF directory in the jar file.

...

Here, they're not located in directory META-INF, so how does it work?

Note: in META-INF, they are some .tld files, but I'm not interested in them since I'm not using JSP as the view, but Facelets.

Arrest answered 26/9, 2013 at 11:56 Comment(0)
T
4

It isn't using the taglib.xml for that. It's programmatically registering them via com.sun.faces.facelets.tag.jsf.html.HtmlLibrary in com.sun.faces.application.ApplicationAssociate which is executed during startup. Here are the relevant lines from Mojarra 2.2.1 (copypasted from Grepcode):

954        c.addTagLibrary(new CoreLibrary());
955        c.addTagLibrary(new CoreLibrary(CoreLibrary.XMLNSNamespace));
956        c.addTagLibrary(new HtmlLibrary());
957        c.addTagLibrary(new HtmlLibrary(HtmlLibrary.XMLNSNamespace));
958        c.addTagLibrary(new UILibrary());
959        c.addTagLibrary(new UILibrary(UILibrary.XMLNSNamespace));
960        c.addTagLibrary(new JstlCoreLibrary());
961        c.addTagLibrary(new JstlCoreLibrary(JstlCoreLibrary.IncorrectNamespace));
962        c.addTagLibrary(new JstlCoreLibrary(JstlCoreLibrary.XMLNSNamespace));
963        c.addTagLibrary(new PassThroughAttributeLibrary());
964        c.addTagLibrary(new PassThroughElementLibrary());
965        c.addTagLibrary(new FunctionLibrary(JstlFunction.class, FunctionLibrary.Namespace));
966        c.addTagLibrary(new FunctionLibrary(JstlFunction.class, FunctionLibrary.XMLNSNamespace));
967        if (isDevModeEnabled()) {
968            c.addTagLibrary(new FunctionLibrary(DevTools.class, DevTools.Namespace));
969            c.addTagLibrary(new FunctionLibrary(DevTools.class, DevTools.NewNamespace));
970        }
971        c.addTagLibrary(new CompositeLibrary());
972        c.addTagLibrary(new CompositeLibrary(CompositeLibrary.XMLNSNamespace));
Terris answered 26/9, 2013 at 15:25 Comment(2)
Do you know if there's a reason for doing this programmatically, rather than using the taglib.xml?Chrysalid
The reason is because it's a container-JAR, not an user-JAR. The taglib.xml works only for user-provided JARs in /WEB-INF/lib.Terris

© 2022 - 2024 — McMap. All rights reserved.