[jboss-user] [EJB 3.0] New message: "Stateful not keep data"
Youssef El Maroufy
do-not-reply at jboss.com
Mon Jan 18 06:41:19 EST 2010
User development,
A new message was posted in the thread "Stateful not keep data":
http://community.jboss.org/message/520556#520556
Author : Youssef El Maroufy
Profile : http://community.jboss.org/people/elmaroufy
Message:
--------------------------------------------------------------
Hi
I hope i'm in the correct sub-furum
I have a problem with Stateful that do not keep data between methods calls;
@Stateful
public class ShoppingCart implements ShoppingCartLocal {
private List<CartItem> cartItems;
public List<CartItem> getCartItems() {
return cartItems;
}
@PostConstruct
public void initialize() {
System.out.println("<--Construct-->");
cartItems = new ArrayList<CartItem>();
}
@PreDestroy
public void clear() {
System.out.println("<--Destroy-->");
cartItems = null;
}
}
the method initialize() is executed on each call !
I'm using JBoss 5.1, and the Stateful is injected in a Managed Bean
public class ProductBusinessDelegate {
@EJB
ProductBusinessLocal productBusiness;
@EJB
ShoppingCartLocal shoppingCart;
public List<CartItem> getCartItems(){
return shoppingCart.getCartItems();
}
public ProductBusinessDelegate() {
}
}
Thanks
--------------------------------------------------------------
To reply to this message visit the message page: http://community.jboss.org/message/520556#520556
More information about the jboss-user
mailing list