cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Cayenne Documentation > Dependency Injection Container
Date Sun, 29 Nov 2009 20:27:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=CAYDOC&amp;forWysiwyg=true"
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="">Dependency
Injection Container</a></h2>
     <h4>Page <b>edited</b> by             <a href="">Andrus
     <div class="notificationGreySide">
         <h2><a name="DependencyInjectionContainer-Introduction"></a>Introduction</h2>

<p>Since 3.1 Cayenne runtime bundles a simple dependency injection (DI) container. <a
href="" rel="nofollow">Dependency injection</a>
(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. </p>

<p>Cayenne provides its own simple DI framework. It is used internally by the framework
to wire its components, and also allows users to easily extend and customize Cayenne. Cayenne
DI framework does not attempt to be "better than X or Y framework" or even a general purpose
framework, still it has no dependency on the rest of the Cayenne framework and can be used
as a standalone module at your own risk. </p>

<p>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 our user's choice of a
DI framework (and version of a DI framework). Cayenne DI will not create a conflict with any
third party DI.</p>

<h2><a name="DependencyInjectionContainer-FeaturesofCayenneDI"></a>Features
of Cayenne DI</h2>

	<li>annotation-based field dependency injection</li>
	<li>annotation-based constructor dependency injection</li>
	<li>injection of map and list "configurations"</li>
	<li>binding interfaces to implementation classes via fluent API</li>
	<li>binding interfaces to "provider" (same as "factory") classes</li>
	<li>merging multiple DI "modules"</li>
	<li>dependency cycle detection</li>
	<li>standard and user-defined scopes for bound objects.</li>

<h2><a name="DependencyInjectionContainer-ExamplesofCustomingCayenneviaDI"></a>Examples
of Customing Cayenne via DI</h2>

     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>

       <a href="">View
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message