O'Reilly logo

Mastering Spring Application Development by Anjana Mankale

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Sending Spring mails with AOP

We can also send mails by integrating the mailing functionality with Aspect Oriented Programming (AOP). This can be used to send mails after the user registers with an application. Think of a scenario where the user receives an activation mail after registration. This can also be used to send information about an order placed on an application. Use the following steps to create a MailAdvice class using AOP:

  1. Create a package called com.packt.aop.
  2. Create a class called MailAdvice.
    public class MailAdvice {
      public void advice (final ProceedingJoinPoint proceedingJoinPoint) { new Thread(new Runnable() { public void run() { System.out.println("proceedingJoinPoint:"+proceedingJoinPoint); try { proceedingJoinPoint.proceed(); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required