IntroductionA merge point is an "entry point" to XDoclet generated files. The developer can add custom data easily. There are two different ways to use merge points. 1. Adding specific parts inside deployment descriptorsHaving to hard code deployment descriptor specifics (ejb-jar.xml and vendor specific ones) in a source file simplifies the deployment work but has the limitation that the programmer must also take the deployer role.
Let's examine an example. You have, in your ejb-jar.xml, an env-entry element to a JDBC URL that you use
inside a session bean (
@ejb.env-entry name="jdbcUrl" type="String" value="jdbc:hsqldb:hsql://thishost:1476" and use the value returned by a JNDI lookup to get the SQL connection.
The problem is that you will need to change your code when the url changes. Several merge points exist
in ejb-body.xdt. This file is the template for ejb-jar.xml, you can see the merge point we need:
For example c:\mergedir\test\ejb\. Here is the content: <env-entry> <env-entry-name>jdbcUrl</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>jdbc:hsqldb:hsql://thishost:1476</env-entry-value> </env-entry> You can now change this file independently of the source file. Look into the .xdt files directly to find all defined merge points. 2. Adding specific generation of code
Entry points exist in template files used to generate the classes. For
example in entitycmp.xdt (template for Entity Bean classes) you have
Examine the existing .xdt files to learn the template language. |