BMT can be a really BAD idea. BMT hurts bean reuse

image with no caption

Can you figure out why?

Think about what you learned on the last few pages, especially about transaction propagation (the whole one-way thing).

image with no caption

If you write a BMT bean, nobody else can ever include your bean in their transaction!

Your BMT bean puts up a big fat wall so calling transactions can’t pass. Remember, a BMT bean will run only in the transactions the bean itself creates and starts. You defeat the whole point of a component model if you lock down the transaction demarcation inside the bean. Remember, the cool thing about a component model is that components can be mixed and combined in new ways to make new applications that the Bean Provider hadn’t ever thought about. The purpose of the deployment descriptor is to give the application assembler a way to configure transactions specific to a particular application, without touching the bean code!

If it’s so bad to use BMT, why is it there?

Because it lets you do a few things you simply cannot do with CMT. But most of the time, you won’t need these things.

With BMT, you can reduce the scope of a transaction.

Using CMT, you cannot mark a transaction at anything smaller than a single method. You put in the deployment descriptor which transaction attribute (we’re getting there) goes with ...

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.