SlideShare uma empresa Scribd logo
1 de 25
CDI and Seam 3
An exciting new landscape for Java
EE development




        Shane Bryzak
        21/04/10
The History of Seam
                (In 2 minutes or less)

• First beta in September 2005
• 1.0.0.GA released in June 2006
• 2.0.0.GA released in November 2007




                                         2
Sub Headline




               3
Sub Headline




               4
5
6
JSR-299 Implementations

• Weld (by Red Hat - Reference Implementation)
• OpenWebBeans (by Apache)
• CanDI (by Caucho)




                                                 7
Portable Extensions

•   One of the most exciting features in CDI
•   Extend the behaviour of the Java EE platform
•   Seam 3 is a collection of portable extensions
•   SPI defined by the JSR-299 spec
•   Easy to write




                                                    8
Just how easy?
3 simple steps:

• Create a new Java class
• Register the extension
• Implement the extension logic




                                  9
Portable Extensions
               Creating the Java class
package com.acme;


import javax.enterprise.inject.spi.Extension;


public class MyExtension implements Extension {


}




                                                  10
Portable Extensions
               Registering the extension

• Create a file in the META-INF/services directory called
  javax.enterprise.inject.spi.Extension
• It should contain the name of your class


com.acme.MyExtension




                                                            11
Portable Extensions
          Implementing the extension logic

• Listen to events fired by the container at deployment time
• Extensions can observe these events and make changes to
  the containers metadata model
• Dynamically change the default behaviour of beans,
  injection points
• Implement new context types




                                                               12
A real world example
                     Seam Security

• Portable extension for CDI
• Provides authentication, identity management and
  federated identity via OpenID, SAML, SSO
• Provides typesafe authorization through the use of
  annotation-based metadata




                                                       13
Typesafe authorization

@SecurityBindingType
@Retention(RUNTIME)
@Target({TYPE, METHOD})
public @interface Manager {}




                               14
Typesafe authorization

@Manager
public void generateSalesReport() {
   ...
}




                                      15
Typesafe authorization

@Secures @Manager
public boolean isManager(Identity identity)
  {
  return identity.hasRole("manager",
     "USERS", "GROUP");
}




                                              16
The extension must:

• Match all methods annotated with a security binding type
  with an authorizer method
• Add an interceptor binding to the secured method
• Throw an exception if there are any secured methods
  without a matching authorizer method




                                                             17
Scanning the methods
            ProcessAnnotatedType Event

• Fired by the container for each Java class or interface it
  discovers
• We can use this event to find classes or methods annotated
  with security binding types
• Our extension class can observe this event




                                                          18
