Transcript
QC
on S
P
@dblevins @tomitribe #JavaEE
Java EE:Extendable and Functional
David BlevinsTomitribe
QC
on S
P
@dblevins @tomitribe #JavaEE
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?
QC
on S
P
@dblevins @tomitribe #JavaEE
Part 1: ExtendableCDI Scopes
QC
on S
P
@dblevins @tomitribe #JavaEE
Background
• EJB and CDI Alignment• EJB slowly being deprecated• Functionality moving to CDI• CDI significantly more extendable
QC
on S
P
@dblevins @tomitribe #JavaEE
CDI and EJB Under the Covers
@dblevins @tomitribe #JavaEE
QC
on S
PProxy (Fake)
Proxy (Fake)
Interceptors
Decorators
Instance (Real)
Security
Transaction
Interceptors
Decorators
Instance (Real)
1. Resolution
2. Services
3. Invocation
(Pool)1. Resolution
2. Services
3. Invocation
(Context/Scope)
CDI 1.0 EJB 3.1
@dblevins @tomitribe #JavaEE
QC
on S
PProxy (Fake)
Proxy (Fake)
Security
Transaction
Interceptors
Decorators
Instance (Real)
1. Resolution
2. Services
3. Invocation
(Pool)1. Resolution
2. Services
3. Invocation
(Context/Scope)
CDI 1.1 EJB 3.2
Transaction
Interceptors
Decorators
Instance (Real)
QC
on S
P
@dblevins @tomitribe #JavaEE
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)
QC
on S
P
@dblevins @tomitribe #JavaEE
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
QC
on S
P
@dblevins @tomitribe #JavaEE
Custom Scope Examples
QC
on S
P
@dblevins @tomitribe #JavaEE
http://tomitribe.io/projects/microscoped
QC
on S
P
@dblevins @tomitribe #JavaEE
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
QC
on S
P
@dblevins @tomitribe #JavaEE
Part 1: ExtendableConnectors
QC
on S
P
@dblevins @tomitribe #JavaEE
Inbound Connectors(aka MDBs)
QC
on S
P
@dblevins @tomitribe #JavaEE
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
QC
on S
P
@dblevins @tomitribe #JavaEE
JMS MDB in Java EE 7
QC
on S
P
@dblevins @tomitribe #JavaEE
Title Text
• Body Level One• Body Level Two• Body Level Three• Body Level Four• Body Level Five
QC
on S
P
@dblevins @tomitribe #JavaEE
Title Text
• Body Level One• Body Level Two• Body Level Three• Body Level Four• Body Level Five
Bad Configuration
QC
on S
P
@dblevins @tomitribe #JavaEE
Title Text
• Body Level One• Body Level Two• Body Level Three• Body Level Four• Body Level Five
Boiler Plate
QC
on S
P
@dblevins @tomitribe #JavaEE
Title Text
• Body Level One• Body Level Two• Body Level Three• Body Level Four• Body Level Five
Only Useful Line of Code
QC
on S
P
@dblevins @tomitribe #JavaEE
JMS MDB in Java EE 8
QC
on S
P
@dblevins @tomitribe #JavaEE
Oh yeah.
QC
on S
P
@dblevins @tomitribe #JavaEE
Custom Connector Examples
QC
on S
P
@dblevins @tomitribe #JavaEE
https://tomitribe.io/projects/chatterbox
https://tomitribe.io/projects/sheldon
QC
on S
P
@dblevins @tomitribe #JavaEE
Part 2: Functional(Ideas for the Future)
QC
on S
P
@dblevins @tomitribe #JavaEE
Eras of Java EE
• 1998 (start)• 2001 (strong) • 2006 (start)
• 2009 (strong)• 2014* (start)
• ???? (strong)
XML Annotation Lambda
QC
on S
P
@dblevins @tomitribe #JavaEE
Opportunity for Impact
• From Declarative to Programmatic• From Component-side to Caller-side• Large decrease in annotation and class overhead• Logic is mobileImpact of Opportunity• Potential Growth in mixed container and “API” code• Lifecycle compromises might need to be made• Will take time and effort (join in!)
QC
on S
P
@dblevins @tomitribe #JavaEE
Thank You!
top related