Contexts and Dependency Injection for Java EE (CDI) Magical Mystery Tour

3,086 views

Published on

This is a fast demo-driven tour of Contexts and Dependency Injection for Java EE, the new cool kid on the dependency injection block.

We discuss features such as injection, automatic context management, scoping, qualifiers, naming, object factories, producers, disposers, dynamic lookup, stereotypes, interceptors, decorators and lightweight type-safe events. The relationship between this critical Java EE API covering generic dependency injection services and the rest of the platform including Dependency Injection for Java (JSR 330), managed beans, EJB 3, JSF and JPA will also be discussed.

Published in: Technology
0 Comments
7 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,086
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
153
Comments
0
Likes
7
Embeds 0
No embeds

No notes for slide

Contexts and Dependency Injection for Java EE (CDI) Magical Mystery Tour

  1. 1. 1Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  2. 2. Contexts and Dependency Injection for Java EE (CDI) Magical Mystery Tour Reza Rahman Java EE/GlassFish Evangelist Reza.Rahman@Oracle.com @reza_rahman
  3. 3. Program Agenda  CDI Primer  Demo  CDI Ecosystem 3Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  4. 4. Contexts and Dependency Injection for Java EE (CDI)  Cool new kid on dependency injection block  Synthesizes best ideas from Seam 2, Guice and Spring  Many innovations on its own right  Loose-coupling, Java-centric type-safety, annotations, expressiveness and ease-of-use  Makes Java EE much more flexible, testable, pluggable and extensible  Large ecosystem rapidly evolving around CDI 4Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  5. 5. CDI and Java EE 5Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  6. 6. CDI Features  Basic dependency injection – @Inject, @Qualifier, @Stereotype, @Alternative, @All, @Any  Component naming – @Named  Custom Object Factories – @Produces, @Disposes, InjectionPoint  Context management – @RequestScoped, @SessionScoped, @ConversationScoped, @ApplicationScoped, @Scope 6Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  7. 7. CDI Features  Lightweight Events – Event, @Observes  Interceptors/Decorators – @Interceptor, @InterceptorBinding, @AroundInvoke, InvocationContext, @Decorator, @Delegate  Portable extensions SPI! 7Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  8. 8. Weld  CDI reference implementation  Weld reference excellent documentation for CDI  Evolved from Seam 2 core  Included in GlassFish, WebLogic and JBoss AS  Can be used with Tomcat, Jetty, Java SE 8Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  9. 9. OpenWebBeans  Apache implementation of CDI included in Geronimo, WebSphere  Closely related to Apache OpenEJB  Great integration with Tomcat along with OpenEJB (TomEE)  Runs in standalone Java SE 9Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  10. 10. CanDI  Caucho implementation forms core of Resin itself  CanDI XML used to configure Resin  Use of annotations like @TransactionAttribute, @Schedule, @Asynchronous, @RolesAllowed, @RunAs, @Lock, @Startup and @Remote outside EJB in plain CDI managed beans  @PoolScoped, @TransactionScoped, @ThreadScoped  Optimized embedded container based Test Framework  CDI-PHP integration 10Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  11. 11. Demo Time! https://github.com/m-reza-rahman/cdi-tour 11Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  12. 12. CDI Ecosystem Portable Extensions Implementations Weld CanDI Tools 12Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public Runtimes
  13. 13. CDI Plugins 13Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  14. 14. Resources  Contexts and Dependency Injection for Java EE, http://www.cdi- spec.org  Java EE Tutorial, http://docs.oracle.com/javaee/7/tutorial/doc/partcdi.htm  OpenWebBeans, http://openwebbeans.apache.org  CanDI, http://caucho.com/projects/candi/  DeltaSpike, http://deltaspike.apache.org 14Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public
  15. 15. 15Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Insert Information Protection Policy Classification from Slide 12
  16. 16. 16Copyright © 2012, Oracle and/or its affiliates. All rights reserved. Public

×