The source code from the book about the Spring Framework version 2, by Craig Walls, with my own additions and tests. Original source code can be found at http://www.manning.com/walls3/ -- Here there are actually more self contained examples than in the original source code, since I'd like to really understand how this stuff works, even if it slow down a lot my reading pace. Dependencies are downloaded with Maven.
To run the examples, first do a "mvn:compile"
An overview of Dependency Injection and AOP
$ scripts/ch01-hello-HelloApp # Injecting properties $ scripts/ch01-knight-KnightApp # Injecting beans $ scripts/ch01-mistrel-KnightWithMinstrelApp # The Knight has to call the minstrel $ scripts/ch01-mistrel-KnightAndMinstrelApp # Aspect oriented programming
Dependency injection
$ scripts/ch02-springidol-DukeApp # Simple Bean Creation $ scripts/ch02-springidol-Duke15App # Bean Creation with constructor args $ scripts/ch02-springidol-PoeticJugglerApp # Bean Creation with constructor refs $ scripts/ch02-springidol-KennyApp # Bean Creation with setter injection $ scripts/ch02-springidol-KennyPianoApp # Same Bean playing a different instrument $ scripts/ch02-springidol-KennySharingWithDukeApp # Showing that there is only one Saxophone $ scripts/ch02-springidol-TwoSaxophonesApp # With inner beans Duke and Kenny have a private Saxophone $ scripts/ch02-springidol-HankApp # Hank, one man band, showing collection wiring $ scripts/ch02-springidol-HankMapApp # Hank with a Map wiring $ scripts/ch02-springidol-HankPropertiesApp # Hank with Properties wiring $ scripts/ch02-autowiring-ByNameApp # Autowiring by name
About some less common techniques to perform DI, skipped
Aspect Oriented Programming (AOP)
The following example is broken, anyway, I'm now off to read Spring Recipes, because I've read all the basics here, and the advanced topics changed quite a bit in Spring 3.0, while this book is about Spring 2.0
$ scripts/ch04-DukeAndAudienceApp # Shows MethodBeforeAdvice, AfterReturningAdvice and ThrowsAdvice