Enhancements to the MainDeployer SuffixOrder mechanism
Note that this applies to versions starting with 4.0.1
The Case
For the motivation, see the
forums. The point is
to allow deployers to dynamically add their suffixes (e.g. "aop") to the
MainDeployer's and the Scanners DeploymentSorter.
We build on this case in order to provide for:
The externalization of all SuffixOrder configuration info
The automatic addition/removal of Suffixes in the correct order
The overriding of SuffixOrder through the MainDeployer, if needed.
The Changes
SubDeployers
The SubDeployer interface and the supporting base class SubDeployerSupport
have two extra read/write attributes, inherited to all SubDeployers:
Suffixes (String{FOOTNOTE DEF }) - used to specify the suffixes of interest to
a particular SubDeployer, e.g. for AspectDeployer it is "aop" & "aop.xml"
RelativeOrder (int) - used to assign an arbitrary relative order value
to the above suffixes, e.g. for AspectDeployer we chose a default
value of "100".
The RelativeOrder is just a way to order the SubDeployer suffixes
in the server's DeploymentSorter used by the MainDeployer and the
Scanner. Their suffixes are sorted according to their relative order
value when their are added to the master SuffixOrder list.
So a suffix with a relative order "100" is added before
a suffix with a relative order "101" or higher, but after any
existing suffix of value "100" or lower.
The SubDeployers don't need to do anything else (like set the
MainDeployer's SuffixOrder as before), apart from optionally
specifying a sensible initial value for those 2 attributes
(e.g. inside a default constructor).
I've already done so the following SubDeployers in the sense that
those are the most likely to be dynamically added or removed from
a running server:
AspectDeployer - "aop", "aop.xml", relative order: 100
HARDeployer - "har", relative order:400
EJB3Deployer, "ejb3", relative order:500
BeanShellSubDeployer, "bsh", relative order:800
MainDeployer
The MainDeployer maintains its SuffixOrder (String{FOOTNOTE DEF }) attribute as before,
although the attribute is now read-only and it reflects at any given point
the master suffix order list used by the MainDeployer and the Scanner.
The SuffixOrder attribute gets its initial value from a new
EnhancedSuffixOrder (String{FOOTNOTE DEF }, read/write) attribute that can be set
in ./conf/xmdesc/org.jboss.deployment.MainDeployer-xmbean.xml.
The implicit initial value of this attribute, is:
"100:deployer,100:deployer.xml,200:sar,200:service.xml,300:rar,
300:ds.xml,500:jar,600:war,600:wsr,600:ear,700:zip,900:last"
It basically provides a fixed SuffixOrder list, enhanced with
relative order values for each suffix. Those values cannot change
from registering SubDeployers.
Whenever a SubDeployer registers with the MainDeployer, the latter will
query its Suffixes and RelativeOrder attributes, and if they are set
(e.g. "aop", "aop.xml", 100) the MainDeployer will update the SuffixOrder
value with the new suffixes in the correct order, unless the suffixes
are already in the SuffixOrder array, in which case they are ignored.
Upon deregistration of a SubDeployer, it's suffixes are removed,
unless they were specified in the initial EnhancedSuffixOrder setting
(which means they are fixed).
The choise of relative order values is arbitrary, however, using the above
setting we essentially achieve the same SuffixOrder as before, only
in a more dynamic and configurable way.
Referenced by:
Comments