Session beans
As we previously mentioned, session beans typically encapsulate business logic. One or two artifacts need to be created in order to create a session bean, including the bean itself, and an optional business interface. These artifacts need to be annotated adequately to let the Jakarta EE runtime know they are session beans.
A simple session bean
The following example illustrates a very simple session bean:
package com.ensode.jakartaeebook; import jakarta.ejb.Stateless; @Stateless public class SimpleSessionBean implements SimpleSession{ private final String message = "If you don't see this, it didn't work!"; @Override public String getMessage() { return message; } }
The @Stateless
annotation lets the Jakarta EE runtime know that this class is a stateless session bean. There are three types of session beans: stateless, stateful, and singleton. Before...