Saturday, June 12, 2010

If Software is pizza, EJB is the House Special

If you can stand terrible food metaphors and have ever been exposed to EJB positively or negatively, keep reading....

I don't know about you, but I love the simplicity of a good pepperoni pizza now and then. Imagine asking for a plain Pepperoni pizza and being told your only option was to get the House Special and to pick off all the onions, black olives, green pepper and whatever else comes on top. Any person with options would simply go to another pizza shop. Well, that's EJB. Something I hope we can change in EJB 4.0.

To setup the metaphor a bit more, let's say the dough and cheese is the component itself and the proxy to the component. The toppings are the various QOSs (qualities of service) such as transaction management, interceptors, concurrency management, cron-like scheduling, asynchronous method calls, and other goodness. Each bean type such as Stateful, Stateless, Singleton and Message Driven are certain styles of pizza with a fixed set of toppings; say Meat Lovers, Vegetarian, or Hawaiian. The toppings of each style of pizza have been selected carefully to compliment each other perfectly and guarantee good results.

Currently though, if you want to start with a plain pizza and add only the toppings you want or need, you cannot do it with EJB. If you want pepperoni, you need to pick a style of pizza that has pepperoni as a topping and deal with the other toppings that come with it, wanted or not. EJB is somewhat flexible and there are usually ways to neutralize some features that amounts to picking off the toppings you don't like, but it's not the same as if they weren't ever there and you are still going to get an odd tasting and odd looking pizza.

Say you don't really want the transaction management topping. You try to pick off the topping by selecting SUPPORTS as your default transaction attribute so if a transaction is there, your bean participates in it, if not, it still does it's work regardless. All is fine until your bean throws a runtime exception and the container decides to rollback the current transaction on your behalf. Say you instead choose to try and pick off the transactional topping by making your bean use bean-managed transactions. Things work fine except now all transactions are suspended by the container so that the bean cannot mess with the state of what was the current transaction. What you really wanted was your bean to not be transactionally aware in the first place.

Unfortunately if you want one of the other toppings like container managed concurrency, cron-like scheduling, or asynchronous method calls, you have to learn to like the transaction management topping, period.

There will always be a need for specific pizza styles with pre-selected toppings -- who doesn't love a good Greek pizza or a Hawaiian now and then. The EJB spec does that well with its perfectly selected bean types, each sprinkled with the select set of QOSs deemed appropriate for that specific bean type. That said, it really should be possible to start with a plain cheese pizza and just add the toppings you want.

Forget the dough and cheese. EJB should be about the toppings.

Ideally, every QOS the EJB spec has to offer would be an option that can be applied to a plain component. Imagine if there was a "plain cheese pizza" bean type that would by default have no QOSs at all and for all intense purposes be a true POJO. There's nothing to learn or study to code it or use it. It's just a POJO created by the container. Then one day you decide you'd like it to be transaction aware. At that point you annotate it with @TransactionManagement and then go read the self contained "transaction management" section of the spec to see what is now expected of you and the users of the bean.

It may be that certain QOSs cannot be combined, which is in fact the case at times. The concept of a container managed persistence context (i.e. a field like "@PersistenceContext EntityManager myEntityManager") cannot be combined with the new @ConcurrencyManagement annotation because EntityManagers themselves are not guaranteed to be capable of concurrency. As a result EJB Singletons are not allowed to use container managed persistence contexts. That may work for some, but maybe you want a Singleton that uses a container managed persistence contexts and do not need concurrency anyway. Such a thing would be possible if you were able to choose the QOSs for your bean regardless of its lifecycle.

It's time to break up the big specs and let people build their own pizzas.

35 comments:

Narender Godara said...

Packers and movers Mohali
Packers and movers Mumbai
Packers and movers Mysore
Packers and movers Nagpur

Mary Brown said...

Java EE article is practical oriented and real time examples. How Java EE address the enterprise development is very important. for that you need a practical orieneted Java Training you need.

Online Java Training
Online Java Training from India
Java Training Institutes in Chennai
Java Training in Chennai
Java Training

Ranveer Patil said...

This is great do you have a catologue if so I would love one to share with friends and family.
T20 world cup 2016 tickets Available
T20 World Cup 2016 Expected Players List

Amrish Singh said...

icc t20 world cup live
Mobiles in India
Hindi Lyrics
IPL t20

Tenaz Tony said...

happy holi images
holi 2016
happy holi 2016
holi images 2016
happy easter images
easter bunny
easter wishes
Good Friday Wallpapers
easter greetings
Easter 2016
holi wallpaper
happy holi photo
holi images

Tenaz said...

sslc result 2016
sslc results 2016
10th result 2016
sslc result 2016 kerala
sslc result 2016 karnataka
sslc 2016
sslc exam results
cbse result 2016
cbse results 2016
cbse 10th result 2016
cbse 10 result
cbse result class 10
class 10 cbse result

