Section 8.6. Automating JavaMail-Based JNDI References with XDoclet


8.6. Automating JavaMail-Based JNDI References with XDoclet

As in previous chapters, we don't want to hardcode our deployment descriptors. We need to add XDoclet tags to the CreditCheckProcessor MDB so the Ant build process can add the JavaMail JNDI settings to the J2EE standard (ejb-jar.xml) and JBoss-specific (jboss.xml) EJB deployment descriptors in Example 8-7.

Example 8-7. CreditCheckProcessorBean.java
 /**  * ...  *  * @ejb.resource-ref  *  res-ref-name="mail/JawJavaMailSession"  *  res-type="javax.mail.Session"  *  res-auth="Container"  *  * @jboss.resource-ref  *  res-ref-name="mail/JawJavaMailSession"  *  jndi-name="java:/Mail"  *  */ public class CreditCheckProcessorBean implements MessageDrivenBean, MessageListener {     ... } 

The @ejb.resource-ref XDoclet tag generates the <resource-ref> element for the JawJavaMailSession in ejb-jar.xml, and the @jboss.resource XDoclet tag generates the corresponding <resource-ref> element in jboss.xml.

At this point, we've written code to send an email message with JavaMail and added JavaMail-based JNDI references to our EJB deployment descriptors. To complete the deployment, we'll deploy JavaMail on JBoss.



JBoss at Work. A Practical Guide
JBoss at Work: A Practical Guide
ISBN: 0596007345
EAN: 2147483647
Year: 2004
Pages: 197

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net