EJB or Not Denver BEA User's Group Sept 2003

Preview:

DESCRIPTION

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

Citation preview

EJB or Not

Scott RyanDenver BEA User’s Group

September 2003

Big Topic Little Time

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

Golden Hammer or NACL

What are the Ingredients?

• Stateless Session Beans• Stateful Session Beans• Entity Beans

o Bean Managedo Container Managed (CMR?)

• Message Driven Beans

What is in it for me?

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

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?

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

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

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

What is going on?

What is all this?CMR

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

Loading but be careful• Very efficient when used correctly

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)

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

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

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

Recommended