Introduction to Web Beans

The new Java standard for dependency injection and contextual state management

Gavin King

Web Beans (JSR-299) specification lead
Red Hat Middleware LLC

Table of Contents

I. Using contextual objects
1. Getting started with Web Beans
1.1. Your first Web Bean
1.2. What is a Web Bean?
1.2.1. API types, binding types and dependency injection
1.2.2. Deployment types
1.2.3. Scope
1.2.4. Web Bean names and Unified EL
1.2.5. Interceptor binding types
1.3. What kinds of objects can be Web Beans?
1.3.1. Simple Web Beans
1.3.2. Enterprise Web Beans
1.3.3. Producer methods
1.3.4. JMS endpoints
2. JSF web application example
3. Dependency injection
3.1. Binding annotations
3.1.1. Binding annotations with members
3.1.2. Combinations of binding annnotations
3.1.3. Binding annotations and producer methods
3.1.4. The default binding type
3.2. Deployment types
3.2.1. Enabling deployment types
3.2.2. Deployment type precedence
3.2.3. Example deployment types
3.3. Fixing unsatisfied dependencies
3.4. Client proxies
3.5. Obtaining a Web Bean by programatic lookup
3.6. Lifecycle callbacks, @Resource, @EJB and @PersistenceContext
4. Scopes and contexts
4.1. Scope types
4.2. Built-in scopes
4.3. The conversation scope
4.3.1. Conversation demarcation
4.3.2. Conversation propagation
4.3.3. Conversation timeout
4.4. The dependent pseudo-scope
4.4.1. The @New annotation
5. Producer methods
5.1. Scope of a producer method
5.2. Injection into producer methods
5.3. Use of @New with producer methods
II. Developing loosely-coupled code
6. Interceptors
6.1. Interceptor bindings
6.2. Implementing interceptors
6.3. Enabling interceptors
6.4. Interceptor bindings with members
6.5. Multiple interceptor binding annotations
6.6. Interceptor binding type inheritance
6.7. Use of @Interceptors
7. Decorators
7.1. Delegate attributes
7.2. Enabling decorators
8. Events
8.1. Event observers
8.2. Event producers
8.3. Registering observers dynamically
8.4. Event bindings with members
8.5. Multiple event bindings
8.6. Transactional observers
III. Making the most of strong typing
9. Stereotypes
9.1. Default scope and deployment type for a stereotype
9.2. Restricting scope and type with a stereotype
9.3. Interceptor bindings for stereotypes
9.4. Name defaulting with stereotypes
9.5. Standard stereotypes
10. Specialization
10.1. Using specialization
10.2. Advantages of specialization
11. Defining Web Beans using XML
11.1. Declaring Web Bean classes
11.2. Declaring Web Bean metadata
11.3. Declaring Web Bean members
11.4. Declaring inline Web Beans
11.5. Using a schema
IV. Web Beans and the Java EE ecosystem
12. Java EE integration
12.1. Injecting Java EE resources into a Web Bean
12.2. Calling a Web Bean from a Servlet
12.3. Calling a Web Bean from a Message-Driven Bean
12.4. JMS endpoints
13. Extending Web Beans
13.1. The Manager object
13.2. The Bean class
13.3. The Context interface
14. Next steps