<p>Forwarded from dev list.</p>
<p>Lincoln Baxter III<br>
<a href="http://ocpsoft.com">http://ocpsoft.com</a><br>
<a href="http://scrumshark.com">http://scrumshark.com</a><br>
Keep it simple.</p>
<p><blockquote type="cite">---------- Forwarded message ----------<br>From: &quot;Matthias Berndt&quot; &lt;<a href="mailto:matthias.berndt@systemtrap.net">matthias.berndt@systemtrap.net</a>&gt;<br>Date: Nov 13, 2009 10:01 AM<br>
Subject: [jsr-314-open] Allow multiple taglib.xml files for the same namespace<br>To:  &lt;<a href="mailto:dev@javaserverfaces.dev.java.net">dev@javaserverfaces.dev.java.net</a>&gt;<br><br>Hello,<br>
<br>
first I&#39;d like to explain my intention. The scenario is writing multiple<br>
JSF components being bundled in more than one java archive. Each java<br>
archive has its own taglib.xml descriptor so you can use them<br>
separately. These components belong to the same project or organisation<br>
and should be published within the same namespace. This isn&#39;t possible<br>
with facelets at the moment and is a known issue to facelets. See:<br>
<a href="https://facelets.dev.java.net/issues/show_bug.cgi?id=118" target="_blank">https://facelets.dev.java.net/issues/show_bug.cgi?id=118</a><br>
<br>
To support this scenario I&#39;m aware of 3 possible solutions.<br>
<br>
The first one is merging the needed java archives especially the<br>
taglib.xml. I think this one is bad because the separation between the<br>
component projects is destroyed.<br>
<br>
The second one is merging the taglib definitions while being processed<br>
by FaceletTaglibConfigProcessor#processTagLibrary(). In line 308 a new<br>
TagLibraryImpl is created for every facelet-taglib element. This can be<br>
extended to use an already existing TagLibraryImpl for a specific<br>
namespace. This extension requires about 10 to 15 lines of code. As a<br>
result there will be one TagLibraryImpl for multiple facelet-taglib<br>
elements with the same namespace.<br>
<br>
The third one, my preferd one, is using the existing<br>
CompositeTagLibrary. As a result and in contrast to the second method<br>
each facelet-taglib element will be represented by a TagLibraryImpl and<br>
combined by CompositeTagLibrary. This requires only a minor change. In<br>
FaceletTaglibConfigProcessor#processTagLibrary() in line 318 the created<br>
TagLibraryImpl is added to the compiler. Compiler#addTagLibrary() tests<br>
if the given library is already known to the compiler. Subsequently this<br>
is done by using equals() and hashCode() in AbstractTagLibrary. At the<br>
moment hashCode() is implemented to use nothing except the namespace. If<br>
there are multiple TagLibraryImpl with the same namespace only one will<br>
be included in the compiler. The rest is thrown away. By extending<br>
hashCode() to use this.factories and this.functions in the calculation<br>
multiple TagLibraryImpl with different tags etc. can coexist. IMO it<br>
makes sense by reason taglibs are not equal only because they define the<br>
same namespace.<br>
CompositeTagLibrary handles this very well so no other changes are<br>
required.<br>
<br>
I attached a patch to modify AbstractTagLibrary#hashCode(). The<br>
algorithm is base on Joshua Bloch&#39;s Effective Java. The existing test<br>
cases are not harmed and apologize my self not writing a specific test<br>
case. I don&#39;t like to call it a patch because it&#39;s so stupidly simple,<br>
but I&#39;d be glad if something like it could be shipped with JSF2 to<br>
provide this feature.<br>
<br>
kind regards,<br>
<font color="#888888">Matthias Berndt<br>
</font><br>---------------------------------------------------------------------<br>
To unsubscribe, e-mail: <a href="mailto:dev-unsubscribe@javaserverfaces.dev.java.net">dev-unsubscribe@javaserverfaces.dev.java.net</a><br>
For additional commands, e-mail: <a href="mailto:dev-help@javaserverfaces.dev.java.net">dev-help@javaserverfaces.dev.java.net</a><br></blockquote></p>