View RSS Feed


Stateless Session Bean

Rate this Entry
, 01-02-2012 at 06:55 PM (1079 Views)
A stateless session (EJB Component) is an enterprise bean which gives its users a stateless service. Interface javax.ejb.SessionBean is implemented by the stateless session bean (EJB Component) and deploys to the “stateless” declarative attribute. They are known as “stateless” as conversational states are not maintained by them that are specific to the client’s session. Stateless session beans are same as the static methods or procedural applications; no instance state is present therefore to execute the method all data is provided by method arguments.

Java Code: This is the example of a stateless session bean
import java.util.Collection;
import javax.ejb.Remote;
public interface Cart {
    public void addItem(String item);
    public void removeItem(String item);
    public Collection getItems();

import java.util.ArrayList;
import java.util.Collection;
import javax.annotation.PostConstruct;
import javax.ejb.Stateful;
public class CartBean implements Cart {
    private ArrayList items;
    public void initialize() {
        items = new ArrayList();
    public void addItem(String item) {
    public void removeItem(String item) {
    public Collection getItems() {
        return items;

Submit "Stateless Session Bean" to Facebook Submit "Stateless Session Bean" to Digg Submit "Stateless Session Bean" to Submit "Stateless Session Bean" to StumbleUpon Submit "Stateless Session Bean" to Google

Updated 01-14-2012 at 07:14 PM by EJB

Session Bean , EJB Bean