<!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">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;">
    XModel in JBoss Tools
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/scabanovich">Viacheslav Kabanovich</a> in <i>JBoss Tools Development</i> - <a href="http://community.jboss.org/docs/DOC-15207">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Some features of JBoss Tools have XModel for their internal model. This model framework was created 8 years but remains undocumented.</p><p>It is time to fill the gap with some notes to be of use to those who might fix issues in or contribute to XModel based features.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Basics for XModel is in plugin org.jboss.tools.common.model. Basic ui components that visualize objects of XModel are in org.jboss.tools.common.model.ui.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The idea of XModel is that one can minimize Java coding by describing any&#160; model object by meta information about its structure and actions that can&#160; be done on it and bind this meta info with common implementation, which&#160; can be customised but in many cases is good by default.<br/>That info is xml&#160; (*.meta) file registered with XModel by extension&#160; point 'org.jboss.tools.common.model.meta'.</p><p><br/>All objects in XModel have&#160; common super interface XModelObject, and even common super class&#160; XModelObjectImpl. But of course, for the sake of</p><p>customization there are&#160; opportunities to override the default implementation.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>For the start, look into *.meta files and make sure that it contains only a&#160; few basic notions. But there are some tricks that make it difficult&#160; to understand without explanations. Just several, for the&#160; beginning:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>1) Entity name convention.<br/>There are no packages and all&#160; entity names must be unique.<br/>It is solved by common prefix for a set of&#160; entities for a project. For <br/>example, all entities for Seam start with&#160; 'Seam'. With one exception: root <br/>entity of file usually starts with 'File',&#160; so root entity for components.xml <br/>starts with 'FileSeam'. That is not the&#160; requirement, but it is conveniency, <br/>which one can use within a project to&#160; filter/find entities by prefix. <br/>Version is provided by digital suffix,&#160; otherwize digits are not welcome in <br/>entity name, e.g. entities&#160; 'FileSeamComponent12', 'FileSeamComponent20' etc. <br/>are for versions 1.2, 2.0,&#160; etc. I regularly use code that assumes such <br/>suffixing to compute version (it&#160; is limited to a project, common features do <br/>not make such&#160; assumptions).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>2). What is "%Regular%" in the next&#160; fragment?<br/>&lt;XModelEntity ImplementingClass="%Regular%"&#160; name="EclipseWorkspace"&gt;<br/>It is quite evident that 'ImplementingClass' is a&#160; java class for XModel <br/>object that implements XModelObject (actually even&#160; always extends <br/>XModelObjectImpl). There are a few standard implementations&#160; and I decided <br/>that it would not do always to type qualified name. So, there&#160; is an idea of <br/>simple mappings with predefined names. Most of them are&#160; introduced in<br/>org.jboss.tools.common.model/resources/meta/base.meta<br/>and&#160; contributed where needed (kind of trivial extension point, invented when&#160; <br/>there were no Eclipse around). In this case it is<br/>&lt;MAPPING&#160; name="Implementations"&gt;<br/>&#160; &lt;PAIR name="Regular"&#160; <br/>value="org.jboss.tools.common.model.impl.RegularObjectImpl"/&gt;<br/>&lt;/MAPPING&gt;<br/>So,&#160; loader of *.meta files looks for either qualified class names or %...%&#160; <br/>expressions, and for 'ImplementingClass' attribute looks into mapping&#160; <br/>'Implementations'.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>3) What are PROPERTIES in the next&#160; fragment?<br/>&lt;XModelAttribute PROPERTIES="id=true;category=general"<br/>&#160;&#160;&#160;&#160; name="component-name" xmlname="name"/&gt;<br/>Actually, this is the most gross&#160; trick in XModel. As I told above, there are <br/>but few basic notions in it, but&#160; one may without limitation add any set of <br/>them by PROPERTIES&#160; attribute.<br/>Being fully aware of the danger of such approach, I introduced new&#160; property <br/>names only when quite necessary and useful.<br/>- Property 'id' is&#160; used by implentation class&#160; <br/>org.jboss.tools.common.model.impl.CustomizedObjectImpl, usually referenced&#160; <br/>%Custom%. It marks attribute as the one which value must be unique in&#160; <br/>parent, and by default that value is used for object's path part and&#160; <br/>presentation (e.g. label in Tree)<br/>- Property 'category' with two values&#160; 'general' and 'advanced' is used to <br/>automatically generate ui editor forms&#160; if no specific form is defined. If <br/>category=advanced, field editor for the&#160; attribute is added to Section <br/>'Advanced', if 'category' is not set, it will&#160; not be present in ui form at <br/>all.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>4) What is&#160; &lt;XModelAttributeReference&gt;?<br/>&lt;XModelEntity&#160; name="SeamJmsQueueConnection"<br/>...<br/>&lt;XModelAttributeReference<br/>&#160;&#160;&#160;&#160; attributes="class,scope,precedence,installed,auto-create"<br/>&#160;&#160;&#160;&#160; entity="SeamComponent"&#160; name="component"/&gt;<br/>...<br/>&lt;/XModelEntity&gt;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Entities&#160; SeamComponent and SeamJmsQueueConnection have a lot in common, meta&#160; <br/>information for attributes 'class', 'scope', etc. can be inherited by the&#160; <br/>later from the former.<br/>The meta model inheritance in XModel is rather&#160; trivial, I admit it, but <br/>improving it is next to impossible because of&#160; potentially huge refactoring <br/>that it might involve (I am afraid that similar&#160; consideration will loom in <br/>the way of many a sensible suggestions for XModel&#160; improvements).</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-15207">going to Community</a></p>

        <p style="margin: 0;">Create a new document in JBoss Tools Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2129">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>