In this chapter we explored swapping test doubles using Inversion of Control (IoC). This is not the only use case for IoC. Being able to easily reconfigure things with no impact to the core business logic is of incredible value.
IoC allows us to move object creation to a centralized location. This empowers our applications to be easier to inject alternatives. This makes things such as testing, remoting, transactions, and security much easier.
Spring Python supports many formats including pure Python, Spring Python XML, and Spring Java XML. This gives users a wide range of choices based on their needs. By working with Jython, it is much easier to mix together Python and Java code together.
Exchanging one object definition with another constitutes a useful service. Throughout this book, other services will be explored. Just remember, at the heart of those services is Spring Python's IoC container.
In this chapter, we learned:
ObjectContainer
with the basic parts of an IoC container. This container handles dependency resolution, setting properties, and lazy initialiation ApplicationContext
, that subclasses the container, and provides extension points for developers to manipulate creation of objectsIn the next chapter, we will look at adding services to existing code using Aspect Oriented Programming (AOP).