<!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;">
    Primordial Boot Options
</h3>
<span style="margin-bottom: 10px;">
    modified by <a href="https://community.jboss.org/people/brian.stansberry">Brian Stansberry</a> in <i>JBoss AS 7 Development</i> - <a href="https://community.jboss.org/docs/DOC-48264">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>On this page I want to lay out some alternative approaches to altering the AS 7.2 / EAP 6.1 boot to realize the objectives discussed in <a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-47927"><br/>https://community.jboss.org/docs/DOC-47927</a>.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2>Primary goals:</h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ol><li><span>To support the organization of modules as described on </span><a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-47927" target="_blank">https://community.jboss.org/docs/DOC-47927</a><span>, such that the modules that ship with AS 7.2 comprise the "distribution base" discussed on that document.</span></li><li><span>To ensure that when other valid "layered distributions" or "add-on"s install on top of that AS 7.2 distribution base they can place their modules in appropriate locations as described in </span><a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-47927" target="_blank">https://community.jboss.org/docs/DOC-47927</a><span> and don't need to alter the startup scripts in order to have those modules become visible with the proper precedence.</span></li><li><span>To ensure the the $JBOSS_MODULE_PATH environment variable is left available for use by end users and isn't polluted with the various detailed paths discussed on </span><a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-47927" target="_blank">https://community.jboss.org/docs/DOC-47927</a><span>.</span></li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2>Secondary goals:</h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>These are things to consider while working to achieve the primary goal:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ol><li>To eliminate as much as possible standard configuration settings from the startup scripts.</li><li>To organize any remaining script-based standard configuration settings to make them easily usable by tooling.</li><li>To avoid altering the programmatic launch of the AS such that existing tooling that launches the AS will not need to handle AS 7.2 / EAP 6.1 separately from how previous AS 7.1 / EAP 6.0 was handled.</li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Some of the secondary goals may prove contradictory.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2>Current Boot</h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The critical aspects of our existing launch commands can be boiled down to the following for a standalone&#160; server and a managed domain host respectively:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">java -jar jboss-modules.jar -mp modules org.jboss.as.standalone
java -jar jboss-modules.jar -mp modules org.jboss.as.process-controller
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 8pt;">(The real command uses $JBOSS_HOME to create absolute paths. That is omitted in this document for brevity.)</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The main() class invoked by the JVM is a JBoss Modules class in jboss-modules.jar. It reads the -mp command line argument to learn that modules are available under filesystem path "modules". It then loads either the <span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">org.jboss.as.standalone</span> or the <span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">org.jboss.as.process-controller</span> module, finds the class described as the "main" class in that module's module.xml file, loads it and invokes its main() method.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2>Options:</h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The following options for how to do the boot come to mind:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>Specialized "Main" Modules</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This the one that's been focused on recently.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The <span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">org.jboss.as.process-controller</span> and <span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">org.jboss.as.standalone</span> modules remain located as they currently are. They do not get placed in modules/layers/base as is described on the Layered Distributions wiki. As a result, a standard jboss-modules boot module loader can find them.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The code in those modules, however, changes significantly. Essentially it no longer particular concerns itself with those modules do today. Instead, it's sole concern is to figure out the detailed module path as described on the Layered Distributions wiki. It will figure that out and create a ModuleLoader that follows those rules. Using that ModuleLoader it will then load a *different* module located in modules/layers/base, find its main class, load that class and invoke its main() method. That class will execute the logic found in the current main classes.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>An advantage to this is the existing programmatic launch command is completely unchanged.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The disadvantage is we leave modules located directly under modules. These modules have to be handled different from other modules, however. You can't override them in a patch via a different module. Instead the patch tool has to treat them as a bunch miscellaneous files (like it treats jboss-modules.jar.) This is mildly annoying because they are a special case for the patch generation and application tools. Also RPMs for layered products will have to account for these modules separately; they can't just create a simple symlink to the EAP RPM's modules/layers/base to pick up all the base modules.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>With this approach there will likely be at least 3 of these specialized modules directly under modules/ -- <span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">org.jboss.as.standalone</span>, <span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">org.jboss.as.</span>process-controller and a 3rd, e.g <span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">org.jboss.as.</span>boot, that contains the most of the code. The bulk of the code is common between the other two.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>Single Specialized "Main" Modules</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is a variant on the previous approach. The launch command becomes:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">java -jar jboss-modules.jar -mp modules org.jboss.as.boot org.jboss.as.standalone</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The goal here is to reduce the number of specialized "Main" modules to just one -- org.jboss.as.boot. It reads the next argument in the command (e.g. <span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">org.jboss.as.standalone</span>) and uses it to decide what module to invoke.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This makes things a bit less messy in the modules/ dir but at the cost of changing the launch command.</p><h3></h3><h3>Specialized JBoss AS Boot Module Loader</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is the approach that was being followed on the initial work for the patching feature. The command becomes:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code">java -cp jboss-modules.jar:jboss-as-loader.jar -Dboot.module.loader=org.jboss.as.boot.ModuleLoader -jar jboss-modules.jar -mp modules org.jboss.as.standalone
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The AS ships a jar "jboss-as-loader.jar" alongside jboss-modules.jar. The launch command places that jar on the classpath. JBoss Modules uses system property "<span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">boot.module.loader</span>" to discover the classname of the ModuleLoader implementation it should use. The implementation the AS provides understands all the rules in the Layered Distributions wiki.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The downsides are an extra file in the root of the AS distribution and a change in the launch command.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>New Main Class</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The AS stops using JBoss Modules as its main class. Instead we create our own main class, which does preliminary setup work and then calls JBoss Modules' main() class.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The launch command becomes:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">java -cp jboss-modules.jar:jboss-as-boot.jar -jar jboss-as-boot.jar -mp </span><span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">modules org.jboss.as.standalone</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: arial, helvetica, sans-serif; background-color: #ffffff;">Again, the downsides are an extra file in the root of the AS distribution and a change in the launch command.</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: arial, helvetica, sans-serif; background-color: #ffffff;"><span>A positive to this is the new main class can take over some processing that's currently done in the scripts. For example, including org.jboss.byteman in system property jboss.modules.system.pkgs. Also the -P processing requested at </span><a class="jive-link-external-small" href="https://issues.jboss.org/browse/MODULES-117" target="_blank">https://issues.jboss.org/browse/MODULES-117</a><span> could be done without requiring it to be added into jboss-modules itself.</span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3><span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;"><span style="font-family: arial, helvetica, sans-serif;">New Main Class with Shading</span><br/></span></h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is the same as the "New Main Class" approach, except we shade jboss-modules.jar into jboss-as-boot.jar in order to eliminate a jar. Launch command becomes:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">java -jar jboss-as-boot.jar -mp </span><span style="font-family: 'Lucida Grande', Arial, Helvetica, sans-serif; background-color: #ffffff;">modules org.jboss.as.standalone</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: arial, helvetica, sans-serif; background-color: #ffffff;">Still a change in launch command though. The only way to get around the change in the launch command would be to call this shaded jar "jboss-modules.jar" which would be very, very ugly.</span></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-48264">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>