Why so many remove methods?

For Remote clients, two in the home, plus one in the component interface

Remember, Remote clients have three remove() methods available, two in the home, and one in the component interface. The remove() that comes from EJBObject is simple; if you call it, you’re saying you want to remove that very bean! In other words, the bean whose EJBObject you used to call remove(). And for session beans, remember, calling remove() simply tells the container that you’re done with the bean. It’s good manners, and it improves scalability since the server can stop keeping client-specific resources on your behalf, rather than waiting, say, for your shopping session to time out from inactivity.

But things aren’t so simple when you call remove on a home. For one thing, you actually can’t remove a home! The server keeps the bean home alive whether you’re around or not, so there’s no significant client-specific resources. There’s no need to tell the server you’re done with the home, because the server would simply say, “So what?”

Then what does it mean to call remove() on a home?

It means you’re telling the home to remove one of the beans that came from that home. And that means you have to identify which bean you’re talking about!

REMOTE client view

image with no caption

Why there’s not a no-arg remove method in the home...

How can you use a remove that takes a handle when you don’t have a handle?

Local ...

Get Head First EJB now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.