有時需要在Session Bean中初始化和釋放一些資源
除此之外
package service;
import java
import java
import javax
import javax
import javax
import javax
import javax
import javax
import javax
@Stateless
public class ShoppingCartBean implements ShoppingCart
{
private List<String> shoppingCart = new ArrayList<String>();
@Resource
private SessionContext sessionContext;
public ShoppingCartBean()
{
System
}
@PrePassivate
public void MyPassivate()
{
System
}
@PostConstruct
public void init()
{
System
}
@PreDestroy
public void destory()
{
System
}
@PostActivate
public void start()
{
System
}
@Override
public void addCommodity(String value)
{
shoppingCart
}
@Override
public List<String> getCommodity()
{
return shoppingCart;
}
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26185.html