QCon SP Java EE: Extendable and Functional David Blevins Tomitribe #JavaEE @dblevins @tomitribe
QCon SP Talk Overview • Part 1: Extensibility • CDI Scopes • Connectors • Java EE 6-7 • Part 2: Functions • New API Opportunities with Java 8 • Killing annotations • Shift from Declarative to Programmatic • Java EE 8? #JavaEE @dblevins @tomitribe
QCon SP Part 1: Extendable CDI Scopes #JavaEE @dblevins @tomitribe
QCon SP Background • EJB and CDI Alignment • EJB slowly being deprecated • Functionality moving to CDI • CDI significantly more extendable #JavaEE @dblevins @tomitribe
QCon SP CDI and EJB Under the Covers #JavaEE @dblevins @tomitribe
CDI 1.0 EJB 3.1 QCon SP Proxy Proxy (Fake) (Fake) (Context/Scope) (Pool) 1. Resolution 1. Resolution Security Transaction 2. Services 2. Services Interceptors Interceptors Decorators Decorators Instance Instance 3. Invocation 3. Invocation (Real) (Real) #JavaEE @dblevins @tomitribe
CDI 1.1 EJB 3.2 QCon SP Proxy Proxy (Fake) (Fake) (Context/Scope) (Pool) 1. Resolution 1. Resolution Security Transaction Transaction 2. Services 2. Services Interceptors Interceptors Decorators Decorators Instance Instance 3. Invocation 3. Invocation (Real) (Real) #JavaEE @dblevins @tomitribe
QCon SP EJB/CDI Lifecycle Lineup • @Singleton • same as CDI @ApplicationScoped • @Stateful • applies to any CDI Scope, not just @SessionScoped • @Stateless • no CDI equivalent • @RequestScoped sort of close(ish) #JavaEE @dblevins @tomitribe
QCon SP Implementing a Scope • Create a new Scope Annotation • Create an implementation of Context • Register the Scope and Context via an Extension • Mark the boundaries • Logical concept • Always different #JavaEE @dblevins @tomitribe
QCon SP Custom Scope Examples #JavaEE @dblevins @tomitribe
QCon SP http://tomitribe.io/projects/ microscoped #JavaEE @dblevins @tomitribe
QCon SP Common Mistakes you will make • Not putting a beans.xml in your app (Java EE 6) • No CDI for you! • Not understanding @Typed • Psst, think @Local from EJB • Bites you when using @Produces • Not understanding what Dependent and NormalScope • Dependent == plain object • NormalScoped == proxied object • Bites you when creating custom scopes #JavaEE @dblevins @tomitribe
QCon SP Part 1: Extendable Connectors #JavaEE @dblevins @tomitribe
QCon SP Inbound Connectors (aka MDBs) #JavaEE @dblevins @tomitribe
QCon SP The following are all false • MDBs are for JMS • MDBs must be asynchronous • A MessageListener interface has one method which returns ‘void’ • MDBs are always pooled • MDBs are stateless #JavaEE @dblevins @tomitribe
QCon SP JMS MDB in Java EE 7 #JavaEE @dblevins @tomitribe
QCon SP Title Text • Body Level One • Body Level Two • Body Level Three • Body Level Four • Body Level Five #JavaEE @dblevins @tomitribe
QCon SP Title Text • Body Level One • Body Level Two • Body Level Three • Body Level Four • Body Level Five Bad Configuration #JavaEE @dblevins @tomitribe
QCon SP Title Text • Body Level One • Body Level Two • Body Level Three • Body Level Four • Body Level Five Boiler Plate #JavaEE @dblevins @tomitribe
QCon SP Title Text • Body Level One • Body Level Two • Body Level Three • Body Level Four • Body Level Five Only Useful Line of Code #JavaEE @dblevins @tomitribe
QCon SP JMS MDB in Java EE 8 #JavaEE @dblevins @tomitribe
QCon SP Oh yeah. #JavaEE @dblevins @tomitribe
QCon SP Custom Connector Examples #JavaEE @dblevins @tomitribe
QCon SP https://tomitribe.io/projects/ chatterbox https://tomitribe.io/projects/ sheldon #JavaEE @dblevins @tomitribe
QCon SP Part 2: Functional (Ideas for the Future) #JavaEE @dblevins @tomitribe
QCon SP Eras of Java EE XML Annotation Lambda • 1998 (start) • 2006 (start) • 2014* (start) • 2001 (strong) • 2009 (strong) • ???? (strong) #JavaEE @dblevins @tomitribe
QCon SP Opportunity for Impact • From Declarative to Programmatic • From Component-side to Caller-side • Large decrease in annotation and class overhead • Logic is mobile Impact of Opportunity • Potential Growth in mixed container and “API” code • Lifecycle compromises might need to be made • Will take time and effort (join in!) #JavaEE @dblevins @tomitribe
QCon SP Thank You! #JavaEE @dblevins @tomitribe
Recommend
More recommend