XDoclet Overview News and Status Download/Installation Using XDoclet Best Practices FAQ License Ant Task Reference <ejbdoclet .. /> <webdoclet .. /> <hibernatedoclet .. /> <jdodoclet .. /> <jmxdoclet .. /> <doclet .. /> <documentdoclet .. /> Tag Reference apache (@soap @struts) bea (@weblogic) caucho (@resin) ejb (@ejb @dao) exolab (@castor) hp (@hpas) hibernate (@hibernate) ibm (@websphere) java (@javabean) jboss (@jboss) jdo (@jdo) jmx (@jmx) macromedia (@jrun) mvcsoft (@mvcsoft) mx4j (@mx4j) objectweb (@jonas) orion (@orion) pramati (@pramati) sybase (@easerver) web (@web @jsp) webwork (@webwork) xdoclet (@xdoclet @doc) Feature Documentation Using Value Objects Advanced Maven Plug-in Merge Points Log4J Configuration IDE Integration Migration from EJBDoclet Ant 1.5 Troubleshooting Community Feedback Resources Tools Developer Resources Developer Guide Architecture Branches and Tags CVS Directory Layout XDoclet 2.0 Design Planning Development Reference Javadoc (API) Template Language (*.xdt) Todo List Project Documentation Front Page Project Info Project Reports Development Process | ### Best Practices This document contains best practices when using XDoclet. Note that these are the opinions of the XDoclet team only, so they could be biased. #### Caching the home interface Add the `cacheHomes="true"` parameter to the `` task to have the utility objects cache the homes (you no longer need an EJBHomeFactory!):
    <utilobject cacheHomes="true"/>
Examples how to lookup the home interface using the utility object (it will narrow if needed, and uses the COMP name or JNDI name):
    EmployeeManager employeeManager = EmployeeManagerUtil.getHome().create();
    Properties jndiEnvProps = ... ;
    CompanyHome companyHome = CompanyUtil.getLocalHome(jndiEnvProps);
#### GUID Generator Need an extremely reliable key generator? Add the `includeGUID="true"` parameter to the `` task to have a key generator that features: unique to the millisecond unique to the server IP address unique to the object hashcode unique to a SecureRandom String, 32 chars very performant EJB 2.0 spec compliant
    <utilobject includeGUID="true"/>
To generate a unique key:
    String id = SomeBeanUtil.generateGUID(this);
#### Use a dot to seperate namespace and element To avoid getting Sun JavaDoc (JDK 1.4) warnings about unknown tags ("warning - @ejb:interface-method is an unknown tag"), replace the : with a . (JavaDoc will ignore these tags). #### Entity Beans Best Practices Try to avoid compound primary keys. Always set the Value Object in ejbPostCreate(..), so that CMR fields are assigned correctly. #### Session Beans Best Practices Use the Session Facade pattern for safer data management. #### Web Component Best Practices