CDI
CDI <ul><li>JSR-299:   </li></ul><ul><li>Contexts and Dependency Injection  </li></ul><ul><ul><ul><ul><ul><li>for the Java...
Features <ul><li>DI with Scopes/Contexts </li></ul><ul><li>Loose Coupling </li></ul><ul><li>Strong Typing </li></ul><ul><l...
Runs on... <ul><li>JBoss AS </li></ul><ul><li>GlassFish </li></ul><ul><li>Tomcat </li></ul><ul><li>Jetty </li></ul><ul><li...
Scopes and Contexts <ul><li>@RequestScoped </li></ul><ul><li>@SessionScoped </li></ul><ul><li>@ApplicationScoped </li></ul...
Producers <ul><li>Producer methods/fields </li></ul><ul><ul><li>Source of the object to be injected (does not have to be f...
Producers
Producers
Producers
Qualifiers <ul><li>Specifying Injections beyond just type </li></ul><ul><li>Access to InjectionPoint Metadata </li></ul>
Qualifers
Qualifers https://docs.jboss.org/weld/reference/1.0.0/en-US/html/injection.html#d0e1182
Interceptors <ul><li>Based on the  Java Interceptor spec </li></ul><ul><li>More sofisticated,  Semantic,  Annotation-drive...
Decorators <ul><li>Works like an Interceptor, but only intercepts invocations on a specific interface </li></ul><ul><li>Is...
Events <ul><li>Event observe pattern </li></ul><ul><li>Typesafe </li></ul>
Events <ul><li>Can be combined with Qualifiers </li></ul>
Stereotypes <ul><li>Declare common metadata for beans with same/similar roles </li></ul><ul><li>Interceptor bindings </li>...
Alternatives <ul><li>Good for mocking </li></ul><ul><li>Switch implementation at runtime </li></ul><ul><li>Enabled via bea...
Related Cool Stuff <ul><li>Arquillian </li></ul><ul><li>ShrinkWrap </li></ul><ul><li>RestEasy </li></ul><ul><li>JSF 2 </li...
credits <ul><li>http://www.microbotic.org/injection.htm </li></ul><ul><li>http://www.brianmicklethwait.com/index.php/weblo...
Upcoming SlideShare
Loading in...5
×

Cdi demo

1,467

Published on

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

  • Be the first to like this

No Downloads
Views
Total Views
1,467
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Cdi demo

  1. 1. CDI
  2. 2. CDI <ul><li>JSR-299: </li></ul><ul><li>Contexts and Dependency Injection </li></ul><ul><ul><ul><ul><ul><li>for the Java EE platform </li></ul></ul></ul></ul></ul><ul><ul><li>Weld: Reference implementation of CDI </li></ul></ul><ul><ul><ul><li>Seam 3: Weld as core + Extensions </li></ul></ul></ul>
  3. 3. Features <ul><li>DI with Scopes/Contexts </li></ul><ul><li>Loose Coupling </li></ul><ul><li>Strong Typing </li></ul><ul><li>Producers </li></ul><ul><li>Qualifiers </li></ul><ul><li>Interceptors </li></ul><ul><li>Decorators </li></ul><ul><li>Events </li></ul><ul><li>Stereotypes </li></ul><ul><li>Alternatives </li></ul><ul><li>Annotation driven </li></ul><ul><li>CoC </li></ul><ul><li>Extensible SPI </li></ul>
  4. 4. Runs on... <ul><li>JBoss AS </li></ul><ul><li>GlassFish </li></ul><ul><li>Tomcat </li></ul><ul><li>Jetty </li></ul><ul><li>Google App Engine </li></ul><ul><li>Any Java EE 6 container </li></ul>
  5. 5. Scopes and Contexts <ul><li>@RequestScoped </li></ul><ul><li>@SessionScoped </li></ul><ul><li>@ApplicationScoped </li></ul><ul><li>@ConversationScoped </li></ul><ul><li>@Dependent (default) </li></ul><ul><li>@New </li></ul><ul><li>@Named (not really a scope/context) </li></ul>
  6. 6. Producers <ul><li>Producer methods/fields </li></ul><ul><ul><li>Source of the object to be injected (does not have to be from a bean) </li></ul></ul><ul><li>Enables </li></ul><ul><ul><li>JPA entities as beans </li></ul></ul><ul><ul><li>Any POJO as Bean </li></ul></ul>
  7. 7. Producers
  8. 8. Producers
  9. 9. Producers
  10. 10. Qualifiers <ul><li>Specifying Injections beyond just type </li></ul><ul><li>Access to InjectionPoint Metadata </li></ul>
  11. 11. Qualifers
  12. 12. Qualifers https://docs.jboss.org/weld/reference/1.0.0/en-US/html/injection.html#d0e1182
  13. 13. Interceptors <ul><li>Based on the Java Interceptor spec </li></ul><ul><li>More sofisticated, Semantic, Annotation-driven adaption </li></ul><ul><li>Business method interception </li></ul><ul><li>Lifecycle callback interception </li></ul><ul><li>Timeout method interception </li></ul>https://docs.jboss.org/weld/reference/1.0.0/en-US/html/interceptors.html#d0e3625
  14. 14. Decorators <ul><li>Works like an Interceptor, but only intercepts invocations on a specific interface </li></ul><ul><li>Is a Bean that implements the methods of the interface it is set to intercept </li></ul><ul><li>Can be abstract </li></ul>https://docs.jboss.org/weld/reference/1.0.0/en-US/html/decorators.html
  15. 15. Events <ul><li>Event observe pattern </li></ul><ul><li>Typesafe </li></ul>
  16. 16. Events <ul><li>Can be combined with Qualifiers </li></ul>
  17. 17. Stereotypes <ul><li>Declare common metadata for beans with same/similar roles </li></ul><ul><li>Interceptor bindings </li></ul><ul><li>Name defaulting </li></ul><ul><li>Alternative stereotypes </li></ul><ul><li>Stereotype stacking </li></ul><ul><li>Built-in stereotypes </li></ul><ul><ul><li>@Interceptor </li></ul></ul><ul><ul><li>@Decorator </li></ul></ul>https://docs.jboss.org/weld/reference/1.0.0/en-US/html/stereotypes.html#d0e4134
  18. 18. Alternatives <ul><li>Good for mocking </li></ul><ul><li>Switch implementation at runtime </li></ul><ul><li>Enabled via beans.xml </li></ul>https://docs.jboss.org/weld/reference/1.0.0/en-US/html/injection.html#alternatives
  19. 19. Related Cool Stuff <ul><li>Arquillian </li></ul><ul><li>ShrinkWrap </li></ul><ul><li>RestEasy </li></ul><ul><li>JSF 2 </li></ul><ul><li>Richfaces </li></ul><ul><li>PrettyFaces </li></ul>
  20. 20. credits <ul><li>http://www.microbotic.org/injection.htm </li></ul><ul><li>http://www.brianmicklethwait.com/index.php/weblog/giant_table_football_table_and_hamster_powered_cars/ </li></ul><ul><li>http://nexus404.com/Blog/2008/07/07/art-lebedev-matryoshka-storage-capacity-dolls-now-available-in-black-geeky-ornaments/ </li></ul><ul><li>http://www.istockphoto.com </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×