Rekha said...

Rocky Handsome Review
Rocky Handsome Box Office Collection
Rocky Handsome opening day collection
Rocky Handsome Movie Review
Rocky Handsome first day collection
Watch Rocky Handsome 1st day collection
Rocky Handsome Audience Response

Sarrainodu Review
Sarrainodu Box Office Collection
Sarrainodu Audio Launch Date
Sarrainodu Collections
Sarainodu Review
Sarrainodu Theaters List
Sarrainodu movie Review



Sarrainodu first day collection
Sarrainodu 1st day Box Office Collection
Sarrainodu Songs Release Date
Sarrainodu Audio Release Date
Watch Sarrainodu Audio Launch Live

Sarrainodu Review
Watch Sarainodu Audo Launch Live

Sarainodu Review
Sarainodu first day Collection

Ayushi Kumar said...

gmail.com login page
whatsapp status in hindi for friends
www.gmail.com sign in login page

life insurance corporation of india wiki

Ankit Das said...

Want to know about Euro Cup 2016???
Visit my blog.

Game of Thrones Season 6 Online said...

game of thrones season 6 online

HBO game of thrones season 6 online

game of thrones season 6 online free

watch game of thrones season 6 online

game of thrones season 6 episode 1 online

game of thrones season 6 episode 1 "The Red Women"

Game of Thrones Season 6 Online said...


watch game of thrones season 6 online

game of thrones season 6 episode 1 online

game of thrones season 6 episode 1 "The Red Women"

Game of Thrones Season 6 Online said...

game of thrones season 6 episodes 1 online

watch game of thrones season 6 episodes 1 online

game of thrones season 6 streaming online

watch game of thrones season 6 episodes 1 "The Red Woman"

Sam Alex said...

mehandi
mehendi design
latest mehndi designs
arabic mehandi designs
arabic mehndi
mehndi design image
mehandi designs images
mehndi design images
mehndi image
arabic mehendi designs

Sam Alex said...

blouse back neck designs
blouse designs images
designer blouses
plain sarees
simple blouse designs
silk saree blouse designs
blouse designs for silk sarees
designer blouses
boat neck blouse designs
blouses designs
bridal blouse designs

Ram Naresh said...

Happy Fathers Day Pictures
Happy Fathrers Day Best Quotes
fathers Day 2016 Messages
Happy Fathrers Day Best Quotes

Zheng junxai5 said...


zhengjx20160804
michael kors outlet clearance
cheap ray ban sunglasses
tory burch outlet online
ray bans
christian louboutin wedding shoes
montblanc pens
louis vuitton purses
nike roshe one
coach factory outlet online
coach outlet online
polp ralph lauren
louis vuitton outlet online
louis vuitton
oakley sunglasses
air jordan 11
burberry outlet
oakley sunglasses wholesale
longchamp outlet
michael kors handbags
true religion jeans
louis vuitton outlet
hermes birkin handbags
christian louboutin outlet
coach factory outlet
ray ban sunglasses uk
louis vuitton
montblanc pen
louis vuitton handbags
coach outlet online
michael kors handbags
tiffany and co
michael kors outlet clearance
louis vuitton purses
coach outlet
michael kors bags
christian louboutin outlet
jordan retro 11
toms shoes
michael kors outlet

Hua Cai said...

christian louboutin uk
michael kors canada
ugg boots sale
hermes bags
michael kors uk
adidas nmd
mbt shoes outlet
louis vuitton neverfull sale
football shirts
michael kors outlet online
ugg boots
michael kors outlet
longchamp outlet
michael kors outlet clearance
lululemon pants
michael kors uk
tiffany and co
ugg boots
lacoste polo shirts
ugg australia
true religion outlet
iphone case
omega outlet
michael kors outlet
mulberry handbags sale
tiffany jewellery
uggs outlet
mulberry uk
michael kors outlet
mac cosmetics sale
michael kors uk
rolex watches outlet
tiffany outlet
michael kors handbags clearance
ray ban sunglasses sale
20160812caihuali

Hua Cai said...

celine outlet
longchamp handbags
louis vuitton outlet stores
nike huarache
ray ban sunglasses
nike outlet store online
ray ban sunglasses sale
gucci outlet
louis vuitton outlet
ysl outlet online
polo ralph lauren
ralph lauren uk
coach outlet
louis vuitton handbags
lebron shoes
coach outlet online
ray ban sunglasses
tory burch outlet online
ferragamo outlet
air max 90
chicago blackhawks
tory burch outlet
michael kors outlet clearance
tory burch shoes
yeezy boost 350
true religion outlet
puma outlet
cheap uggs
nike outlet online
true religion uk
tiffany jewelry
cheap nike shoes sale
celine outlet online
michael kors outlet
tory burch outlet online
20160812caihuali

Rekha said...

