Apache
  Home arrow Apache arrow Page 4 - Apache Tapestry and DirectLink, IoC an...
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
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? 
APACHE

Apache Tapestry and DirectLink, IoC and DI
By: Alexander Kolesnikov
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 13
    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:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    Route your faxes to your email inbox. Private, secure fax numbers available from CallWave. Choose your fax number.

    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.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · I admit that my definition of IoC and DI is somewhat unusual, but I hope you'll find...
       · In the page specifications file, we bind a parameter to the component detailsLink...
     

       

    APACHE ARTICLES

    - 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...
    - The Properties of Tapestry Pages

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway