<!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="http://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;">
    Experiments with EJB3 annotation + DD merging in AS7
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/jaikiran">jaikiran pai</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/docs/DOC-16688">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><h4>Purpose:</h4><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This document outlines the issues encountered while trying to implement merging of EJB3 deployment descriptor and annotations for AS 7.0.0.Beta2</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h4>Details:</h4><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h5>Pre-AS7 deployers and metdata merging:</h5><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Typically the way we used to create a merged view of deployment descriptor (DD) values with annotation values involved the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ul><li>2 separate views were maintained during deployment processing. One view corresponding to DD values and the other for annotations</li><li>After a certain point, the 2 views would be merged into one </li><li>After that point, the deployers which required to work on the metadata, would start using the merged view of the metadata</li></ul><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><h5>AS7 Deployment Unit Processors (DUPs):</h5><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The previous mentioned steps would ideally have worked out in the current AS7 DUP framework. However, most (all?) of the EE specific DUPs which work on annotations expect the metadata (== *ComponentDescription) to be available. For example, see the ResourceInjectionAnnotationParsingProcessor. It gets hold of a AbstractComponentDescription and starts looking for annotations on that component class. The AbstractComponentDescription is fetched from the EEModuleDescription and leads to a chicken and egg problem. For example, while working on EJB3 DD + annotation merging, this is what I initially tried:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><ol><li>Various (ordered) EJB DD processing DUPs running first and creating the EJBComponentDescription(s).</li><li>Various (ordered) annotation DUPs running after the DD based DUPs and creating a parallel EJBComponentDescription(s).</li><li>A merging DUP which merges the EJBComponentDescription(s) created in #1 and #2 and then attaching each of these EJBComponentDescriptions to EEModuleDescription.</li><li>Rest of the DUPs then working off the merged EJBComponentDescription(s) by fetching them from the EEModuleDescription.</li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The problem with this approach is that the DUPs like ResourceInjectionAnnotationParsingProcessor which scan for annotations require the EJBComponentDescription to be available in EEModuleDescription for it to fire. Effectively, until #3 is done (the merging of DD + annotations), such DUPs can't fire. However, for #3 (a.k.a merging) to be successfully completed we need the ResourceInjectionAnnotationParsingProcessor and such DUPs to fire. Effectively this leads to a chicken and egg issue.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>There's one other approach which I tried out (with issues of its own), the one which is currently implemented (and broken) in upstream, for merging DD + annotations. That approach was more of a workaround for this main issue and isn't really relevant at this point. However, I can outline that approach here if required (just need to recap some finer details on why it is broken)</p></div>

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

        <p style="margin: 0;">Create a new document in JBoss AS7 Development at <a href="http://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>