Using Other J2EE Resources

When you deploy Quartz within the J2EE container, you can take advantage of other resources available to the J2EE components. For example, if you need to send e-mails, one approach would be to use the Quartz SendMailJob, which relies on JavaMail. Another approach you can take if you deploy Quartz within the container is to use the mail session that should be readily available for all J2EE servers, assuming that you've set one up. That's another one of the benefits of deploying Quartz as a J2EE client.

InitialContext initialContext = new InitialContext(); Session session = (Session) initialContext.lookup(urlToMailSession); Message msg = new MimeMessage(session); // ... build up msg Transport.send(msg);

Категории