We will now start analyzing a simple EJB. Here we have a module that provides read and write operations for posts inside a forum. Here is the first sample:
@Stateless
public class MyPosts {
public List<Post> getLastPosts() {...}
public List<Post> getPostsByDay() {...}
public void addPost(String topicName, String message) {...}
}
@Stateless converts a simple class in a stateless session bean, the first EJB type that we are analyzing next.
Stateless means an EJB without state. Each operation done inside this service is missed when the call ends. Suppose this class wants to register the list of requested posts calling the getPostsByDay operation:
@Stateless
public class MyPosts {
private List<Post> lastRequestedPosts;
public List<Post> getPostsByDay() {
lastRequestedPosts = asList(new Post[]{new Post("first message"...