SlideShare a Scribd company logo
Apache Incubator OpenWebBeans Gurkan Erdogdu Conny Lundgren Matthias Wessendorf Kevan Miller Apache Incubator Free and Open Source
What is OpenWebBeans Implementation of the JSR-299 WebBeans Incubated in the Apache Software Foundation http://incubator.apache.org/openwebbeans http://incubator.apache.org
What is a WebBeans? Dependency injection service between Java EE components EJB Components Servlet Components Java Beans Components Easy use of EJB 3.1 components as first class managed bean in the JSF environment Type-safe API deployment Interceptors and Decorators
Continue... Loosely coupled components with powerful Event and Observer mechanism  Context management Conversation context ? Lifecycle management Manages all of the Java EE components lifecycles Extensible Easily extensible with Manager runtime
Web Bean Definition Simple Web Beans No action is required Every Java Beans is a simpe web bean Enterprise Web Beans EJB session beans Producer Methods JMS Endpoints
Web Bean Definition API Types Binding types Scopes Deployment types Names StereoTypes Specialization
API Type Simple Web Bean public class Bean implements IBean{} Class, super class and interfaces, directly or indirectly Above : Bean, IBean, Object EJB Components @Stateless class PaymentProcessorImpl implements PaymentProcessor { ... } LocalInterfaces Above : Local interfaces (PaymentProcessor)
API Type continue Producer Methods public Product getProduct(){} Return type, super class, interfaces directly or indirectly Above : Product, Object JMS End points Queue : Queue, QueueConnection, QueueSession and QueueSender + Object Topic : Topic, TopicConnection, TopicSession and TopicPublisher + Object
Binding Types Seperates implementations from each other Annotation driven Annotated with @BindingType Example, 2 binding types @BindingType public @interface CreditCardPayment @BindingType public @interface DebitCardPayment
Binding Types One interface, two implementation, dependency injection, just BindingType ?  Seperation with @BindingType, HOW? public class PaymentProcessor{ Ipayment payment; -> Which payment type? } public class PaymentProcessor{ @CreditCardPayment IPayment payment; -> Credit Card } public class PaymentProcessor{ @DebitCardPayment IPayment payment; -> Debit Card }
Scopes RequestScoped SessionScoped ApplicationScoped ConversationScoped DependentScoped Or your defined scope, annotated @ScopeType @ScopeType Public @interface MyScope{}
Deployment Types Cleanly seperate your beans at run time Test environment enabled Web Beans or Production ready web beans Easy test your beans Example: @Production -> Use in my production run time public class PaymentProcessor implement  Processor { } @Test -> Use in my test run time public class TestProcessor implement  Processor { } Injection :  Processor  instance ??? -> which bean it selects?
Name Web Beans has name @Named annotation @Named(value=”actual name”) Default Name, if no value is provided Class Name -> public class PaymentProcessor Name : paymentProcessor Method name -> Products getProducts() Name : products  No name is no @Named annotation
StereoTypes Like class inheritance No repeat yourself Just inherit model Inherit annotations Annotated with @StereoType @StereoType @RequestScoped @Production @Named public @interface MyStereoType
StereoType Easily create web bean annotations EXAMPLE : MyNewBean inherits from stereotypes. @MyStereoType public class MyNewBean{} Inherit :ScopeType, DeploymentType and Default Named indicator from MyStereoType
Specialization Related with web beans resolution semantic Clear in the next slides Normally injection service resolves web beans with API type Binding Type Precedence
Specialization Lets say two DeploymentType Type1 and Type2 and Type1 precedence > Type2 Normally we want Production @BindingType1 @Type1 Public class Production{} @BindingType2 @BindingType1 @Type2 Public class Mock{}
Specialization public class PaymentProcessor { @BindingType2 @BindingType1 IPayment payment; ->  we want Production?? } But gets Mock??? Why? Resolution rules? If we want always selectinh Production type web beans without Binding Type, then @Specializes rescue @Specializes public class Production extends Mock{} ->  Inhertis all BindingTypes  of Mock., now, @BindingType2 Ipayment payment selects Production
Resolutions Resolution By Name Name Precedence of the DeploymentType Resolution By Type API Type BindingType Precedence of the DeploymentType
Injected Fields Inject fields of the web beans Public class MyBean { @Logger Log logger; ->  Inject for me after creation }
Initializer Methods Initializer Methods of the web bean @Production Public class PaymentProcessor { Ipayment payment; @Initialize public void createPaymentProcessor(@CreditCard IPayment processor) ->  Inject for me after creation this.payment = processor; }
Constructor Initializer Inject into web beans  constructor @Production @RequestScoped public class PaymentProcessor { ->  Inject into the my constructor while creating public PaymentProcessor(@CreditCard Ipayment payment) { } }
EL Resolution EL Resolution Resolve by name Use in JSF or JSP page @RequestScoped @Named public class LoginBean @Produces @SessionScoped @LoggedInUser @Named(value="currentUser") public User getLoggedInUser() {   return this.user ; } public void login() { User user = new User(); this.user = user;}
EL Resolution <h:inputText id=&quot;userName&quot; value=&quot;#{loginBean.userName}&quot;></h:inputText> <h:inputText id=&quot;password&quot; value=&quot;#{loginBean.password}&quot;></h:inputText> <h:commandButton action=&quot;#{loginBean.login}&quot; value=&quot;Login&quot;></h:commandButton>
EL Resolution Welcome Page, gets user name and password from the @CurrentUser <div align=&quot;right&quot;> <h:commandLink value=&quot;Logout&quot; action=&quot;#{logoutBean.logout}&quot;></h:commandLink> </div> <div> <h:outputText value=&quot;Merhaba #{currentUser.userName} #{currentUser.password}&quot;></h:outputText> </div>
LifeCycle of WebBeans Create Inject fields Initialize Methods Life cycle annotations, @PostConstruct, @PreDestroy Interceptors for orthogonal processes Decorators for business processes Common annotations, @EJB Destroy
Interceptors Interceptor with @InterceptorBindingType @InterceptorBindingType Public @interface Transactional{} -> Interceptor @Transactional  ->  Class level Public class Payment{ @Transactional ->  Method level public void payment(){} }
Interceptors Business Level Interceptors Business method invocation Life Cycle Interceptors Web Bean life cycle @PostConstruct @PreDestroy @PrePassivate @PreActivate
Interceptor Example @Transactional public class MyTransactionInterceptor { @AroundInvoke ->  called just before my business method public void invoke(InvocationContext context) { } }
Decorators For specific business  method Can be abstract Example: @Decorator public class MyDecorator implement Ipayment { @Decorates @CreditCard IPayment payment;  -> Specific web bean public void pay() ->  Specific business method { } }
Events Loosely Coupled Interaction Events Event type Event binding type Observers Observable annotation Transactional observers
Observers public class PaymentObserver implements Observer<PaymentDoneEvent> { public void notify(PaymentDoneEvent event) { } }
Events @Observes annotation, observes given event type public class PaymentDoneBean { public void afterPayment(@Observes PaymentDoneEvent event) { } }
Events Fire events via Manager API public void pay() {  manager.fireEvent(new PaymentDoneEvent(user)) }
Event @Observable annotation Register observers via event Custom web bean with Event API Fire events via event public class LoginBean {  private @Observable Event<LoggedInEvent> event;  -> Runtime provided Event bean public void afterLoggedIn() { LoggedInEvent loggedIn = new LoggedInEvent(&quot;Gurkan&quot;); event.fire(loggedIn, anns); ->  Fire event via Event }
Scope and Contexts Active Scope Active context with respect to the current thread Passive Scope Passive context with respect to the current thread ContextNotActiveException if access Context passivation Passivation in passivated type context. Save its context info into the disk
XML Configuration Some third party class Not able to annotate Candidate for XML configuration XML namespace for Java package <WebBeans xmlns=&quot;urn:java:javax.webbeans&quot; xmlns:myapp=&quot;urn:java:com.mydomain.myapp&quot;> ... </WebBeans>
Java EE 6.0 JSR- 316 Easy management of the Enterprise Projects
Questions QUESTIONS?? Thank you!

More Related Content

What's hot (20)

React render props
React render propsReact render props
React render props
Saikat Samanta
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
Joonas Lehtinen
 
GWT integration with Vaadin
GWT integration with VaadinGWT integration with Vaadin
GWT integration with Vaadin
Peter Lehto
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
 
Jsf intro
Jsf introJsf intro
Jsf intro
vantinhkhuc
 
Part 2 generating a client_from_wsdl
Part 2 generating a client_from_wsdlPart 2 generating a client_from_wsdl
Part 2 generating a client_from_wsdl
krishmdkk
 
ajax_pdf
ajax_pdfajax_pdf
ajax_pdf
tutorialsruby
 
Angularjs 2
Angularjs 2 Angularjs 2
Angularjs 2
Cubet Techno Labs
 
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
Codemotion
 
Jug Guice Presentation
Jug Guice PresentationJug Guice Presentation
Jug Guice Presentation
Dmitry Buzdin
 
Android Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmAndroid Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG Stockholm
Johan Nilsson
 
當ZK遇見Front-End
當ZK遇見Front-End當ZK遇見Front-End
當ZK遇見Front-End
祁源 朱
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
Jeado Ko
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
Pamela Fox
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
BizTalk360
 
Introduction to Vaadin
Introduction to VaadinIntroduction to Vaadin
Introduction to Vaadin
netomi
 
Vaadin with Java EE 7
Vaadin with Java EE 7Vaadin with Java EE 7
Vaadin with Java EE 7
Peter Lehto
 
Binding business data to vaadin components
Binding business data to vaadin componentsBinding business data to vaadin components
Binding business data to vaadin components
Peter Lehto
 
JavaEE with Vaadin - Workshop
JavaEE with Vaadin - WorkshopJavaEE with Vaadin - Workshop
JavaEE with Vaadin - Workshop
Peter Lehto
 
Web Components for Java Developers
Web Components for Java DevelopersWeb Components for Java Developers
Web Components for Java Developers
Joonas Lehtinen
 
GWT integration with Vaadin
GWT integration with VaadinGWT integration with Vaadin
GWT integration with Vaadin
Peter Lehto
 
AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
Ran Wahle
 
Part 2 generating a client_from_wsdl
Part 2 generating a client_from_wsdlPart 2 generating a client_from_wsdl
Part 2 generating a client_from_wsdl
krishmdkk
 
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
The Web Components interoperability challenge - Horacio Gonzalez - Codemotion...
Codemotion
 
Jug Guice Presentation
Jug Guice PresentationJug Guice Presentation
Jug Guice Presentation
Dmitry Buzdin
 
Android Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG StockholmAndroid Cloud to Device Messaging Framework at GTUG Stockholm
Android Cloud to Device Messaging Framework at GTUG Stockholm
Johan Nilsson
 
當ZK遇見Front-End
當ZK遇見Front-End當ZK遇見Front-End
當ZK遇見Front-End
祁源 朱
 
[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법[FEConf Korea 2017]Angular 컴포넌트 대화법
[FEConf Korea 2017]Angular 컴포넌트 대화법
Jeado Ko
 
OpenSocial Intro
OpenSocial IntroOpenSocial Intro
OpenSocial Intro
Pamela Fox
 
JavaScript - Chapter 14 - Form Handling
 JavaScript - Chapter 14 - Form Handling   JavaScript - Chapter 14 - Form Handling
JavaScript - Chapter 14 - Form Handling
WebStackAcademy
 
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
Use Windows Azure Service Bus, BizTalk Services, Mobile Services, and BizTalk...
BizTalk360
 
Introduction to Vaadin
Introduction to VaadinIntroduction to Vaadin
Introduction to Vaadin
netomi
 
Vaadin with Java EE 7
Vaadin with Java EE 7Vaadin with Java EE 7
Vaadin with Java EE 7
Peter Lehto
 
Binding business data to vaadin components
Binding business data to vaadin componentsBinding business data to vaadin components
Binding business data to vaadin components
Peter Lehto
 
JavaEE with Vaadin - Workshop
JavaEE with Vaadin - WorkshopJavaEE with Vaadin - Workshop
JavaEE with Vaadin - Workshop
Peter Lehto
 

Viewers also liked (7)

OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheCon
os890
 
Make JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODIMake JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODI
os890
 
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpikeMyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
os890
 
MyFaces Universe at ApacheCon
MyFaces Universe at ApacheConMyFaces Universe at ApacheCon
MyFaces Universe at ApacheCon
os890
 
Flexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpikeFlexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpike
os890
 
MyFaces CODI Conversations
MyFaces CODI ConversationsMyFaces CODI Conversations
MyFaces CODI Conversations
os890
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
os890
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheCon
os890
 
Make JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODIMake JSF more type-safe with CDI and MyFaces CODI
Make JSF more type-safe with CDI and MyFaces CODI
os890
 
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpikeMyFaces CODI and JBoss Seam3 become Apache DeltaSpike
MyFaces CODI and JBoss Seam3 become Apache DeltaSpike
os890
 
MyFaces Universe at ApacheCon
MyFaces Universe at ApacheConMyFaces Universe at ApacheCon
MyFaces Universe at ApacheCon
os890
 
Flexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpikeFlexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpike
os890
 
MyFaces CODI Conversations
MyFaces CODI ConversationsMyFaces CODI Conversations
MyFaces CODI Conversations
os890
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
os890
 

Similar to OpenWebBeans/Web Beans (20)

CDI @javaonehyderabad
CDI @javaonehyderabadCDI @javaonehyderabad
CDI @javaonehyderabad
Prasad Subramanian
 
S313937 cdi dochez
S313937 cdi dochezS313937 cdi dochez
S313937 cdi dochez
Jerome Dochez
 
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 EcosystemSpark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Arun Gupta
 
Using Contexts & Dependency Injection in the Java EE 6 Platform
Using Contexts & Dependency Injection in the Java EE 6 PlatformUsing Contexts & Dependency Injection in the Java EE 6 Platform
Using Contexts & Dependency Injection in the Java EE 6 Platform
Arun Gupta
 
Introduction To Web Beans
Introduction To Web BeansIntroduction To Web Beans
Introduction To Web Beans
Eduardo Pelegri-Llopart
 
Spring training
Spring trainingSpring training
Spring training
TechFerry
 
Ejb3 Dan Hinojosa
Ejb3 Dan HinojosaEjb3 Dan Hinojosa
Ejb3 Dan Hinojosa
Dan Hinojosa
 
The future of enterprise dependency injection: Contexts & Dependency Injectio...
The future of enterprise dependency injection: Contexts & Dependency Injectio...The future of enterprise dependency injection: Contexts & Dependency Injectio...
The future of enterprise dependency injection: Contexts & Dependency Injectio...
Paul Bakker
 
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
 
1/3 : introduction to CDI - Antoine Sabot-Durand
1/3 : introduction to CDI - Antoine Sabot-Durand1/3 : introduction to CDI - Antoine Sabot-Durand
1/3 : introduction to CDI - Antoine Sabot-Durand
SOAT
 
EJB 3.0 Walkthrough (2006)
EJB 3.0 Walkthrough (2006)EJB 3.0 Walkthrough (2006)
EJB 3.0 Walkthrough (2006)
Peter Antman
 
Spring IOC and DAO
Spring IOC and DAOSpring IOC and DAO
Spring IOC and DAO
AnushaNaidu
 
Spring frame work
Spring frame workSpring frame work
Spring frame work
husnara mohammad
 
Spring, web service, web server, eclipse by a introduction sandesh sharma
Spring, web service, web server, eclipse by a introduction sandesh sharmaSpring, web service, web server, eclipse by a introduction sandesh sharma
Spring, web service, web server, eclipse by a introduction sandesh sharma
Sandesh Sharma
 
Spring talk111204
Spring talk111204Spring talk111204
Spring talk111204
ealio
 
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
Rohit Kelapure
 
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
Rohit Kelapure
 
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business Logic
Emprovise
 
CDI and Weld
CDI and WeldCDI and Weld
CDI and Weld
Redpill Linpro
 
Contexts and Dependency Injection for the JavaEE platform
Contexts and Dependency Injection for the JavaEE platformContexts and Dependency Injection for the JavaEE platform
Contexts and Dependency Injection for the JavaEE platform
Bozhidar Bozhanov
 
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 EcosystemSpark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Spark IT 2011 - Context & Dependency Injection in the Java EE 6 Ecosystem
Arun Gupta
 
Using Contexts & Dependency Injection in the Java EE 6 Platform
Using Contexts & Dependency Injection in the Java EE 6 PlatformUsing Contexts & Dependency Injection in the Java EE 6 Platform
Using Contexts & Dependency Injection in the Java EE 6 Platform
Arun Gupta
 
Spring training
Spring trainingSpring training
Spring training
TechFerry
 
The future of enterprise dependency injection: Contexts & Dependency Injectio...
The future of enterprise dependency injection: Contexts & Dependency Injectio...The future of enterprise dependency injection: Contexts & Dependency Injectio...
The future of enterprise dependency injection: Contexts & Dependency Injectio...
Paul Bakker
 
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
 
1/3 : introduction to CDI - Antoine Sabot-Durand
1/3 : introduction to CDI - Antoine Sabot-Durand1/3 : introduction to CDI - Antoine Sabot-Durand
1/3 : introduction to CDI - Antoine Sabot-Durand
SOAT
 
EJB 3.0 Walkthrough (2006)
EJB 3.0 Walkthrough (2006)EJB 3.0 Walkthrough (2006)
EJB 3.0 Walkthrough (2006)
Peter Antman
 
Spring IOC and DAO
Spring IOC and DAOSpring IOC and DAO
Spring IOC and DAO
AnushaNaidu
 
Spring, web service, web server, eclipse by a introduction sandesh sharma
Spring, web service, web server, eclipse by a introduction sandesh sharmaSpring, web service, web server, eclipse by a introduction sandesh sharma
Spring, web service, web server, eclipse by a introduction sandesh sharma
Sandesh Sharma
 
Spring talk111204
Spring talk111204Spring talk111204
Spring talk111204
ealio
 
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
Rohit Kelapure
 
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final2012 04-09-v2-tdp-1167-cdi-bestpractices-final
2012 04-09-v2-tdp-1167-cdi-bestpractices-final
Rohit Kelapure
 
Enterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business LogicEnterprise Java Beans 3 - Business Logic
Enterprise Java Beans 3 - Business Logic
Emprovise
 
Contexts and Dependency Injection for the JavaEE platform
Contexts and Dependency Injection for the JavaEE platformContexts and Dependency Injection for the JavaEE platform
Contexts and Dependency Injection for the JavaEE platform
Bozhidar Bozhanov
 

Recently uploaded (20)

Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
What’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptxWhat’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptx
Lisa ward
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
STKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 versionSTKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 version
Dr. Jimmy Schwarzkopf
 
The 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptxThe 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptx
aptyai
 
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Lorenzo Miniero
 
John Carmack’s Slides From His Upper Bound 2025 Talk
John Carmack’s Slides From His Upper Bound 2025 TalkJohn Carmack’s Slides From His Upper Bound 2025 Talk
John Carmack’s Slides From His Upper Bound 2025 Talk
Razin Mustafiz
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Introducing Ensemble Cloudlet vRouter
Introducing Ensemble  Cloudlet vRouterIntroducing Ensemble  Cloudlet vRouter
Introducing Ensemble Cloudlet vRouter
Adtran
 
What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!
cryptouniversityoffi
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCPMCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
Sambhav Kothari
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...
Ivan Ruchkin
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
Supercharge Your AI Development with Local LLMs
Supercharge Your AI Development with Local LLMsSupercharge Your AI Development with Local LLMs
Supercharge Your AI Development with Local LLMs
Francesco Corti
 
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Nikki Chapple
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure ModesCognitive Chasms - A Typology of GenAI Failure Failure Modes
Cognitive Chasms - A Typology of GenAI Failure Failure Modes
Dr. Tathagat Varma
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
What’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptxWhat’s New in Web3 Development Trends to Watch in 2025.pptx
What’s New in Web3 Development Trends to Watch in 2025.pptx
Lisa ward
 
Introducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and ARIntroducing FME Realize: A New Era of Spatial Computing and AR
Introducing FME Realize: A New Era of Spatial Computing and AR
Safe Software
 
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath InsightsUiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPath Community Berlin: Studio Tips & Tricks and UiPath Insights
UiPathCommunity
 
STKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 versionSTKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 version
Dr. Jimmy Schwarzkopf
 
The 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptxThe 2025 Digital Adoption Blueprint.pptx
The 2025 Digital Adoption Blueprint.pptx
aptyai
 
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Multistream in SIP and NoSIP @ OpenSIPS Summit 2025
Lorenzo Miniero
 
John Carmack’s Slides From His Upper Bound 2025 Talk
John Carmack’s Slides From His Upper Bound 2025 TalkJohn Carmack’s Slides From His Upper Bound 2025 Talk
John Carmack’s Slides From His Upper Bound 2025 Talk
Razin Mustafiz
 
SDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhereSDG 9000 Series: Unleashing multigigabit everywhere
SDG 9000 Series: Unleashing multigigabit everywhere
Adtran
 
Introducing Ensemble Cloudlet vRouter
Introducing Ensemble  Cloudlet vRouterIntroducing Ensemble  Cloudlet vRouter
Introducing Ensemble Cloudlet vRouter
Adtran
 
What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!What is DePIN? The Hottest Trend in Web3 Right Now!
What is DePIN? The Hottest Trend in Web3 Right Now!
cryptouniversityoffi
 
Gihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai TechnologyGihbli AI and Geo sitution |use/misuse of Ai Technology
Gihbli AI and Geo sitution |use/misuse of Ai Technology
zainkhurram1111
 
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCPMCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
MCP Dev Summit - Pragmatic Scaling of Enterprise GenAI with MCP
Sambhav Kothari
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification o...
Ivan Ruchkin
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
Supercharge Your AI Development with Local LLMs
Supercharge Your AI Development with Local LLMsSupercharge Your AI Development with Local LLMs
Supercharge Your AI Development with Local LLMs
Francesco Corti
 
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Protecting Your Sensitive Data with Microsoft Purview - IRMS 2025
Nikki Chapple
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 

OpenWebBeans/Web Beans

  • 1. Apache Incubator OpenWebBeans Gurkan Erdogdu Conny Lundgren Matthias Wessendorf Kevan Miller Apache Incubator Free and Open Source
  • 2. What is OpenWebBeans Implementation of the JSR-299 WebBeans Incubated in the Apache Software Foundation http://incubator.apache.org/openwebbeans http://incubator.apache.org
  • 3. What is a WebBeans? Dependency injection service between Java EE components EJB Components Servlet Components Java Beans Components Easy use of EJB 3.1 components as first class managed bean in the JSF environment Type-safe API deployment Interceptors and Decorators
  • 4. Continue... Loosely coupled components with powerful Event and Observer mechanism Context management Conversation context ? Lifecycle management Manages all of the Java EE components lifecycles Extensible Easily extensible with Manager runtime
  • 5. Web Bean Definition Simple Web Beans No action is required Every Java Beans is a simpe web bean Enterprise Web Beans EJB session beans Producer Methods JMS Endpoints
  • 6. Web Bean Definition API Types Binding types Scopes Deployment types Names StereoTypes Specialization
  • 7. API Type Simple Web Bean public class Bean implements IBean{} Class, super class and interfaces, directly or indirectly Above : Bean, IBean, Object EJB Components @Stateless class PaymentProcessorImpl implements PaymentProcessor { ... } LocalInterfaces Above : Local interfaces (PaymentProcessor)
  • 8. API Type continue Producer Methods public Product getProduct(){} Return type, super class, interfaces directly or indirectly Above : Product, Object JMS End points Queue : Queue, QueueConnection, QueueSession and QueueSender + Object Topic : Topic, TopicConnection, TopicSession and TopicPublisher + Object
  • 9. Binding Types Seperates implementations from each other Annotation driven Annotated with @BindingType Example, 2 binding types @BindingType public @interface CreditCardPayment @BindingType public @interface DebitCardPayment
  • 10. Binding Types One interface, two implementation, dependency injection, just BindingType ? Seperation with @BindingType, HOW? public class PaymentProcessor{ Ipayment payment; -> Which payment type? } public class PaymentProcessor{ @CreditCardPayment IPayment payment; -> Credit Card } public class PaymentProcessor{ @DebitCardPayment IPayment payment; -> Debit Card }
  • 11. Scopes RequestScoped SessionScoped ApplicationScoped ConversationScoped DependentScoped Or your defined scope, annotated @ScopeType @ScopeType Public @interface MyScope{}
  • 12. Deployment Types Cleanly seperate your beans at run time Test environment enabled Web Beans or Production ready web beans Easy test your beans Example: @Production -> Use in my production run time public class PaymentProcessor implement Processor { } @Test -> Use in my test run time public class TestProcessor implement Processor { } Injection : Processor instance ??? -> which bean it selects?
  • 13. Name Web Beans has name @Named annotation @Named(value=”actual name”) Default Name, if no value is provided Class Name -> public class PaymentProcessor Name : paymentProcessor Method name -> Products getProducts() Name : products No name is no @Named annotation
  • 14. StereoTypes Like class inheritance No repeat yourself Just inherit model Inherit annotations Annotated with @StereoType @StereoType @RequestScoped @Production @Named public @interface MyStereoType
  • 15. StereoType Easily create web bean annotations EXAMPLE : MyNewBean inherits from stereotypes. @MyStereoType public class MyNewBean{} Inherit :ScopeType, DeploymentType and Default Named indicator from MyStereoType
  • 16. Specialization Related with web beans resolution semantic Clear in the next slides Normally injection service resolves web beans with API type Binding Type Precedence
  • 17. Specialization Lets say two DeploymentType Type1 and Type2 and Type1 precedence > Type2 Normally we want Production @BindingType1 @Type1 Public class Production{} @BindingType2 @BindingType1 @Type2 Public class Mock{}
  • 18. Specialization public class PaymentProcessor { @BindingType2 @BindingType1 IPayment payment; -> we want Production?? } But gets Mock??? Why? Resolution rules? If we want always selectinh Production type web beans without Binding Type, then @Specializes rescue @Specializes public class Production extends Mock{} -> Inhertis all BindingTypes of Mock., now, @BindingType2 Ipayment payment selects Production
  • 19. Resolutions Resolution By Name Name Precedence of the DeploymentType Resolution By Type API Type BindingType Precedence of the DeploymentType
  • 20. Injected Fields Inject fields of the web beans Public class MyBean { @Logger Log logger; -> Inject for me after creation }
  • 21. Initializer Methods Initializer Methods of the web bean @Production Public class PaymentProcessor { Ipayment payment; @Initialize public void createPaymentProcessor(@CreditCard IPayment processor) -> Inject for me after creation this.payment = processor; }
  • 22. Constructor Initializer Inject into web beans constructor @Production @RequestScoped public class PaymentProcessor { -> Inject into the my constructor while creating public PaymentProcessor(@CreditCard Ipayment payment) { } }
  • 23. EL Resolution EL Resolution Resolve by name Use in JSF or JSP page @RequestScoped @Named public class LoginBean @Produces @SessionScoped @LoggedInUser @Named(value=&quot;currentUser&quot;) public User getLoggedInUser() { return this.user ; } public void login() { User user = new User(); this.user = user;}
  • 24. EL Resolution <h:inputText id=&quot;userName&quot; value=&quot;#{loginBean.userName}&quot;></h:inputText> <h:inputText id=&quot;password&quot; value=&quot;#{loginBean.password}&quot;></h:inputText> <h:commandButton action=&quot;#{loginBean.login}&quot; value=&quot;Login&quot;></h:commandButton>
  • 25. EL Resolution Welcome Page, gets user name and password from the @CurrentUser <div align=&quot;right&quot;> <h:commandLink value=&quot;Logout&quot; action=&quot;#{logoutBean.logout}&quot;></h:commandLink> </div> <div> <h:outputText value=&quot;Merhaba #{currentUser.userName} #{currentUser.password}&quot;></h:outputText> </div>
  • 26. LifeCycle of WebBeans Create Inject fields Initialize Methods Life cycle annotations, @PostConstruct, @PreDestroy Interceptors for orthogonal processes Decorators for business processes Common annotations, @EJB Destroy
  • 27. Interceptors Interceptor with @InterceptorBindingType @InterceptorBindingType Public @interface Transactional{} -> Interceptor @Transactional -> Class level Public class Payment{ @Transactional -> Method level public void payment(){} }
  • 28. Interceptors Business Level Interceptors Business method invocation Life Cycle Interceptors Web Bean life cycle @PostConstruct @PreDestroy @PrePassivate @PreActivate
  • 29. Interceptor Example @Transactional public class MyTransactionInterceptor { @AroundInvoke -> called just before my business method public void invoke(InvocationContext context) { } }
  • 30. Decorators For specific business method Can be abstract Example: @Decorator public class MyDecorator implement Ipayment { @Decorates @CreditCard IPayment payment; -> Specific web bean public void pay() -> Specific business method { } }
  • 31. Events Loosely Coupled Interaction Events Event type Event binding type Observers Observable annotation Transactional observers
  • 32. Observers public class PaymentObserver implements Observer<PaymentDoneEvent> { public void notify(PaymentDoneEvent event) { } }
  • 33. Events @Observes annotation, observes given event type public class PaymentDoneBean { public void afterPayment(@Observes PaymentDoneEvent event) { } }
  • 34. Events Fire events via Manager API public void pay() { manager.fireEvent(new PaymentDoneEvent(user)) }
  • 35. Event @Observable annotation Register observers via event Custom web bean with Event API Fire events via event public class LoginBean { private @Observable Event<LoggedInEvent> event; -> Runtime provided Event bean public void afterLoggedIn() { LoggedInEvent loggedIn = new LoggedInEvent(&quot;Gurkan&quot;); event.fire(loggedIn, anns); -> Fire event via Event }
  • 36. Scope and Contexts Active Scope Active context with respect to the current thread Passive Scope Passive context with respect to the current thread ContextNotActiveException if access Context passivation Passivation in passivated type context. Save its context info into the disk
  • 37. XML Configuration Some third party class Not able to annotate Candidate for XML configuration XML namespace for Java package <WebBeans xmlns=&quot;urn:java:javax.webbeans&quot; xmlns:myapp=&quot;urn:java:com.mydomain.myapp&quot;> ... </WebBeans>
  • 38. Java EE 6.0 JSR- 316 Easy management of the Enterprise Projects