Singletons with AspectJ

I stumbled upon this post (german) that shows how to implement the singleton pattern with AspectJ. Although you may want to use dependency injection with Spring or Guice, there might be (hopefully rare) occasions on which you opt for this solution. In this post we’ll check out how to do this with AspectJ 5.

The Eclipse project with the sample code for this post can be downloaded as tar.gz or zip; make sure to install the AspectJ Development Tools. You can browse the code online here.

Continue reading →