Java EE中的池化“无状态实例” VS“无状态单例Bean”

时间:2019-07-28 21:25:29

标签: java java-ee

在Java-EE中拥有一堆池的“无状态实例” 而不是一个“无状态单例bean” 有什么好处?

Singleton Java-EE:

@ApplicationScoped
public class MySingletonDAO {
// no global properties are shared
..
}

或其他无状态单例bean:

@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class MySingletonDAO {
// no global properties are shared
..
}

无状态Java-EE:

@Stateless
public class MyStatelessDAO {
..
}

使用@Stateless-bean代替“无状态单例” -bean不会带来任何好处。有吗?

0 个答案:

没有答案