Apache
  Home arrow Apache arrow Page 4 - Apache Tapestry and DirectLink, IoC and DI
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
APACHE

Apache Tapestry and DirectLink, IoC and DI
By: Alexander Kolesnikov
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 17
    2007-05-14


    Table of Contents:
  • Apache Tapestry and DirectLink, IoC and DI
  • DirectLink and For working together
  • Passing a parameter
  • Inversion of Control and Dependency Injection

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Apache Tapestry and DirectLink, IoC and DI - Inversion of Control and Dependency Injection
    ( Page 4 of 4 )

    Inversion of Control (IoC) and Dependency Injection (DI) are some of the most popular concepts in software development these days, at least in the world of Java. However when I decided to find out what these words mean, I found that most of the available definitions are incomprehensible, while the concepts themselves are quite simple. So let me make yet another attempt to explain what IoC and DI actually mean.

    Imagine you are staying in a five star hotel. Are you going to cook your breakfast or wash your shirts there? Probably not. You will trust the hotel to do all the low level work while you are doing something much more important like sunbathing or visiting local attractions. That's quite a natural thing to do, but from the computer science point of view this approach is labeled "Inversion of Control."

    In general, IoC means that you don't want to deal with some low level basic functionality in your code (you don't want to control that stuff yourself as you have more interesting things to do), so you leave it to a container (like that hotel) in which your code runs.

    We have already dealt with IoC in Tapestry when we used just an abstract getter to tell the framework that we need to have a fully configured and properly maintained page property. Tapestry itself can be considered a container, although it would be more proper to say that Tapestry 4 is built on top of an IoC container named HiveMind.

    HiveMind is a separate Apache project, also created by Howard Lewis Ship, the creator of Tapestry. We are going to deal with HiveMind configuration in the upcoming articles, but for now it is enough just to know that it exists. Arguably, HiveMind is more sophisticated than the much better known IoC container of Spring framework. By the way, we can easily use Spring beans in a Tapestry application. Strangely enough, it might be easier to get a Spring bean reference into Tapestry than into Spring itself! But I digress; this is a topic for a later article.

    Now what about Dependency Injection? It is actually a variety of IoC, a more specialized version of it. Back in your five star hotel, you were very thirsty and consumed all the contents of your mini-bar. Does this mean that you will die from thirst the next evening? Not at all, the hotel (your container) will put (inject!) more drinks into your mini-bar. Similar to this, when we need some resource (dependency) in our Tapestry application, as we needed a reference to the Details page recently, we only provide a way to inject that dependency for us (perhaps using an annotation and an abstract getter), so that it is ready to use when we need it.

    I hope the only question that still bothers you now is why such weird words are used: injection, inversion... See, some software developers like to think of themselves as not mere programmers but computer scientists. And what typically distinguishes any scientist from ordinary people? It is perhaps their tendency to use incomprehensible weird terms to label simple things. So here we are.

    What comes next

    We are going to create a page for adding a new celebrity. But before doing this we'll want to make a DataSource stored in the application's memory and easily accessible for all pages. In other words, we are going to make it an Application State Object (ASO).

    See you in the next article.



     
     
    >>> More Apache Articles          >>> More By Alexander Kolesnikov
     

       

    APACHE ARTICLES

    - Creating a VAMP (Vista, Apache, MySQL, PHP) ...
    - Putting Apache in Jail
    - Containing Intrusions in Apache
    - Server Limits for Apache Security
    - Setting Permissions in Apache
    - Installing Apache
    - Apache Installation and Configuration
    - Apache Tapestry and Custom Components: DateI...
    - Tapestry and AJAX: Autocompleter and InlineE...
    - PropertySelection and IPropertySelectionMode...
    - The DatePicker and Shell Components of Apach...
    - Apache Tapestry: ASO and More Components
    - Apache Tapestry and DirectLink, IoC and DI
    - Making a CelebrityCollector with Apache Tape...
    - Apache Tapestry and Listener Methods, Condit...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek