Cayenne User Documentation
Dependency Injection Container

Introduction

Since 3.1 Cayenne runtime bundles a simple dependency injection (DI) container. Dependency injection (also known as "Inversion of Control") is a powerful approach of assembling application components without creating tight coupling between them. There are a number of well-known dependency injection frameworks, such as Spring and Guice.

Cayenne DI container is used internally by the framework to wire its components, and also allows users to easily extend and customize Cayenne. Cayenne DI does not attempt to be "better than X or Y framework" or even be a general purpose DI framework. Still it has no dependency on the rest of Cayenne and can theoretically be used as a standalone container (at your own risk).

Cayenne DI framework provides annotation-based configuration API similar to Google Guice and a subset of standard DI features needed by Cayenne. We decided not to use a third-party framework for a number of reasons. Size - Cayenne DI container is about 30K. Guice and Spring are at least 15 times larger (depending on what parts you want to include). Potential conflict with DI frameworks used by applications - we don't want to dictate the user's choice of a DI framework (or a version of a DI framework). Using Cayenne DI will not create a conflict with any third party DI container.

Features of Cayenne DI

Examples of Customizing Cayenne via DI

TODO

.