Naming (JNDI) and dependency injection (CDI)

Study for Week 7

This week you will see how to access configuration that is managed by a Java EE container. In addition, you will see how the container can automatically manage different scopes.

At the end of this session, you should be able to:

  • Explain the need for applications to access context provided by an application container
  • Identify and differentiate two approaches to obtaining context: lookup and dependency injection
  • Use JNDI in a web application to look up settings and services provided by the Java EE container
  • Use CDI in a web application to inject dependencies provided by the Java EE container

Managing contexts in an application server

Java Naming and Directory Interface (JNDI)

Contexts and Dependency Injection (CDI)

I recommend reading Chapter 2 of Beginning Java EE 7: