<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="https://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Design of AS7 multi-JSF feature
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="https://community.jboss.org/people/ssilvert">Stan Silvert</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/docs/DOC-47689">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p><span style="font-size: 14pt;"><strong>About multi-JSF</strong></span></p><p>Currently, AS7 ships with two JSF implementations, a JSF 2.1 implementation and a JSF 1.2 implementation.&#160; A web application can select which implementation is used by including a context param in web.xml.&#160; By default, it uses the JSF 2.1 imlementation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>"multi-JSF" allows installation of multiple JSF implementations (and versions) on the same AS7 server.&#160; The goal is to allow use of any JSF implementation (MyFaces or Mojarra) and any version of those implementation from JSF 1.1 all the way up to the experimental JSF 2.2 versions.&#160; This is far superior to the old WAR_BUNDLES_JSF_IMPL method because JSF jars do not need to be bundled with the webapp.&#160; More importantly, "multi-JSF" provides an implementation that is fully integrated with the container.&#160; This means more efficient annotation processing, lifecycle handling, and other integration advantages.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 14pt;"><strong>How it works</strong></span></p><p>The way multi-JSF will work is that for each JSF version, a new slot is created in the modules path under <strong>com.sun.jsf-impl</strong>, <strong>javax.faces.api</strong>, and <strong>org.jboss.as.jsf-injection</strong>.&#160; When the jsf-subsystem is started, it scans the module path to find all the installed JSF implementations.&#160; When the JSF subsystem deploys a web app containing the specified context param, it adds the slotted modules to the deployment.&#160; </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Here is an example of the context param for the latest milestone of Mojarra 2.2:</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;context-param&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;param-name&gt;</span>org.jboss.jbossfaces.JSF_CONFIG_NAME<span class="jive-xml-tag">&lt;/param-name&gt;</span>
&#160;&#160; <span class="jive-xml-tag">&lt;param-value&gt;</span>mojarra-2.2.0-m05<span class="jive-xml-tag">&lt;/param-value&gt;</span>
<span class="jive-xml-tag">&lt;/context-param&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 14pt;"><strong>How a JSF implementation is installed</strong></span></p><p>A single JSF implementation is installed using a <a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-18945">CLI deployment archive</a>.&#160; This archive includes the required jars and module.xml files.&#160; It also includes CLI scripts for installing/uninstalling the JSF impls using the <a class="jive-link-external-small" href="https://issues.jboss.org/browse/AS7-4265">CLI module command</a>.&#160; You execute the installation archive like this:</p><blockquote class="jive-quote"><p>[standalone@localhost:9999 /] deploy &lt;local path to archive&gt;/install-mojarra-2.2.0-m05.cli</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The install script inside the archive looks like this:</p><blockquote class="jive-quote"><p>module add --name=javax.faces.api --slot=mojarra-2.2.0-m05 --resources=jsf-api-2.2.0-m05.jar --module-xml=mojarra-api-module.xml</p><p>module add --name=com.sun.jsf-impl --slot=mojarra-2.2.0-m05 --resources=jsf-impl-2.2.0-m05.jar --module-xml=mojarra-impl-module.xml</p><p>module add --name=org.jboss.as.jsf-injection --slot=mojarra-2.2.0-m05 --resources=jboss-as-jsf-injection-7.2.0.Alpha1-SNAPSHOT.jar --module-xml=injection-module.xml</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 14pt;"><strong>How the CLI deployment archives are created</strong></span></p><p>A CLI deployment archive for a JSF implementation/version is created using a standalone maven project you can <a class="jive-link-external-small" href="https://github.com/ssilvert/jboss-jsf-installer">download from GitHub</a> and run.&#160; To create an archive with the project, you&#160; call it like this:</p><blockquote class="jive-quote"><p>mvn -Djsf-version=2.2.0-m05 -Pmojarra clean assembly:single</p></blockquote><p>This pulls in the JSF resources and creates the install/uninstall scripts.&#160; It is all bundled together in an archive (zip) file that must be manually renamed with a .cli extension.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><strong style="font-size: 14pt;">How to change the default JSF implementation in AS7</strong></p><p>The multi-JSF feature adds two new attributes to the JSF subsystem.&#160; The first, <em>active-jsf-impls</em>, is just a read-only list of the installed JSF implementations.&#160; The second, <em>default-jsf-impl-slot</em>, allows you to change the default JSF implementation.&#160; You just need to issue a write-attribute command and set the value to one of the active impls.&#160; Then restart AS7.</p><p><a href="https://community.jboss.org/servlet/JiveServlet/showImage/102-47689-3-19878/JSF-subsys-attribs.png"><span> https://community.jboss.org/servlet/JiveServlet/downloadImage/102-47689-3-19878/450-187/JSF-subsys-attribs.png </span></a></p><p>Alternatively, you can set this in your configuration file, such as standalone.xml:</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;subsystem xmlns="urn:jboss:domain:jsf:1.0" default-jsf-impl-slot="mojarra-2.2.0-m05"/&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 14pt;"><strong>Demo</strong></span></p><p>I've attached a copy of install-mojarra-2.2.0-m05.cli and install-myfaces-2.1.8.cli.&#160; You can unzip to take a look at it.&#160; You can even deploy it with the latest nightly build of AS7.&#160;&#160; This will let you see how the modules are installed.&#160;&#160; I'm not quite done with updates to the jsf-subsystem, so you can't see multi-jsf in action on a webapp yet.&#160; If you want to try it out though, let me know.&#160; I can upload a working version to my github account.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Comment by <a href="https://community.jboss.org/docs/DOC-47689">going to Community</a></p>

        <p style="margin: 0;">Create a new document in JBoss AS 7 Development at <a href="https://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>