Reputation: 7723
Is this an EJB or ManagedBean? To be an EJB bean, must it be annotated by @stateful, @stateless or @Singleton? I thought @SessionScoped and @ApplicationScoped classes are also EJB beans. Is this right?
import javax.faces.bean.SessionScoped;
import javax.inject.Named;
@Named("userData")
@SessionScoped
public class UserData implements Serializable {
private static final long serialVersionUID = 1L;
public UrlData data;
public UrlData getData() {
return data;
}
public void setData(UrlData data) {
this.data = data;
}
}
Upvotes: 1
Views: 782
Reputation: 3162
@SessionScoped and @ApplicationScoped are part of ManagedBean not EJB, which classes as a resource with the JavaServer Faces.
You can see more detail in Java-EE specification
This is an example code that inject EJB into ManagedBean
@ManagedBean
@SessionScoped
public class Count {
@EJB
private CounterBean counterBean;
private int hitCount;
public Count() {
this.hitCount = 0;
}
public int getHitCount() {
hitCount = counterBean.getHits();
return hitCount;
}
public void setHitCount(int newHits) {
this.hitCount = newHits;
}
}
Upvotes: 1