Skip to end of metadata
Go to start of metadata

AspectJ aspects can be configured and used as a bean. Since aspects are no regular bean in the sense that they provide a static factory method "aspectOf" to obtain aspect instances, a special tag <aspectj> is provided to symplify the configuration of aspects.

This tag is not pre-loaded as the standard tags. In order to use it, <nut> tag is used to load it.

For example:

It is of course possible to use the <bean> tag directly to configure aspects, just the same way as what we do in Spring:

Different from Spring, Nuts does not do eager initialization by default. Therefore, we need to explicitly set the "eager-init" attribute in order to make sure the aspect is initialized properly before the advice is applied.

Compared to the <aspectj> tag, the latter way is just more verbose.

Labels
  • None