
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  https://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 CDI/EJB compliant containers or with some of the most popular enterprise frameworks like  https://github.com/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  https://tomee.apache.org/[Apache TomEE] ) and then using Spring.
