使用:EJB 3.1、JBoss AS 7、RestEasy。
我有一个会话范围的 bean,我想用它来存储会话的用户信息。
import java.io.Serializable;
import javax.enterprise.context.SessionScoped
@SessionScoped
public class LoggedInUser implements Serializable {
private String id;
...
}
如果用户打开我的 web 应用程序,过滤器会提取包含用户标识的标题信息(应用程序在 webseal 后面运行)。我需要在那里(在调用 ldap 之后)创建一个登录用户对象(参见上面的 LoggedInUser)。之后我想在不同的@Stateless Beans 中注入这个 LoggedInUser 对象,但 LoggedInUser 总是“空的”(成员为空)。
进样:
@Path("/country")
@Stateless
public class CountryController extends AbstractController {
@Inject
private Logger LOGGER;
@Inject
private LoggedInUser loggedInUser;
//@Inject dont work too..
//private Instance<LoggedInUser> loggedInstance
我做错了什么?