JSF2 Spring JDK 代理会话 Bean 开销问题
在我当前的应用程序(JSF2、Spring 3、Richfaces 4、WebFlow 2.x)中,有一个我需要会话范围的字符串(因此每个用户都有自己的副本)。
我的问题是在 spring 管理的容器中创建和维护 spring/JSF2 bean 涉及多少开销?我应该为这个字符串制作一个bean吗?或者我应该将此字符串包含在已经存在的 bean 中吗? (在我的例子中是用户bean)。现在我的字符串包含在它自己的包装 bean 类中。我最初的想法是,如果我将字符串包含在 User bean 中,那么每当有东西需要上述字符串时,我就会包含一堆额外的东西(用户 bean 中的其他所有内容)。例如。连接一个仅包含所需字符串的 bean 似乎比连接一个包含一堆从未使用过的额外内容的 bean 更有意义。有人对此有任何经验/想法吗?
In my current app (JSF2, Spring 3, Richfaces 4, WebFlow 2.x) have a string which I need session scoped(so each user has their own copy).
My question is how much overhead is involved in creating and maintaining a spring/JSF2 bean in a spring managed container? Should I make a bean just for this string? or should I include this string in an already existing bean? (the user bean in my case). Right now I have the string contained in its own wrapped bean class. My initial thought was that if I included it the string in the User bean, then I would be including a bunch of extra stuff(everything else in the user bean) each time something needs the aforementioned string. eg. it seems to make more sense to just wire up a bean containing just the needed string as apposed to wiring a bean that contains a bunch of extra stuff that never gets used. Anyone have any experience/thoughts on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是 Spring 博客上的一篇文章其中讨论了代理对性能的影响。
我不完全理解你的情况,但我认为不值得为每个字符串创建一个 bean。不是因为性能,而是因为可读性和可维护性。 (另请检查 spring 注释
@Value(..)
用于注入基元)Here is an article on the spring blog which discusses the impact of proxies on performance.
I don't fully understand your situation, but I don't think it's worth creating a bean for each string. Not because of performance, but because of readability and maintainability. (Also check the spring annotation
@Value(..)
for injecting primitives)