QCon SP Java EE: Extendable and Functional David Blevins - - PowerPoint PPT Presentation

qcon sp
SMART_READER_LITE
LIVE PREVIEW

QCon SP Java EE: Extendable and Functional David Blevins - - PowerPoint PPT Presentation

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


slide-1
SLIDE 1

QCon SP

@dblevins @tomitribe #JavaEE

Java EE: Extendable and Functional

David Blevins Tomitribe

slide-2
SLIDE 2

QCon SP

@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?
slide-3
SLIDE 3

QCon SP

@dblevins @tomitribe #JavaEE

Part 1: Extendable CDI Scopes

slide-4
SLIDE 4

QCon SP

@dblevins @tomitribe #JavaEE

Background

  • EJB and CDI Alignment
  • EJB slowly being deprecated
  • Functionality moving to CDI
  • CDI significantly more extendable
slide-5
SLIDE 5

QCon SP

@dblevins @tomitribe #JavaEE

CDI and EJB Under the Covers

slide-6
SLIDE 6

@dblevins @tomitribe #JavaEE

QCon SP

Proxy (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

slide-7
SLIDE 7

@dblevins @tomitribe #JavaEE

QCon SP

Proxy (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)

slide-8
SLIDE 8

QCon SP

@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)
slide-9
SLIDE 9

QCon SP

@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
slide-10
SLIDE 10

QCon SP

@dblevins @tomitribe #JavaEE

Custom Scope Examples

slide-11
SLIDE 11

QCon SP

@dblevins @tomitribe #JavaEE

http://tomitribe.io/projects/ microscoped

slide-12
SLIDE 12

QCon SP

@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
slide-13
SLIDE 13

QCon SP

@dblevins @tomitribe #JavaEE

Part 1: Extendable Connectors

slide-14
SLIDE 14

QCon SP

@dblevins @tomitribe #JavaEE

Inbound Connectors (aka MDBs)

slide-15
SLIDE 15

QCon SP

@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
slide-16
SLIDE 16

QCon SP

@dblevins @tomitribe #JavaEE

JMS MDB in Java EE 7

slide-17
SLIDE 17

QCon SP

@dblevins @tomitribe #JavaEE

Title Text

  • Body Level One
  • Body Level Two
  • Body Level Three
  • Body Level Four
  • Body Level Five
slide-18
SLIDE 18

QCon SP

@dblevins @tomitribe #JavaEE

Title Text

  • Body Level One
  • Body Level Two
  • Body Level Three
  • Body Level Four
  • Body Level Five

Bad Configuration

slide-19
SLIDE 19

QCon SP

@dblevins @tomitribe #JavaEE

Title Text

  • Body Level One
  • Body Level Two
  • Body Level Three
  • Body Level Four
  • Body Level Five

Boiler Plate

slide-20
SLIDE 20

QCon SP

@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

slide-21
SLIDE 21

QCon SP

@dblevins @tomitribe #JavaEE

JMS MDB in Java EE 8

slide-22
SLIDE 22

QCon SP

@dblevins @tomitribe #JavaEE

Oh yeah.

slide-23
SLIDE 23

QCon SP

@dblevins @tomitribe #JavaEE

Custom Connector Examples

slide-24
SLIDE 24

QCon SP

@dblevins @tomitribe #JavaEE

https://tomitribe.io/projects/ chatterbox https://tomitribe.io/projects/ sheldon

slide-25
SLIDE 25

QCon SP

@dblevins @tomitribe #JavaEE

Part 2: Functional

(Ideas for the Future)

slide-26
SLIDE 26

QCon SP

@dblevins @tomitribe #JavaEE

Eras of Java EE

  • 1998 (start)
  • 2001 (strong)
  • 2006 (start)
  • 2009 (strong)
  • 2014* (start)
  • ???? (strong)

XML Annotation Lambda

slide-27
SLIDE 27

QCon SP

@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 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!)
slide-28
SLIDE 28

QCon SP

@dblevins @tomitribe #JavaEE

Thank You!