The Resource Adapter
The mailconnector resource adapter enables the MDB to receive email messages that are delivered to a specific mailbox folder on a mail server. It also provides connection factory objects clients can use to obtain connection objects that allow them to synchronously query email servers for new messages in a specific mailbox folder.
In this example, the MDB activates the resource adapter, but it does not receive email messages. Instead, this example allows users to synchronously query an email server for new messages.
The components of the resource adapter are as follows:
mailconnector.ra: Base class of the mailconnector resource adapter
mailconnector.ra/inbound: Classes that implement the inbound resource adapter, which supports delivery of JavaMail messages to MDBs
mailconnector.ra/outbound: Classes that implement the outbound resource adapter, which supports synchronous queries to email servers
mailconnector.api: Interfaces that are implemented by MDBs associated with this resource adapter and by the Connection and ConnectionFactoryinterfaces provided by the outbound resource adapter
mailconnector.share: JavaBeans class that implements the ConnectionSpec interface, allowing properties to be passed to the outbound resource adapter
When the resource adapter is deployed, it uses the Work Management facilities available to resource adapters to start a thread that monitors mailbox folders for new messages. The polling thread of the resource adapter monitors the mailbox folders every 30 seconds for new messages.