EJB or Not Denver BEA User's Group Sept 2003

16
EJB or Not Scott Ryan Denver BEA User’s Group September 2003

description

An overview of the pros and cons of adopting EJB in enterprise java development

Transcript of EJB or Not Denver BEA User's Group Sept 2003

Page 1: EJB or Not Denver BEA User's Group Sept 2003

EJB or Not

Scott RyanDenver BEA User’s Group

September 2003

Page 2: EJB or Not Denver BEA User's Group Sept 2003

Big Topic Little Time

Page 3: EJB or Not Denver BEA User's Group Sept 2003

References

• EJB 1.0• EJB 1.1• EJB 2.0• EJB 2.1

http://java.sun.com/products/ejb/docs.html#specs• Bitter EJB - Manning Publications Co.• JBoss and AOP www.jboss.org/• Programming Weblogic EJBs

Page 4: EJB or Not Denver BEA User's Group Sept 2003

Golden Hammer or NACL

Page 5: EJB or Not Denver BEA User's Group Sept 2003

What are the Ingredients?

• Stateless Session Beans• Stateful Session Beans• Entity Beans

o Bean Managedo Container Managed (CMR?)

• Message Driven Beans

Page 6: EJB or Not Denver BEA User's Group Sept 2003

What is in it for me?

• Distributed Component Model• Pooling/Sharing• Security• Transactions• Asynchronous Behavior (MDB)

Page 7: EJB or Not Denver BEA User's Group Sept 2003

Is that the one I had before?Stateless Session Beans

• Good for one Method Call• Pooled and shared for performance• Can store Instance Information• What happens with Instance Variables?

Page 8: EJB or Not Denver BEA User's Group Sept 2003

Where do put I my state?Stateful Session Beans

• What is the efficient way to store state• When is the persistence done• Cluster Aware• Multiple ways to persist

o Memory, Files, Database• Be careful what you store and how• Seek other ways to persist complex data

Page 9: EJB or Not Denver BEA User's Group Sept 2003

Wow Look at all I getEntity Beans

• Not just a persistence mechanismo There are better ways to persist

• Understand how to tune with deployment Descriptorso Persistenceo Pooling o Transactionso Security

Page 10: EJB or Not Denver BEA User's Group Sept 2003

Wow Look at all I get(Continued)

• Concurrencyo Exclusive, Database, Optimistic, Read-only,

Read Mostly• Caching Strategies• Lazy Loading• Clustering and Load Balancing• Local VS Remote

Page 11: EJB or Not Denver BEA User's Group Sept 2003

What is going on?

Page 12: EJB or Not Denver BEA User's Group Sept 2003

What is all this?CMR

• Watch the depth of relationships• Leverage Concurrency, Caching, Lazy

Loading but be careful• Very efficient when used correctly

Page 13: EJB or Not Denver BEA User's Group Sept 2003

How do I call you?Message Driven Beans

• Very useful to control Asynchronous activity

• Design to run standalone (asynchronously)• Tune the number to support the load• Handle ALL message types• Be careful what you do with exceptions• Keep it light (implementation and message

size)

Page 14: EJB or Not Denver BEA User's Group Sept 2003

Who changed my bean?AOP and JBoss

• Code added during run time o Horizontal extension via bytecode injectiono Can I trust the implementation?o Similar to JDO implementation but on a larger

scale• Possible alternative to EJBs

o Selectively add functionality to POJOs

Page 15: EJB or Not Denver BEA User's Group Sept 2003

Tidbits of Knowledge

• EJB’s have huge value when used correctly• Plan your interfaces carefully• Don’t write code that you can generate

o Xdoclet, EJBGEN, Reverse EJBGEN• Understand what is going on under the covers• Use deployment options to tune implementation• Leverage experience of others• Remember the alternatives

Page 16: EJB or Not Denver BEA User's Group Sept 2003

Tidbits of Knowledge(cont)

• Be careful when using inheritance• Understand reentrancy and Idempotency• Plan your exception handling• Understand the object lifecycles• Don’t spawn threads or interfere with

Container code