Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Removed {footnote} tags in favor of (eventually) applying a CSS style to external links

...

The inner construction of the Tapestry framework is based on inversion of control

Footnote

http://www.martinfowler.com/articles/injection.htmlImage Removed

(IoC), a design approach that allows a working system to be fabricated from many small, easily testable pieces.

...

Tapestry 4 introduced the use of the Apache HiveMind

Footnote

http://hivemind.apache.org/Image Removed

IoC container. In fact, the HiveMind project was created specifically for use as the IoC container for Tapestry 4. Tapestry 4 has met its goals for extensibility and configurability, largely because of HiveMind's flexibility.

Tapestry 5 extends on this, replacing HiveMind with a new container specifically build for Tapestry 5, designed for greater ease of use, expressiveness and performance. HiveMind itself has been subsequently shelved; T5 IoC can be considered a streamlined and improved HiveMind. And T5 IoC can be used separately from the rest of Tapestry!

Why Not Spring?

Spring

Footnote

http://www.springframework.orgImage Removed

is the most successful IoC container project. The Spring project combines a very good IoC container, integrated AspectJ
Footnote

http://www.eclipse.org/aspectj/Image Removed

support, and a large number of libraries built on top of the container. Spring is an excellent application container, but lacks a number of features necessary for a framework container:

...

With the advent of new technologies (in particular, JDK 1.5 Annotations

Footnote

http://download.oracle.com/javase/tutorial/java/javaOO/annotations.htmlImage Removed

and runtime class generation via Javassist
Footnote

http://www.jboss.org/products/javassistImage Removed]

) some of the precepts of HiveMind have been undermined. That is to say, in HiveMind (and Spring), all that XML is an awkward way to describe a few basic Java operations: instantiating classes and invoking methods on those classes (to inject dependencies into the instantiated instances). The central concept in Tapestry IoC is to eliminate XML and build an equivalent system around simple objects and methods.

Tapestry IoC also represents many simplifications of HiveMind, representing lessons learned while creating both HiveMind and Tapestry 4. HiveMind itself has wound down (it is not longer in active development), with the user base moving to Tapestry 5.

Why not Guice?

Google Guice

Footnote

http://code.google.com/p/google-guice/Image Removed

is a newcomer to the IoC landscape. Guice and T5 IoC are very close and, in fact, T5 IoC expressly borrows many great and innovative ideas from Guice. Guice abandons not only XML but even any concept of a service id ... for injection, services are matched by type and perhaps filtered based on annotations.

...

Another goal is "developer friendliness". This is a true cross-cutting concern, and one not likely to be packaged into an aspect any time soon. The Tapestry IoC framework is designed to be easy to use and easy to understand. Further, when things go wrong, it actively attempts to help you via comprehensive checks and carefully composed error messages. Further, all user-visible objects implement a reasonable toString() method

Footnote

http://howardlewisship.com/blog/2003/08/importance-of-tostring.htmlImage Removed

, to help you understand what's going when you inevitably try to figure things out in the debugger.

...

When building a registry of services, lightness refers to the proper division of responsibility, the separation of concerns, and the limiting of dependencies between different parts of the system. This style is often called Law of Demeter Footnotehttp://www.ccs.neu. edu/research/demeter/demeter-method/LawOfDemeter/general-formulation.htmlImage Removed. Using an IoC container makes it easier to embrace this approach, since one critical concern, which objects are responsible for instantiating which others, is entirely managed by the container. With this life cycle concern removed, it becomes very easy to reduce complex chunks of code into small, testable, reusable services.

...

  • Small interfaces of two or three methods.
  • Small methods, with two or three parameters (because dependencies are injected in behind the scenes, rather than passed into the method).
  • Anonymous communication via events, rather than explicit method invocations. The service implementation can implement an event listener interface.

See The Pragmatic Programmer

Footnote

http://www.pragmaticprogrammer.com/ppbook/index.shtmlImage Removed

for more insights into building solid code.

...

The point of Injection is a field, method parameter, or constructor parameter that receives an injected value. The type of service (or other dependency) is determined by the type of the field or parameter. Often, annotations further identify what is to be injected, or in the case of field injection, that an injection is required.display-footnotes