Specification of assembly.xml

The Assembly File

The assembly.xml file defines how to assemble the application. It defines the blocks that make up the application, and how to connect them together. It also defines the application listeners to include in the application.

In previous versions of Phoenix, configuration data was also stored in the assembly file. This is no longer the case; Configuration is now stored in a separate Configuration File.

The root element of the assembly file must be an <assembly> element. The root element must contain a child element for each block and application listener which is part of the application. These elements are described below.

The <block> Element

The <block> element defines a block, and how to provide services to the block. The <block> element takes the following attributes:

AttributeDescription
class The fully-qualified name of the block's implementing class. This class must be public, with a public no-args constructor. There must be a corresponding BlockInfo file for the class.
name A unique name for the block. This name is used to refer to the block in other parts of the assembly file, and in the configuration file. The block name may only contain letters, digits, '-' and '.'.

The <provide> Element

The <provide> element defines how to provide a particular service to the block. It connects the block to another block that provides the required service. There must be at least one <provide> element for each dependency listed in the block's BlockInfo file. For array and mapped services, there may be more than one <provide> element for each dependency. The <provide> element takes the following attributes:

AttributeDescription
alias The key to use for the service, for mapped services. Defaults to the value of the name attribute.
name The name of the block to use to provide the service to the target block. This must refer to another block in the same application.
role The role of the service. This must refer to one of the dependencies listed in the block's BlockInfo file. The service name and version specified by the dependency must match one of the services listed in the provider block's BlockInfo file.

The <proxy> Element

The <proxy> element controls whether Phoenix will wrap the block with a proxy object before supplying it to other blocks. The <proxy> element takes the following attributes:

AttributeDescription
disable Disables the use of a proxy object. Default is false.

The <listener> Element

The <listener> element defines an application listener. The <listener> element takes the following attributes:

AttributeDescription
class The fully qualified name of the listener class. This class must be public and provide a public no-args constructor. It must implement the org.apache.avalon.phoenix.ApplicationListener interface.
name A unique name for the listener, which is used to refer to the listener in the configuration file. The name may only contain letters, digits, '-' and '.'.

The <block-listener> Element (Deprecated)

The <block-listener> element defines a block listener. Note that the use of block listeners is deprecated. The <block-listener> element takes the same attributes as the <listener> element.

Sample Assembly File

Below is an example assembly file. It defines 2 blocks, called myAuthorizer and myBlock, and a listener. Block myBlock uses the Authorizer service provided by block myAuthorizer.


<?xml version="1.0"?>

<assembly>

    <block name="myAuthorizer"
           class="com.biz.cornerstone.blocks.MyAuthorizer">
    </block>

    <block name="myBlock"
           class="com.biz.cornerstone.blocks.MyBlock">
        <provide name="myAuthorizer"
                 role="com.biz.cornerstone.services.Authorizer"/>
    </block>

    <listener name="myListener"
              class="com.biz.cornerstone.listeners.MyListener">
    </listener>

</assembly>
            
by Peter Donald