Barbershop near me
black Barber Shop near me
Barber Shop near me
top Barber Shops near me
Barbershops near me
Barbershop near me
black Barber Shop near me
best black Barber Shops near me
Barber Shop near me
top Barber Shops near me
Barbershops near me
Barbershop near me
black Barber Shop near me
best black Barber Shops near me
Barber Shop near me
top Barber Shops near me

Rekha said...

good black Barber Shops near me
Barbershop near me
Barber Shop near me
Barber Shops near me
black Barber Shop near me
black Barber Shops near me
Barber Shop near me
Barber Shops near me
Barber Shops near me
best black Barber Shops near me
Barbershop near me
Barber Shop near me
good Barber Shops near me
black Barber Shop near me
black Barber Shops near me
Barber Shop near me
Barber Shops near me
Top Barber Shops near me
Best black Barber Shops near me
Barbershop near me
Barber Shop near me
Barber Shops near me
black Barber Shop near me
black Barber Shops near me
top Barber Shop near me

jackluter said...

Comparing the food activities with EJB is the best example to understand the software.

App Development Companies USA

Unknown said...

Hairstyles for Men with Curly Hair
Hairstyles for Curly Hair Men
Hairstyles for Women over 50
Hairstyles for Older Women
Hairstyles for Boys
Haircuts for Boys
Wedding Hairstyles for Short Hair Women
Wedding Hairstyles for Short Hair
Hairstyles for Women over 60
Hairstyles for Women
Hairstyles for Men with Short Hair
Hairstyles for Men with Curly Hair
Medium Length Hairstyles for Wavy Hair
Medium Length Hairstyles for Curly Hair
African American Hairstyles for Women
African American Women hairstyles
Hairstyles for Men with Long Hair
Hairstyles for Men
Hairstyles for Boys with Long Hair
Long Hair Hairstyles for Boys

Meiqing Xu said...

timberland boots
vans outlet store
longchamp handbags
hermes birkin
birkenstock shoes
christian louboutin shoes
cheap jordans
ralph lauren outlet online
cheap ugg boots
louboutin uk
20161208caiyan

Tokecash said...

Hi, I do think this is an excellent blog. I stumbledupon it 😉 I may
return yet again since I book marked it. Money
and freedom is the greatest way to change, may you be rich and continue to help others. Parabola Tv Muslim ::: Parabola Tv Muslim ::: Parabola Tv Muslim



Unknown said...

the north face jackets
coach outlet clearance
louis vuitton handbags
adidas trainers
cheap jordans
michael kors handbags
nba jerseys
coach outlet online
toms shoes
oakley sunglasses
chanyuan2017.01.7

subash gautam said...

IPL 2017 Schedule
IPL 2017 Points Table
IPL 2017
Fifa 2018 schedule
IPL Live Streaming
IPL 2017 schedule

Thomas pedro said...

Contract advance promoting has turned out to be more imperative than any time in recent memory in today's market. Gone are the days when you could dial arbitrary telephone numbers and land an advance application. Payday Loans San-diego

chenmeinv0 said...

christian louboutin
ray ban sunglasses
christian louboutin paris
air jordans
cheap rolex watches
pandora jewelry
adidas originals uk
chanel bags
coach outlet
ray ban wayfarer
hzx20170301

Elizabeth Morton said...

Popular Posts
Top 10 Lists
Richest Kids
Best Bluetooth Earburds
Haunted Objects
Best Running Shoes for Women
Hollywood Actress

Nicole Zhang said...

Soundtrack List
Films Soundtracks
The Red Turtle Soundtrack
The Great Wall Soundtrack
A Cure For Wellness Soundtrack
The Lego Batman Movie Soundtrack
John Wick Chapter 2 Soundtrack
Fist Fight Soundtrack

Julianna Mori said...

Tattoos
Popular Tattoos
Vikings Tattoos
UFO Tattoos
Tribal Tattoos
Star Wars Tattoos
Realistic Tattoos

marko said...

While you can discover a huge amount of organizations either local to your home or on the web, getting a quick home loan shouldn't oblige you to jump through loops and transfer ownership of your first conceived youngster. car title loans chicago

marko said...

Bank Loan Officers: The advance officers at a bank, credit union or other loaning establishment are representatives who work to offer and process contract and different advances started by their manager. They frequently have a wide assortment of credit sorts to draw from, however all begin from that particular bank. usapaydayloanstore.com/chicago

Justin said...

The reason payday money advances are incredible for building new credit is on the grounds that the term of the advance is typically close to two weeks. As a result of the short advance term, a man could have numerous chances to get cash utilizing this sort of credit. usapaydayloanstore.com/chicago

caiyan said...

longchamp outlet store
christian louboutin sale
nike outlet
coach outlet
michael kors bags
coach canada
air max 2017
air jordan retro
ray ban sunglasses
sac longchamp pas cher
0427shizhong