Event observers
public class SecurityExtension implements Extension
  {


public <X> void processAnnotatedType(
    @Observes ProcessAnnotatedType<X> event,
    final BeanManager beanManager)
{
    ...
}




                                                      19
Interceptors

• Interceptors specification part of JSR-318
• CDI builds on this specification by introducing interceptor
  bindings
• Interceptor bindings are used to create a link between an
  interceptor and the bean to be intercepted




                                                                20
Interceptor Bindings
                     How they work

• Create an interceptor binding annotation
• Apply it to the interceptor class
• Apply it to the method or class that you want to be
  intercepted




                                                        21
Interceptor Bindings
             Creating the binding type
@Retention(RUNTIME)
@InterceptorBinding
@Target( { TYPE, METHOD })
@interface SecurityInterceptorBinding { }




                                            22
Interceptor Bindings
            Applying to the Interceptor
@SecurityInterceptorBinding @Interceptor
public class SecurityInterceptor
  implements Serializable {
   @Inject SecurityExtension extension;


   @AroundInvoke
   public Object aroundInvoke(InvocationContext
  invocation) throws Exception {



                                                  23
Interceptor Bindings
            Applying it to a method
public @Model class DocumentAction {

    @SecurityInterceptorBinding
    public void createDocument() {

    }
}


                                       24
Dynamic interceptors

• Our extension can apply an interceptor binding
  dynamically, at deployment time
• (Code demo - Eclipse)




                                                   25

Mais conteúdo relacionado

Mais procurados

BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 ||  Detecting Compromise on Windows Endpoints with Osquery  BlueHat v17 ||  Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat Security Conference
 

Mais procurados (20)

Linux Security, from Concept to Tooling
Linux Security, from Concept to ToolingLinux Security, from Concept to Tooling
Linux Security, from Concept to Tooling
 
Control Plane: Security Rationale for Istio (DevSecOps - London Gathering, Ja...
Control Plane: Security Rationale for Istio (DevSecOps - London Gathering, Ja...Control Plane: Security Rationale for Istio (DevSecOps - London Gathering, Ja...
Control Plane: Security Rationale for Istio (DevSecOps - London Gathering, Ja...
 
Securing the Cloud
Securing the CloudSecuring the Cloud
Securing the Cloud
 
Chris Rutter: Avoiding The Security Brick
Chris Rutter: Avoiding The Security BrickChris Rutter: Avoiding The Security Brick
Chris Rutter: Avoiding The Security Brick
 
Linux Hardening
Linux HardeningLinux Hardening
Linux Hardening
 
Secure and Simple Sandboxing in SELinux
Secure and Simple Sandboxing in SELinuxSecure and Simple Sandboxing in SELinux
Secure and Simple Sandboxing in SELinux
 
Is Docker Secure?
Is Docker Secure?Is Docker Secure?
Is Docker Secure?
 
How secure is your Docker Container pipeline?
How secure is your Docker Container pipeline?How secure is your Docker Container pipeline?
How secure is your Docker Container pipeline?
 
Breaking and fixing_your_dockerized_environments_owasp_appsec_usa2016
Breaking and fixing_your_dockerized_environments_owasp_appsec_usa2016Breaking and fixing_your_dockerized_environments_owasp_appsec_usa2016
Breaking and fixing_your_dockerized_environments_owasp_appsec_usa2016
 
Kernel Recipes 2013 - Linux Security Modules: different formal concepts
Kernel Recipes 2013 - Linux Security Modules: different formal conceptsKernel Recipes 2013 - Linux Security Modules: different formal concepts
Kernel Recipes 2013 - Linux Security Modules: different formal concepts
 
BSides SF talk on Docker Images Security - Feb 13, 2017
BSides SF talk on Docker Images Security - Feb 13, 2017BSides SF talk on Docker Images Security - Feb 13, 2017
BSides SF talk on Docker Images Security - Feb 13, 2017
 
Puppet for Production in WebEx - PuppetConf 2013
Puppet for Production in WebEx - PuppetConf 2013Puppet for Production in WebEx - PuppetConf 2013
Puppet for Production in WebEx - PuppetConf 2013
 
Container Security Mmanagement
Container Security MmanagementContainer Security Mmanagement
Container Security Mmanagement
 
A (fun!) Comparison of Docker Vulnerability Scanners
A (fun!) Comparison of Docker Vulnerability ScannersA (fun!) Comparison of Docker Vulnerability Scanners
A (fun!) Comparison of Docker Vulnerability Scanners
 
Matriux
MatriuxMatriux
Matriux
 
Security of Linux containers in the cloud
Security of Linux containers in the cloudSecurity of Linux containers in the cloud
Security of Linux containers in the cloud
 
How Many Linux Security Layers Are Enough?
How Many Linux Security Layers Are Enough?How Many Linux Security Layers Are Enough?
How Many Linux Security Layers Are Enough?
 
How CLOCKSS ingests and preserves content by Thib Guicherd-Callin
How CLOCKSS ingests and preserves content by Thib Guicherd-CallinHow CLOCKSS ingests and preserves content by Thib Guicherd-Callin
How CLOCKSS ingests and preserves content by Thib Guicherd-Callin
 
Optimizing ModSecurity on NGINX and NGINX Plus
Optimizing ModSecurity on NGINX and NGINX PlusOptimizing ModSecurity on NGINX and NGINX Plus
Optimizing ModSecurity on NGINX and NGINX Plus
 
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 ||  Detecting Compromise on Windows Endpoints with Osquery  BlueHat v17 ||  Detecting Compromise on Windows Endpoints with Osquery
BlueHat v17 || Detecting Compromise on Windows Endpoints with Osquery
 

Destaque

Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
Jiayun Zhou
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
Antoine Sabot-Durand
 

Destaque (10)

Java EE 6
Java EE 6Java EE 6
Java EE 6
 
Java EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSFJava EE 6 CDI Integrates with Spring & JSF
Java EE 6 CDI Integrates with Spring & JSF
 
Moving to Java EE 6 and CDI and away from the clutter
Moving to Java EE 6 and CDI and away from the clutterMoving to Java EE 6 and CDI and away from the clutter
Moving to Java EE 6 and CDI and away from the clutter
 
Designing Java EE Applications in the Age of CDI
Designing Java EE Applications in the Age of CDIDesigning Java EE Applications in the Age of CDI
Designing Java EE Applications in the Age of CDI
 
CDI, Weld and the future of Seam
CDI, Weld and the future of SeamCDI, Weld and the future of Seam
CDI, Weld and the future of Seam
 
What we can expect from Java 9 by Ivan Krylov
What we can expect from Java 9 by Ivan KrylovWhat we can expect from Java 9 by Ivan Krylov
What we can expect from Java 9 by Ivan Krylov
 
Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014Introduction to cdi given at java one 2014
Introduction to cdi given at java one 2014
 
Extending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss ForgeExtending Java EE with CDI and JBoss Forge
Extending Java EE with CDI and JBoss Forge
 
Java one 2015 [con3339]
Java one 2015 [con3339]Java one 2015 [con3339]
Java one 2015 [con3339]
 
Developing Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJSDeveloping Modern Java Web Applications with Java EE 7 and AngularJS
Developing Modern Java Web Applications with Java EE 7 and AngularJS
 

Semelhante a CDI and Seam 3: an Exciting New Landscape for Java EE Development

GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug in
GR8Conf
 

Semelhante a CDI and Seam 3: an Exciting New Landscape for Java EE Development (20)

Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group OsnabrueckCut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
Cut your Dependencies with Dependency Injection - .NET User Group Osnabrueck
 
Context and Dependency Injection
Context and Dependency InjectionContext and Dependency Injection
Context and Dependency Injection
 
Santander DevopsandCloudDays 2021 - Hardening containers.pdf
Santander DevopsandCloudDays 2021 - Hardening containers.pdfSantander DevopsandCloudDays 2021 - Hardening containers.pdf
Santander DevopsandCloudDays 2021 - Hardening containers.pdf
 
Applied Security for Containers, OW2con'18, June 7-8, 2018, Paris
Applied Security for Containers, OW2con'18, June 7-8, 2018, ParisApplied Security for Containers, OW2con'18, June 7-8, 2018, Paris
Applied Security for Containers, OW2con'18, June 7-8, 2018, Paris
 
Martin Toshev - Java Security Architecture - Codemotion Rome 2019
Martin Toshev - Java Security Architecture - Codemotion Rome 2019Martin Toshev - Java Security Architecture - Codemotion Rome 2019
Martin Toshev - Java Security Architecture - Codemotion Rome 2019
 
Javantura v4 - Security architecture of the Java platform - Martin Toshev
Javantura v4 - Security architecture of the Java platform - Martin ToshevJavantura v4 - Security architecture of the Java platform - Martin Toshev
Javantura v4 - Security architecture of the Java platform - Martin Toshev
 
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
Security Architecture of the Java Platform (BG OUG, Plovdiv, 13.06.2015)
 
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexusMicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
MicroProfile, Docker, Kubernetes, Istio and Open Shift lab @dev nexus
 
Security Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java PlatformSecurity Аrchitecture of Тhe Java Platform
Security Аrchitecture of Тhe Java Platform
 
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
A Cocktail of Guice and Seam, the missing ingredients for Java EE 6
 
GR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug inGR8Conf 2011: Grails, how to plug in
GR8Conf 2011: Grails, how to plug in
 
Build12 factorappusingmp
Build12 factorappusingmpBuild12 factorappusingmp
Build12 factorappusingmp
 
Hardening Kubernetes by Securing Pods
Hardening Kubernetes by Securing PodsHardening Kubernetes by Securing Pods
Hardening Kubernetes by Securing Pods
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With Testcontainers
 
Container security Familiar problems in new technology
Container security Familiar problems in new technologyContainer security Familiar problems in new technology
Container security Familiar problems in new technology
 
Aleksei Dremin - Application Security Pipeline - phdays9
Aleksei Dremin - Application Security Pipeline - phdays9Aleksei Dremin - Application Security Pipeline - phdays9
Aleksei Dremin - Application Security Pipeline - phdays9
 
Toward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malwareToward dynamic analysis of obfuscated android malware
Toward dynamic analysis of obfuscated android malware
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020
 
Cloud nativemicroservices jax-london2020
Cloud nativemicroservices   jax-london2020Cloud nativemicroservices   jax-london2020
Cloud nativemicroservices jax-london2020
 
Is OSGi Modularity Always Worth It? - Glyn Normington
Is OSGi Modularity Always Worth It? - Glyn NormingtonIs OSGi Modularity Always Worth It? - Glyn Normington
Is OSGi Modularity Always Worth It? - Glyn Normington
 

Mais de Saltmarch Media

Mais de Saltmarch Media (17)

Concocting an MVC, Data Services and Entity Framework solution for Azure
Concocting an MVC, Data Services and Entity Framework solution for AzureConcocting an MVC, Data Services and Entity Framework solution for Azure
Concocting an MVC, Data Services and Entity Framework solution for Azure
 
Caring about Code Quality
Caring about Code QualityCaring about Code Quality
Caring about Code Quality
 
Learning Open Source Business Intelligence
Learning Open Source Business IntelligenceLearning Open Source Business Intelligence
Learning Open Source Business Intelligence
 
Java EE 7: the Voyage of the Cloud Treader
Java EE 7: the Voyage of the Cloud TreaderJava EE 7: the Voyage of the Cloud Treader
Java EE 7: the Voyage of the Cloud Treader
 
Is NoSQL The Future of Data Storage?
Is NoSQL The Future of Data Storage?Is NoSQL The Future of Data Storage?
Is NoSQL The Future of Data Storage?
 
Introduction to WCF RIA Services for Silverlight 4 Developers
Introduction to WCF RIA Services for Silverlight 4 DevelopersIntroduction to WCF RIA Services for Silverlight 4 Developers
Introduction to WCF RIA Services for Silverlight 4 Developers
 
Integrated Services for Web Applications
Integrated Services for Web ApplicationsIntegrated Services for Web Applications
Integrated Services for Web Applications
 
Gaelyk - Web Apps In Practically No Time
Gaelyk - Web Apps In Practically No TimeGaelyk - Web Apps In Practically No Time
Gaelyk - Web Apps In Practically No Time
 
JBoss at Work: Using JBoss AS 6
JBoss at Work: Using JBoss AS 6JBoss at Work: Using JBoss AS 6
JBoss at Work: Using JBoss AS 6
 
WF and WCF with AppFabric – Application Infrastructure for OnPremise Services
WF and WCF with AppFabric – Application Infrastructure for OnPremise ServicesWF and WCF with AppFabric – Application Infrastructure for OnPremise Services
WF and WCF with AppFabric – Application Infrastructure for OnPremise Services
 
“What did I do?” - T-SQL Worst Practices
“What did I do?” - T-SQL Worst Practices“What did I do?” - T-SQL Worst Practices
“What did I do?” - T-SQL Worst Practices
 
Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0Building RESTful Services with WCF 4.0
Building RESTful Services with WCF 4.0
 
Building Facebook Applications on Windows Azure
Building Facebook Applications on Windows AzureBuilding Facebook Applications on Windows Azure
Building Facebook Applications on Windows Azure
 
Architecting Smarter Apps with Entity Framework
Architecting Smarter Apps with Entity FrameworkArchitecting Smarter Apps with Entity Framework
Architecting Smarter Apps with Entity Framework
 
Agile Estimation
Agile EstimationAgile Estimation
Agile Estimation
 
Alternate JVM Languages
Alternate JVM LanguagesAlternate JVM Languages
Alternate JVM Languages
 
A Bit of Design Thinking for Developers
A Bit of Design Thinking for DevelopersA Bit of Design Thinking for Developers
A Bit of Design Thinking for Developers
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

CDI and Seam 3: an Exciting New Landscape for Java EE Development

  • 1. CDI and Seam 3 An exciting new landscape for Java EE development Shane Bryzak 21/04/10
  • 2. The History of Seam (In 2 minutes or less) • First beta in September 2005 • 1.0.0.GA released in June 2006 • 2.0.0.GA released in November 2007 2
  • 5. 5
  • 6. 6
  • 7. JSR-299 Implementations • Weld (by Red Hat - Reference Implementation) • OpenWebBeans (by Apache) • CanDI (by Caucho) 7
  • 8. Portable Extensions • One of the most exciting features in CDI • Extend the behaviour of the Java EE platform • Seam 3 is a collection of portable extensions • SPI defined by the JSR-299 spec • Easy to write 8
  • 9. Just how easy? 3 simple steps: • Create a new Java class • Register the extension • Implement the extension logic 9
  • 10. Portable Extensions Creating the Java class package com.acme; import javax.enterprise.inject.spi.Extension; public class MyExtension implements Extension { } 10
  • 11. Portable Extensions Registering the extension • Create a file in the META-INF/services directory called javax.enterprise.inject.spi.Extension • It should contain the name of your class com.acme.MyExtension 11
  • 12. Portable Extensions Implementing the extension logic • Listen to events fired by the container at deployment time • Extensions can observe these events and make changes to the containers metadata model • Dynamically change the default behaviour of beans, injection points • Implement new context types 12
  • 13. A real world example Seam Security • Portable extension for CDI • Provides authentication, identity management and federated identity via OpenID, SAML, SSO • Provides typesafe authorization through the use of annotation-based metadata 13
  • 15. Typesafe authorization @Manager public void generateSalesReport() { ... } 15
  • 16. Typesafe authorization @Secures @Manager public boolean isManager(Identity identity) { return identity.hasRole("manager", "USERS", "GROUP"); } 16
  • 17. The extension must: • Match all methods annotated with a security binding type with an authorizer method • Add an interceptor binding to the secured method • Throw an exception if there are any secured methods without a matching authorizer method 17
  • 18. Scanning the methods ProcessAnnotatedType Event • Fired by the container for each Java class or interface it discovers • We can use this event to find classes or methods annotated with security binding types • Our extension class can observe this event 18
  • 19. Event observers public class SecurityExtension implements Extension { public <X> void processAnnotatedType( @Observes ProcessAnnotatedType<X> event, final BeanManager beanManager) { ... } 19
  • 20. Interceptors • Interceptors specification part of JSR-318 • CDI builds on this specification by introducing interceptor bindings • Interceptor bindings are used to create a link between an interceptor and the bean to be intercepted 20
  • 21. Interceptor Bindings How they work • Create an interceptor binding annotation • Apply it to the interceptor class • Apply it to the method or class that you want to be intercepted 21
  • 22. Interceptor Bindings Creating the binding type @Retention(RUNTIME) @InterceptorBinding @Target( { TYPE, METHOD }) @interface SecurityInterceptorBinding { } 22
  • 23. Interceptor Bindings Applying to the Interceptor @SecurityInterceptorBinding @Interceptor public class SecurityInterceptor implements Serializable { @Inject SecurityExtension extension; @AroundInvoke public Object aroundInvoke(InvocationContext invocation) throws Exception { 23
  • 24. Interceptor Bindings Applying it to a method public @Model class DocumentAction { @SecurityInterceptorBinding public void createDocument() { } } 24
  • 25. Dynamic interceptors • Our extension can apply an interceptor binding dynamically, at deployment time • (Code demo - Eclipse) 25