简体   繁体   English

性能问题JSF-托管Bean内的托管Bean注入

[英]Performance Concern JSF - Managed Bean Injection Inside Managed Bean

I am using an existing application based on JSF2.0 and over top we are using Primefaces. 我正在使用基于JSF2.0的现有应用程序,最重要的是,我们正在使用Primefaces。 I have seen, people have injected on managed bean inside another managed bean. 我已经看到,人们在另一个托管bean中注入了托管bean。 I am looking forward to know, is it a good practice? 我期待知道,这是一个好习惯吗? What about the performance drawbacks? 那性能上的缺点呢? I see our application behaves very slow in Performance Testing environment. 我看到我们的应用程序在性能测试环境中的运行速度非常慢。 Another thing, inside a ManagedBean annotation, we have a concept of "eager", how useful this attribute is? 另一件事,在ManagedBean批注中,我们有一个“渴望”的概念,这个属性有多有用?

Thanks. 谢谢。

AFAIR it's not a good practice if serialization is enabled - which is required if you use client side state or session replication/clustering. 当然,如果启用了序列化,则不是一个好习惯-如果使用客户端状态或会话复制/集群,则需要这样做。

eg if you have 2 viewscoped beans on the same view ("A" and "B") and inject "B" into "A". 例如,如果您在同一视图(“ A”和“ B”)上有2个观察范围的bean,并将“ B”注入“ A”。 "A" will be serialized 1 time and "B" will be serialized 2 times. “ A”将被序列化1次,“ B”将被序列化2次。

This problem will not occur if you CDI because only proxies will be injected and not the real instance. 如果您使用CDI,则不会发生此问题,因为将仅注入代理而不是真实实例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM