<!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;">
    AS 7 Internal Architecture Overview
</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-47970">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><h2>High Level Overview</h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>At a coarse level, AS 7 consists of two main elements:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ul><li>A core manageable service container based on modular classloading</li><li>Extensions to that core that provide the kind of functionality most users associate with an application server, like handling HTTP requests and managing transactions</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The AS distribution also includes two clients for the management interfaces it exposes (a CLI tool and a web-based admin console). The AS codebase also produces implementations of the SPIs published by the Arquillian project, allowing AS7 servers to run Arquillian-based tests.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>AS Core</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The core of the AS consists of the following primary elements:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ul><li>A modular classloading system provided by the jboss-modules library</li><li>A fast, highly scalable service container framework provided by the jboss-msc library</li><li>An extensible management layer that is meant to mediate access to the service container by logic that wants to add, remove and modify services. The management layer also provides a consistent, persistent, configuration model for the AS. The management layer involves<ul><li>core elements, via the jboss-dmr library and the AS's own <span style="font-family: 'courier new', courier;">controller</span>, <span style="font-family: 'courier new', courier;">controller-client</span>, <span style="font-family: 'courier new', courier;">deployment-repository</span>, <span style="font-family: 'courier new', courier;">domain-management</span> and <span style="font-family: 'courier new', courier;">network</span> modules as well as parts of the <span style="font-family: 'courier new', courier;">server</span> module</li><li>remote management capability via the <span style="font-family: 'courier new', courier;">protocol</span> and <span style="font-family: 'courier new', courier;">domain-http</span> modules</li><li>multi-server managed domains via the <span style="font-family: 'courier new', courier;">process-controller</span> and <span style="font-family: 'courier new', courier;">host-controller</span> modules</li><li>miscellaneous elements provided via the <span style="font-family: 'courier new', courier;">managment-client-content</span> and <span style="font-family: 'courier new', courier;">platform-mbean</span> modules</li></ul></li><li>A deployment framework for coordinating installation of deployment content into the runtime. This is one of the things provided by the <span style="font-family: 'courier new', courier;">server</span> module. </li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>AS Extensions</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Most of the functionality that end users associate with an application server is provided AS extensions. Most of the modules in the AS7 codebase are extension implementations, with each extension providing a coherent set of functionality. Many extensions provide support for some aspect of the Java EE specifications.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Extensions implement an interface (<span style="font-family: 'courier new', courier;">org.jboss.as.controller.Extension</span>) that allows integration with the core AS management layer. Via that mechanism, extensions are able to </p><ul><li>participate in the parsing and marshalling of the AS's configuration documents</li><li>register resources and operations to be exposed via the AS's management API</li><li>install services into the AS's service container</li><li>register deployment unit processors with the AS's deployment framework</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>See the "<a class="jive-link-external-small" href="https://docs.jboss.org/author/display/AS72/Extending+JBoss+AS+7">Extending JBoss AS 7</a>" document for more on extensions. See also <a class="jive-link-wiki-small" href="https://community.jboss.org/docs/DOC-25627">https://community.jboss.org/docs/DOC-25627</a> for more on how extending AS 7 differs from extending previous version of JBoss AS.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2>AS7 Boot Process</h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>To better illustrate the AS 7 architecture, let's walk through the boot process for a standalone server.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>Primordial Boot</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When you run bin/standalone.sh from the root of the AS 7 distribution, the final effect is to launch a JVM using the following essential command</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-java">java -jar jboss-modules.jar -mp modules org.jboss.as.standalone
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>If you start the AS and use the <span style="font-family: 'courier new', courier;">ps</span> command to see the actual JVM launch command, you'll see a lot of JVM settings (-Xmx and the like) and a lot of system property settings, but the above bits are the key information. Let's break that down a bit:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'courier new', courier; background-color: #ffffff;">java -jar jboss-modules.jar</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>We can see from this that the actual main class the VM will invoke isn't in a JBoss AS library at all; it's in jboss-modules.jar (the <span style="font-family: 'courier new', courier;">org.jboss.modules.Main</span> class.) So, when you start the AS the first thing you are doing is setting up a modular classloading environment.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'courier new', courier; background-color: #ffffff;">-mp modules</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>These are argument passed to <span style="font-family: 'courier new', courier;">org.jboss.modules.Main.main()</span>. The <span style="font-family: 'courier new', courier;">-mp<span style="font-family: arial, helvetica, sans-serif;"> is short for "module path" and the value is a path analogous to the value of an OS $PATH environment variable. Each item in the path is a location under which jboss-modules will look for a module when needed. If there is more than one item in the path, the items are searched in order, with the search ending as soon as the module is found. In this case there is only one item in the path -- the <span style="font-family: 'courier new', courier;">modules/</span> dir under the AS distribution root.</span></span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'courier new', courier; background-color: #ffffff;">org.jboss.as.standalone</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This is the name of a module located on the module path. This module will be loaded by jboss-modules. If you look in the <span style="font-family: 'courier new', courier;">modules/org/jboss/as/standalone/module.xml</span> file in the AS distribution, you will see it includes this element:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><pre class="jive-pre"><code class="jive-code jive-xml"><span class="jive-xml-tag">&lt;main-class name="org.jboss.as.server.Main"/&gt;</span>
</code></pre><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>When jboss-modules sees that element in the module.xml for the module passed to its main() method, it knows to load the specified class and to pass any remaining command line arguments into <em>its</em> <span style="font-family: 'courier new', courier;">main()</span> method. So, now we have a modular classloading enviroment set up, and the <span style="font-family: 'courier new', courier;">org.jboss.as.server.Main.main()</span> method (found in the AS codebase's <span style="font-family: 'courier new', courier;">server</span> module) has been invoked.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The <span style="font-family: 'courier new', courier;">org.jboss.as.server.Main.main()</span> method does a number of things, but two are most relevant for people who wish to understand how to develop the AS:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ul><li>Any remaining command line arguments are processed and an instance of the <span style="font-family: 'courier new', courier;">ServerEnvironment<span style="font-family: arial, helvetica, sans-serif;"> is created. This object encapsulates environmental information available via the command line or system properties; things like where the root of the AS dist is; where the root of the server instance is; where the configuration file is, etc. Later this information is made available to all services in the system via the <span style="font-family: 'courier new', courier;">ServerEnvironmentService</span>.</span></span></li><li><span style="font-family: arial, helvetica, sans-serif;">An object implementing the <span style="font-family: 'courier new', courier;">Bootstrap</span> interface (specifically, the <span style="font-family: 'courier new', courier;">org.jboss.as.server.BootstrapImpl</span> class) is created&#160; and configured and its <span style="font-family: 'courier new', courier;">bootstrap()</span> method is invoked.</span></li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3><span style="font-family: arial, helvetica, sans-serif;">Service-based Boot</span></h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: arial, helvetica, sans-serif;">The most important thing </span><span style="font-family: 'courier new', courier;">BootstrapImpl</span> does is create an instance of the JBoss MSC library's <span style="font-family: 'courier new', courier;">ServiceContainer</span> interface. A service container manages a set of running services. A service is simply a thing that can be started and stopped, with start and stop performed via methods specified in the JBoss MSC <span style="font-family: 'courier new', courier;">Service</span> interface. A service also exposes a value of some type <span style="font-family: 'courier new', courier;">T</span> via the <span style="font-family: 'courier new', courier;">Service</span> interface's <span style="font-family: 'courier new', courier;">public T getValue()</span> method. The value type <span style="font-family: 'courier new', courier;">T</span> specified by the service is used by default by consumers of the service, and should represent the public interface of the service, which may or may not be the same as the implementing type of the service.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The ServiceContainer provides an API for managing services -- configuring and installing them, removing them, triggering start and stop, looking up already installed services, etc. Configuring a service can involve expressing the dependencies the service has on other services and asking that the service container inject the value of depended-upon services into the service before starting it. If a service depends upon another service, that other service must be successfully started before the service container will invoke the dependent service's <span style="font-family: 'courier new', courier;">start</span> method. If for some reason the depended-upon service needs to be stopped, the service container will invoke the dependent service's <span style="font-family: 'courier new', courier;">stop</span> method first.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The <span style="font-family: 'courier new', courier;">ServiceContainer</span> maintains an internal thread pool. In order to achieve highly performant management of large numbers of inter-related services, activities related to starting and stopping services are performed as a series of concisely scoped tasks, with the threads in the thread pool used to execute those tasks. For example, executing a service's start method would be a task performed by a thread in the <span style="font-family: 'courier new', courier;">ServiceContainer</span>'s thread pool. Because of this fact, <em>it is important to recognize that any activity related to starting and stopping services will be highly multi-threaded. For example, you can never assume that the thread that asks the service container to install a service will be the thread that calls its <span style="font-family: 'courier new', courier;">start</span> method.</em></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So, at this point in our boot, we have in place two of the four main architectural elements discussed in the "AS Core" section above: a modular classloading environment provided by the jboss-modules library, and a service container framework provided by the jboss-msc library.&#160; <em><br/></em></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: arial, helvetica, sans-serif;">Up to this point in theS boot, all activity has been on a single thread, the JVM's <span style="font-family: 'courier new', courier;">main</span> thread. In the <span style="font-family: 'courier new', courier;">BootstrapImpl.bootstrap()</span> method, things get more interesting, since much of the remaining boot work involves installing services, with the ServiceContainer's thread pool threads doing the most of that work.</span></p><p><span style="font-family: arial, helvetica, sans-serif;"><br/></span></p><p><span style="font-family: 'courier new', courier;">BootstrapImpl.bootstrap()</span> installs two services:</p><ul><li><span style="font-family: 'courier new', courier;">ControlledProcessStateService</span>. This service provides access to a simple enum value showing the current running state of the server (STARTING, STOPPING, RUNNING, RESTART_REQUIRED, RELOAD_REQUIRED). This is the only service that once started should not be stopped until the VM is being shut down.</li><li><span style="font-family: 'courier new', courier;">ApplicationServerService</span>. This is the root service for the application server; all other services in one way or another depend upon it. When you use the CLI to perform the <span style="font-family: 'courier new', courier;">:reload</span> operation, the server handles that request by telling the service container to stop this service, which has the effect of stopping all other services that depend upon it. Then once it is stopped, the service container is told to start the service again.</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The A starts a number of other services in its start method. The most significant of these is the <span style="font-family: 'courier new', courier;">ServerService</span>.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h3>The ServerService and the Controller Boot Thread</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: 'courier new', courier;">ServerService</span> brings in the 3rd and 4th of the four primary components of the core AS listed in the "High Level Overview" above -- the extensible management layer and the deployment framework. For those of you familiar with the "<a class="jive-link-external-small" href="https://docs.jboss.org/author/display/AS72/Extending+JBoss+AS+7">Extending JBoss AS 7</a>" document, <span style="font-family: 'courier new', courier;">ServerService</span> performs many of the same kinds of activities an Extension implementation performs in its initialize(ExtensionContext context) method, but for the core AS management model:</p><ul><li>registers resource definitions, attributes definitions and <span style="font-family: 'courier new', courier;">OperationStepHandler</span>s for the core AS managed resources</li><li>registers core <span style="font-family: 'courier new', courier;">DeploymentUnitProcessor</span>s</li></ul><p><span style="font-family: 'courier new', courier;"><br/></span></p><p><span style="font-family: 'courier new', courier;">ServerService</span> implements <span style="font-family: 'courier new', courier;">Service&lt;ModelController&gt;</span>. A <span style="font-family: 'courier new', courier;">ModelController</span> is the central execution point for management operations in a managed AS process (i.e. a server or a HostController in a managed domain.)</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>In its <span style="font-family: 'courier new', courier;">start</span> method, <span style="font-family: 'courier new', courier;">ServerService</span> spawns a separate thread, the "Controller Boot Thread", which is responsible for the coordinating the remainder of the boot. It does the following primary tasks</p><ul><ul><li>Triggers the parsing of the server configuration file (e.g. standalone.xml) into a list of management operations that should be executed by the <span style="font-family: 'courier new', courier;">ModelController</span> to bring the server's running configuration in line with the xml configuration</li><li>Passes those management operations into the <span style="font-family: 'courier new', courier;">ModelController</span>'s <span style="font-family: 'courier new', courier;">execute</span> method. The <span style="font-family: 'courier new', courier;">ModelController</span> uses the Controller Boot Thread to handle execution of many of the steps involved in handling those operations.</li><li>Blocks until all services added into the runtime as part of of handling those management ops have either started or failed to start.</li><li>Logs the completion of boot.</li></ul></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The tasks of the Controller Boot Thread are spelled out in some further detail below.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h4>XML Parsing, Extension Loading, Extension Parsing Initialization</h4><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The task of an XML parser for an AS7 configuration document (e.g. standalone.xml, domain.xml, host.xml) is to populate a list of management operations that should be executed by the <span style="font-family: 'courier new', courier;">ModelController</span> to bring the server's running configuration in line with the xml. Each of those management operations has the same format as would be read off the wire if the CLI had sent an operation request to the server to invoke an equivalent operation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The parser for the core AS xml namespace has some special behavior when it comes to parsing an <span style="font-family: 'courier new', courier;">&lt;extension&gt;</span> element in the xml:</p><ul><li>The <span style="font-family: 'courier new', courier;">name</span> attribute of the element is the name of a JBoss Modules module that contains an implementation of the <span style="font-family: 'courier new', courier;">org.jboss.as.controller.Extension</span> interface</li><li>Once the name is parsed, the parser asks JBoss Modules to load the module</li><li>Once the module is loaded, the j<span style="font-family: 'courier new', courier;">ava.lang.ServiceLoader</span> mechanism is used to load the module's implementation of the <span style="font-family: 'courier new', courier;">Extension</span> interface.</li><li>The <span style="font-family: 'courier new', courier;">initializeParsers(ExtensionParsingContext context)</span> on that <span style="font-family: 'courier new', courier;">Extension</span> implementation is invoked. That allows the extension to register XML parsers for the XML namespaces supported by the subsystems the extension provides.</li><li>When the core AS xml parser subsequently encounters a <span style="font-family: 'courier new', courier;">&lt;subsystem&gt;</span> element in the configuration document, the xml namespace of the element is determined, and the appropriate parser registered by some <span style="font-family: 'courier new', courier;">Extension</span> is used to parse that portion of the document<span style="font-family: 'courier new', courier;">.</span></li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h4>Execution of Boot Management Operations, Extension Initialization</h4><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Once xml parsing is complete, a list of management operations is ready for execution by the <span style="font-family: 'courier new', courier;">ModelController</span>. Each operation has the same format (address, operation name, parameters) as would be read off the wire if the CLI had sent an operation request to the server to invoke an equivalent operation. The Controller Boot Thread asks the <span style="font-family: 'courier new', courier;">ModelController</span> to execute the operations as a unit, with each individual operation acting as a step in the overall unit of work. Execution process in 3 stages, with all steps in the overall unit completing a stage before execution on the next stage begins. (This execution pattern applies whenever any operation or atomic list of operations is invoked, not just during boot.)</p><ul><li>Stage MODEL -- the <span style="font-family: 'courier new', courier;">OperationStepHandler</span> registered for each operation makes necessary updates to the server's internal configuration model, and, if necessary, registers a handler for the same operation for Stage RUNTIME.</li><li>Stage RUNTIME -- any <span style="font-family: 'courier new', courier;">OperationStepHandler</span> registered in Stage MODEL for an operation accesses the JBoss MSC <span style="font-family: 'courier new', courier;">ServiceContainer</span> and installs/removes/updates any relevant services. The <span style="font-family: 'courier new', courier;">ServiceContainer</span> has its own thread pool and uses it to perform the necessary tasks to start and stop services. The thread executing the <span style="font-family: 'courier new', courier;">OperationStepHandler</span> does not do this directly, and the handler implementation needs to recognize that service start/stop will be asynchronous.</li><li>Stage VERIFY -- A Stage.MODEL or Stage.RUNTIME handler can register a Stage.VERIFY handler that will only run once the <span style="font-family: 'courier new', courier;">ServiceContainer</span> had completed all service modifications made in stage RUNTIME. A VERIFY handler can check that the runtime services completed successfully.</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Before the list of boot operations is passed into the <span style="font-family: 'courier new', courier;">ModelController</span>, a check for operations that add extension resources (e.g. using CLI syntax, <span style="font-family: 'courier new', courier;">/extension=org.foo.extension:add</span>) is done. When one is found, the relevant <span style="font-family: 'courier new', courier;">Extension</span> implementation's <span style="font-family: 'courier new', courier;">initialize(ExtensionContext context) </span>method is invoked. This gives the <span style="font-family: 'courier new', courier;">Extension</span> a chance to register its resource and attribute definitions and <span style="font-family: 'courier new', courier;">OperationStepHandler</span>s with the core AS management layer before the boot operations are executed. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h4>Wait for Service Container Stability and Boot Completion</h4><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The final steps in the AS 7 boot are to wait while the JBoss MSC <span style="font-family: 'courier new', courier;">ServiceContainer</span> processes the installation and start of all the services added by the handlers for the boot operations. As discussed in the introduction to the <span style="font-family: 'courier new', courier;">ServiceContainer</span> above, the start of services is performed by threads in the <span style="font-family: 'courier new', courier;">ServiceContainer</span>'s internal thread pool. Services are not started by the Controller Boot Thread. However, the ServerService attaches a listener to the controller object for each service; using this the <span style="font-family: 'courier new', courier;">ServerService</span> is able to track when all services have reached a stable state. The Controller Boot Thread uses this facility to block until the <span style="font-family: 'courier new', courier;">ServiceContainer</span> has stabilized. At that point, all services are either started or failed, and boot is nearly complete. The Controller Boot Thread switches the state of the ControlledProcessState service from STARTING to RUNNING, write a log message reporting that the boot is complete, and boot is finished.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h2><span style="font-family: arial, helvetica, sans-serif;">Deployment Processing</span></h2><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-family: arial, helvetica, sans-serif;">When you trigger deployment of some content, one of the management operations supported by the core AS management layer is invoked. The logic responsible for handling that operation will extract relevant information from the operation request (e.g. the name of the deployment) and will then install services into the AS's service container:</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ul><li><span style="font-family: arial, helvetica, sans-serif;">A <span style="font-family: 'courier new', courier;">Service&lt;VirtualFile&gt;</span> implementation that provides an <span style="font-family: 'courier new', courier;">org.jboss.vfs.VirtualFile<span style="font-family: arial, helvetica, sans-serif;"> that represents the deployment content.</span></span><br/></span></li><li><span style="font-family: arial, helvetica, sans-serif;">A <span style="font-family: 'courier new', courier;">Service&lt;DeploymentUnit&gt;</span> (in this case <span style="font-family: 'courier new', courier;">RootDeploymentUnitService</span>) that provides a <span style="font-family: 'courier new', courier;">DeploymentUnit</span> for the deployment. A DeploymentUnit </span>retains data which is persistent for the life of the deployment, and is the object that will later be passed into the various <span style="font-family: 'courier new', courier;">DeploymentUnitProcessor</span> implementations that perform various actions to install the runtime services needed by the deployment.</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The <span style="font-family: 'courier new', courier;">RootDeploymentUnitService</span> has injected into it a reference to all the <span style="font-family: 'courier new', courier;">DeploymentUnitProcessor</span> (DUP) implementations that were registered by the core <span style="font-family: 'courier new', courier;">ServerService</span> at boot or that have been registered by subsystems. The DUP implementations are grouped by the <span style="font-family: 'courier new', courier;">Phase</span> of the deployment process in which they execute, and are numerically ordered within that phase.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Deployment proceeds in phases. See the <a class="jive-link-external-small" href="https://github.com/jbossas/jboss-as/blob/master/server/src/main/java/org/jboss/as/server/deployment/Phase.java"><span style="font-family: 'courier new', courier;">Phase</span> enum</a> for a listing of the phases. For each phase, there is a <span style="font-family: 'courier new', courier;">DeploymentUnitPhaseService</span> representing that phase that is installed into the service container. Each phase service (save the first) depends on the phase service for the previous phase, and each phase service (save the last) in its <span style="font-family: 'courier new', courier;">start</span> method installs the phase service for the next phase. The <span style="font-family: 'courier new', courier;">RootDeploymentUnitService</span> in its <span style="font-family: 'courier new', courier;">start</span> method installs the first phase service, which in turn depends on it the <span style="font-family: 'courier new', courier;">RootDeploymentUnitService</span>. The effect of all this is if the <span style="font-family: 'courier new', courier;">RootDeploymentUnitService</span> is stopped (e.g. by the <span style="font-family: 'courier new', courier;">undeploy</span> management operation), this will trigger a requirement for the service container to first stop the first phase service, which will in turn trigger a requirement to first stop the next phase service, and so on all the way to the final phase service. The effect is the phase services will be stopped in reverse order from how they were started.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The primary thing the phase services do in their <span style="font-family: 'courier new', courier;">start</span> and <span style="font-family: 'courier new', courier;">stop</span> methods is invoke the <span style="font-family: 'courier new', courier;">deploy</span> and <span style="font-family: 'courier new', courier;">undeploy</span> methods of each <span style="font-family: 'courier new', courier;">DeploymentUnitProcessor</span> registered for their phase. The <span style="font-family: 'courier new', courier;">deploy</span> method is invoked in phase service <span style="font-family: 'courier new', courier;">start</span> and the <span style="font-family: 'courier new', courier;">undeploy</span> method is invoked in <span style="font-family: 'courier new', courier;">stop</span>. For each deploy/undeploy call the DUP is provided with a <span style="font-family: 'courier new', courier;">DeploymentPhaseContext</span> that provides context to the call and gives the DUP access to the service container, allowing it to install or remove services.</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-47970">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>