O'Reilly logo

Hands-On High Performance with Spring 5 by Dinesh Radadiya, Prashant Goswami, Pritesh Shah, Subhash Shah, Chintan Mehta

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

Aspect instantiation models

By default, the declared aspect is singleton, so there will be only one instance of our aspect per class loader (and not per JVM). The instance of our aspect will be destroyed only when the class loader is garbage.

If we need to have our aspect with private attributes hold data relative to class instances, the aspect needs to be stateful. To do so, Spring with its AspectJ support provides a way using perthis and pertarget instantiation models. AspectJ is an independent library, and has other instantiation models in addition to perthis and pertarget, such as percflow, percflowbelowand pertypewithin, which are not supported in Spring's AspectJ support.

To create a stateful aspect using perthis, we need to declare ...

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