Declaring aspect

The first thing in Spring AOP is to decide on and define the aspects. In XML-based configuration, an aspect is conceptualized as a simple Java class that you need to declare as a bean definition in a Spring application context (XML) file. The <aop:aspect> element is used to define an aspect:

    <aop:config>    <aop:aspect id="myLoggin" ref="loggingAspect"></aop:aspect>     </aop:config>    <bean id="loggingAspect"    class="com.packet.spring.aop.aspects.LogginAspect">    </bean>

Since an aspect is a form of Java class, it can be defined as a normal Spring bean, and then can be configured with the ref attribute of the <aop:aspect> element. The state and behavior is associated with fields and methods of the aspect class, while the point-cut ...

Get Java 9 Dependency Injection now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.