我在Managed Bean中注入了一个EJB bean。它的构造函数被调用两次。 例如,我得到:
com.logic.jsf.AdditionManagedBean created
com.logic.Addition$$$view45 created
com.logic.Addition created
我知道@PostConstruct,但我想知道为什么会这样。是因为代理,在这种情况下,我不应该在类的打印名称中看到代理相关的文字吗?
@Stateless
@LocalBean
public class Addition{
public Addition(){
System.out.println(this.getClass().getName() +" created");
}
public String getAddition(){
return "Addition";
}
}
注入:
@ManagedBean
@RequestScoped
public class AdditionManagedBean {
@EJB
Addition addition;
public AdditionManagedBean(){
System.out.println(this.getClass().getName()+" created");
}
public String getAddition(){
return addition.getAddition();
}
}