
Writing a web application is not just about producing a good layout and a bunch of “cool” pages. We must also integrate our presentation code with enterprise resources like data sources, message queues, business objects, etc...

The first decade of 2000s has seen the rising of new frameworks (like  http://spring.io/[Spring] ) and new specifications (like  http://en.wikipedia.org/wiki/Enterprise_JavaBeans[EJB 3.1] ) aimed to simplify the management of enterprise resources and (among other things) their integration with presentation code. 

All these new technologies are based on the concepts of container and dependency injection. Container is the environment where our enterprise resources are created and configured while   http://en.wikipedia.org/wiki/Dependency_Injection[dependency injection] is a pattern implemented by containers to inject into an object the resources it depends on.

Wicket can be easily integrated with enterprise containers using component instantiation listeners. These entities are instances of interface _org.apache.wicket.application.IComponentInstantiationListener_ and can be registered during application's initialization.   IComponentInstantiationListener defines callback method onInstantiation(Component component) which can be used to provide custom instantiation logic for Wicket components. 

Wicket distribution and project  https://github.com/wicketstuff[WicketStuff] already provide a set of built-in listeners to integrate our applications with EJB 3.1 compliant containers (like JBoss Seam) or with some of the most popular enterprise frameworks like  http://code.google.com/p/google-guice/[Guice] or Spring.

In this chapter we will see two basic examples of injecting a container-defined object into a page using first an implementation of the EJB 3.1 specifications (project  http://openejb.apache.org/[OpenEJB] ) and then using Spring.
