JSR-299: Contexts and Dependency Injection for the Java EE platform

JSR-299 Expert Group

Gavin King

Red Hat Middleware, LLC

Final Draft


Table of Contents

License
1. Architecture
1.1. Contracts
1.2. Relationship to other specifications
1.2.1. Relationship to the Java EE platform specification
1.2.2. Relationship to EJB
1.2.3. Relationship to managed beans
1.2.4. Relationship to Dependency Injection for Java
1.2.5. Relationship to Java Interceptors
1.2.6. Relationship to JSF
1.3. Introductory examples
1.3.1. JSF example
1.3.2. EJB example
1.3.3. Java EE component environment example
1.3.4. Event example
1.3.5. Injection point metadata example
1.3.6. Interceptor example
1.3.7. Decorator example
2. Concepts
2.1. Functionality provided by the container to the bean
2.2. Bean types
2.2.1. Legal bean types
2.2.2. Restricting the bean types of a bean
2.2.3. Typecasting between bean types
2.3. Qualifiers
2.3.1. Built-in qualifier types
2.3.2. Defining new qualifier types
2.3.3. Declaring the qualifiers of a bean
2.3.4. Specifying qualifiers of an injected field
2.3.5. Specifying qualifiers of a method or constructor parameter
2.4. Scopes
2.4.1. Built-in scope types
2.4.2. Defining new scope types
2.4.3. Declaring the bean scope
2.4.4. Default scope
2.5. Bean EL names
2.5.1. Declaring the bean EL name
2.5.2. Default bean EL names
2.5.3. Beans with no EL name
2.6. Alternatives
2.6.1. Declaring an alternative
2.7. Stereotypes
2.7.1. Defining new stereotypes
2.7.1.1. Declaring the default scope for a stereotype
2.7.1.2. Specifying interceptor bindings for a stereotype
2.7.1.3. Declaring a @Named stereotype
2.7.1.4. Declaring an @Alternative stereotype
2.7.1.5. Stereotypes with additional stereotypes
2.7.2. Declaring the stereotypes for a bean
2.7.3. Built-in stereotypes
2.8. Problems detected automatically by the container
3. Programming model
3.1. Managed beans
3.1.1. Which Java classes are managed beans?
3.1.2. Bean types of a managed bean
3.1.3. Declaring a managed bean
3.1.4. Specializing a managed bean
3.1.5. Default name for a managed bean
3.2. Session beans
3.2.1. EJB remove methods of session beans
3.2.2. Bean types of a session bean
3.2.3. Declaring a session bean
3.2.4. Specializing a session bean
3.2.5. Default name for a session bean
3.3. Producer methods
3.3.1. Bean types of a producer method
3.3.2. Declaring a producer method
3.3.3. Specializing a producer method
3.3.4. Disposer methods
3.3.5. Disposed parameter of a disposer method
3.3.6. Declaring a disposer method
3.3.7. Disposer method resolution
3.3.8. Default name for a producer method
3.4. Producer fields
3.4.1. Bean types of a producer field
3.4.2. Declaring a producer field
3.4.3. Default name for a producer field
3.5. Resources
3.5.1. Declaring a resource
3.5.2. Bean types of a resource
3.6. Additional built-in beans
3.7. Bean constructors
3.7.1. Declaring a bean constructor
3.8. Injected fields
3.8.1. Declaring an injected field
3.9. Initializer methods
3.9.1. Declaring an initializer method
3.10. The default qualifier at injection points
3.11. The qualifier @Named at injection points
3.12. @New qualified beans
4. Inheritance and specialization
4.1. Inheritance of type-level metadata
4.2. Inheritance of member-level metadata
4.3. Specialization
4.3.1. Direct and indirect specialization
5. Dependency injection, lookup and EL
5.1. Modularity
5.1.1. Declaring selected alternatives for a bean archive
5.1.2. Enabled and disabled beans
5.1.3. Inconsistent specialization
5.1.4. Inter-module injection
5.2. Typesafe resolution
5.2.1. Unsatisfied and ambiguous dependencies
5.2.2. Legal injection point types
5.2.3. Assignability of raw and parameterized types
5.2.4. Primitive types and null values
5.2.5. Qualifier annotations with members
5.2.6. Multiple qualifiers
5.3. EL name resolution
5.3.1. Ambiguous EL names
5.4. Client proxies
5.4.1. Unproxyable bean types
5.4.2. Client proxy invocation
5.5. Dependency injection
5.5.1. Injection using the bean constructor
5.5.2. Injection of fields and initializer methods
5.5.3. Destruction of dependent objects
5.5.4. Invocation of producer or disposer methods
5.5.5. Access to producer field values
5.5.6. Invocation of observer methods
5.5.7. Injection point metadata
5.6. Programmatic lookup
5.6.1. The Instance interface
5.6.2. The built-in Instance
5.6.3. Using AnnotationLiteral and TypeLiteral
6. Scopes and contexts
6.1. The Contextual interface
6.1.1. The CreationalContext interface
6.2. The Context interface
6.3. Normal scopes and pseudo-scopes
6.4. Dependent pseudo-scope
6.4.1. Dependent objects
6.4.2. Destruction of objects with scope @Dependent
6.4.3. Dependent pseudo-scope and Unified EL
6.5. Contextual instances and contextual references
6.5.1. The active context object for a scope
6.5.2. Contextual instance of a bean
6.5.3. Contextual reference for a bean
6.5.4. Contextual reference validity
6.5.5. Injectable references
6.5.6. Injectable reference validity
6.6. Passivation and passivating scopes
6.6.1. Passivation capable beans
6.6.2. Passivation capable dependencies
6.6.3. Passivating scopes
6.6.4. Validation of passivation capable beans and dependencies
6.7. Context management for built-in scopes
6.7.1. Request context lifecycle
6.7.2. Session context lifecycle
6.7.3. Application context lifecycle
6.7.4. Conversation context lifecycle
6.7.5. The Conversation interface
7. Lifecycle of contextual instances
7.1. Restriction upon bean instantiation
7.2. Container invocations and interception
7.3. Lifecycle of contextual instances
7.3.1. Lifecycle of managed beans
7.3.2. Lifecycle of stateful session beans
7.3.3. Lifecycle of stateless session and singleton beans
7.3.4. Lifecycle of producer methods
7.3.5. Lifecycle of producer fields
7.3.6. Lifecycle of resources
8. Decorators
8.1. Decorator beans
8.1.1. Declaring a decorator
8.1.2. Decorator delegate injection points
8.1.3. Decorated types of a decorator
8.2. Decorator enablement and ordering
8.3. Decorator resolution
8.3.1. Assignability of raw and parameterized types for delegate injection points
8.4. Decorator invocation
9. Interceptor bindings
9.1. Interceptor binding types
9.1.1. Interceptor binding types with additional interceptor bindings
9.1.2. Interceptor bindings for stereotypes
9.2. Declaring the interceptor bindings of an interceptor
9.3. Binding an interceptor to a bean
9.4. Interceptor enablement and ordering
9.5. Interceptor resolution
9.5.1. Interceptors with multiple bindings
9.5.2. Interceptor binding types with members
10. Events
10.1. Event types and qualifier types
10.2. Observer resolution
10.2.1. Assignability of type variables, raw and parameterized types
10.2.2. Event qualifier types with members
10.2.3. Multiple event qualifiers
10.3. Firing events
10.3.1. The Event interface
10.3.2. The built-in Event
10.4. Observer methods
10.4.1. Event parameter of an observer method
10.4.2. Declaring an observer method
10.4.3. Conditional observer methods
10.4.4. Transactional observer methods
10.5. Observer notification
10.5.1. Observer method invocation context
11. Portable extensions
11.1. The Bean interface
11.1.1. The Decorator interface
11.1.2. The Interceptor interface
11.1.3. The ObserverMethod interface
11.2. The Producer and InjectionTarget interfaces
11.3. The BeanManager object
11.3.1. Obtaining a contextual reference for a bean
11.3.2. Obtaining an injectable reference
11.3.3. Obtaining a CreationalContext
11.3.4. Obtaining a Bean by type
11.3.5. Obtaining a Bean by name
11.3.6. Obtaining a passivation capable bean by identifier
11.3.7. Resolving an ambiguous dependency
11.3.8. Validating an injection point
11.3.9. Firing an event
11.3.10. Observer method resolution
11.3.11. Decorator resolution
11.3.12. Interceptor resolution
11.3.13. Determining if an annotation is a qualifier type, scope type, stereotype or interceptor binding type
11.3.14. Obtaining the active Context for a scope
11.3.15. Obtaining the ELResolver
11.3.16. Wrapping a Unified EL ExpressionFactory
11.3.17. Obtaining an AnnotatedType for a class
11.3.18. Obtaining an InjectionTarget
11.4. Alternative metadata sources
11.5. Container lifecycle events
11.5.1. BeforeBeanDiscovery event
11.5.2. AfterBeanDiscovery event
11.5.3. AfterDeploymentValidation event
11.5.4. BeforeShutdown event
11.5.5. ProcessAnnotatedType event
11.5.6. ProcessInjectionTarget event
11.5.7. ProcessProducer event
11.5.8. ProcessBean event
11.5.9. ProcessObserverMethod event
12. Packaging and deployment
12.1. Bean archives
12.2. Application initialization lifecycle
12.3. Bean discovery
12.4. Integration with Unified EL