Make it a Stateless Session bean

Now, we’re at the place where we give the tool the bean’s ‘structural’ information. What kind of bean it is, which class file is the home interface, and so on. Remember, the tool uses this to create the deployment descriptor. And the EJB container uses the deployment descriptor to figure out how to deploy and manage the bean.

The Advice bean is simple—client calls a method on the remote object, the remote object returns a value, then the remote object forgets the whole thing ever happened. End of story. That scenario is just perfect for a stateless session bean solution. If the Advice bean needed to remember the advice it gave to the client, and use it in some way in future invocations from that same client, then we’d make it stateful. But we don’t, so we won’t.

And as you’ll learn later, it wouldn’t make sense to have the Advice bean be an entity or message-driven bean. But it’s too late to make it anything but a session bean anyway—your bean class implements the SessionBean interface. So you’re already committed to a bean type. But whether the session bean is stateless or stateful can be a little more subtle. For now, just make it stateless.

Select the Session radio button

Select the Stateless radio button

image with no caption

Don’t click the Next button!! We have way more to do on this screen.

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.