cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Cayenne > Runtime Metadata Merging
Date Sat, 13 Feb 2010 12:04:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/25/_/styles/combined.css?spaceKey=CAY&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/CAY/Runtime+Metadata+Merging">Runtime
Metadata Merging</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~andrus">Andrus
Adamchik</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <p><em>This is a design document. As of 3.0 Cayenne doesn't include this
feature.</em></p>

<h2><a name="RuntimeMetadataMerging-MultipleDeploymentUnits"></a>Multiple
Deployment Units</h2>

<p>Users can organize their persistent classes and object relational mapping files into
separate deployment units, such as .jar files, .war files and class folders. Each deployment
unit must have "cayenne.xml" descriptor and a set of related DataNode and DataMap XML files.
At runtime Cayenne will merge mapping information from all deployment units into a single
access stack using a set of rules described below.</p>

<h2><a name="RuntimeMetadataMerging-%22cayenne.xml%22LookupRules"></a>"cayenne.xml"
Lookup Rules</h2>

<p>As described in the previous deployment chapters, "cayenne.xml" is by default looked
up in the root of each classpath location (such as top of a ".jar" file, a "WEB-INF/classes"
folder, etc.), or in WEB-INF/ folder of a web application. Or it can be placed in a package
or a subfolder per <a href="/confluence/display/CAYDOC/Customizing+Configuration" title="Customizing
Configuration">customization instructions</a>. </p>

<h2><a name="RuntimeMetadataMerging-MergingConfigurationfromMultipleDeploymentUnits"></a>Merging
Configuration from Multiple Deployment Units</h2>

<p>If multiple deployment units contain "cayenne.xml" descriptors in the default or
custom locations above, all descriptors will be merged together. Cayenne will do merging on
its own using a set of default rules. Most of the merging behavior can be further customized
by the user. The following merge rules are applied:</p>

<ul>
	<li><em>All Units Are Equal.</em> There is no "master" descriptor. All
descriptors are considered equal and the order in which they are merged is undefined and should
not be relied upon.</li>
	<li><em>Domains Are Merged By Name.</em> Names of Cayenne DataDomains are
used to match and combine together DataMaps and DataNodes from different deployment units.</li>
	<li><em>Domain Names Can Be Aliased to Control Merging.</em> Users may
have no control over the domain naming of third-party libraries. To ensure that those libraries
are merged into the right domains, they can create domain name aliases via MergeContext class
API:</li>
</ul>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>MergeContext context = ...
context.mergeDomainAs("unit1", "domain1", "myAppDomain");</pre>
</div></div>

<p>If the code in a deployment unit relies on the domain name and aliases are used,
it should use deployment unit name (optionally specified in the modeler) and domain name when
looking up domain:</p>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>Configuration config = ....
DataDomain domain = config.getDomain("unit1", "domain1");</pre>
</div></div>

<ul>
	<li><em>Conflicting DataMaps Are Auto-Aliased.</em> If more than one DataMap
with the same name is being merged into a given domain, Cayenne automatically creates a name
alias for the second, third and following conflicting DataMaps. The naming conflict is logged
but no exception is thrown.</li>
</ul>


<ul>
	<li><em>Default DataNode.</em> If a DataDomain has only one DataNode, all
DataMaps are automatically linked to this DataNode. If there are multiple DataNodes, a "default"
DataNode can be specified via the MergeContext. All unlinked DataMaps will use this DataNode:</li>
</ul>


<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>MergeContext context = ...
context.setDefaultNode("unit1", "domain1", "myNode");</pre>
</div></div>

<ul>
	<li><em>Conflicting DataNodes Are Auto-Aliased.</em> If more than one DataNode
with the same name is being merged into a given domain, Cayenne automatically creates a name
alias for the second, third and following conflicting DataNodes. The naming conflict is logged
but no exception is thrown.</li>
</ul>


<ul>
	<li><em>Conflicting DbEntities, Procedures, Queries Are Ignored.</em> If
more than one DbEntity (Procedure, Query) with the same name is defined across the DataMaps
merged into the same domain, only one entity (Procedure, Query) will be preserved. The reset
will be ignored. There is no way to control which entity stays.</li>
</ul>


<ul>
	<li><em>Conflicting ObjEntities Are Ignored / Listeners Merged.</em> If
more than one ObjEntity with the same name is defined across the DataMaps merged into the
same domain, only one entity will be preserved. The reset will be ignored. There is no way
to control which entity stays. However entity listeners are combined together. This way listeners
can be defined in a unit separate from the unit that defined ObjEntity.</li>
</ul>


     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/CAY/Runtime+Metadata+Merging">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=86151&revisedVersion=2&originalVersion=1">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/CAY/Runtime+Metadata+Merging?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message