From the course: Spring: Framework in Depth

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Implement AOP advice: Before

Implement AOP advice: Before

From the course: Spring: Framework in Depth

Start my 1-month free trial

Implement AOP advice: Before

- [Instructor] Now that we have our pointcut and everything necessary for the framework to execute an aspect, we're going to create a before advice to execute before the join point that that pointcut will select. So let's jump into our IDE, in our LoggingAspect class. The first thing that we need to do is we need to put a logger in this class. So we're going to create a private static final Logger. Make sure you get the one from slf4j, call it LOGGER and we'll get that from the LoggerFactory and we'll just send it in the LoggingAspect.class as the prime for the logger. Now we're going to do our actual advice, so we're going to create a @Before advice and that @Before advice is going to execute against the executeLogging method. Now I alluded to earlier, you don't have to do it this way. We could put the pointcut here, but I actually prefer to keep them separate. I think it gives me a better visualization of what's going on…

Contents