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 Mon, 30 Aug 2010 18:35:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=CAYDOC&amp;forWysiwyg=true"
<body style="background: white;" bgcolor="white" class="email-body">
<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
                         <h4>Changes (1)</h4>
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* standard and user-defined scopes
for bound objects. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >h2. Examples of <span class="diff-changed-words">Customi<span
class="diff-added-chars"style="background-color: #dfd;">zi</span>ng</span>
Cayenne via DI <br></td></tr>
            <tr><td class="diff-unchanged" > <br>_TODO_ <br></td></tr>
</div>                            <h4>Full Content</h4>
                    <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="" class="external-link" 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 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). </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 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.</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 Injector instance</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-ExamplesofCustomizingCayenneviaDI"></a>Examples
of Customizing 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