How to use Spring AOP to tell class X bean with specific id instead of all beans of class X

In spring aop, you can create tips that will affect the entire instance of a certain type, but I want to tell the bean declaration not to all beans of this type.

<bean id="bean1" class="type1"/> <bean id="bean2" class="type1"/> 

I want to tell bean1 not all beans of type1 . What is the best approach?

+4
source share
1 answer

From the Spring AOP documentation :

Spring AOP also supports an optional PCD (PointCut Designator) named bean '. This PCD allows you to limit the match of junction points to a specific one named Spring bean, or to a set named Spring beans (when using wildcards). The "bean" PCD is as follows:

bean (idOrNameOfBean)

The token 'idOrNameOfBean' can be the name of any Spring bean: limited support for wildcards using the '*' character is supported, so if you set up some naming conventions for your Spring beans, you can easily write a PCD 'bean' expression to select them. As with other pointcut pointers, the PCD 'bean' can be & ed, || 'ed as well! (denied).

+4
source

All Articles