SEAM:有效使用@BypassInterceptors?

发布于 2024-09-26 02:29:32 字数 265 浏览 0 评论 0原文

我想知道社区可以给我在使用 Seam 编程时使用 @BypassInterceptors 注释的什么建议?我一直在阅读有关提高 Seam 应用程序性能的文章,并且每篇文章都提到添加此注释可以提高性能。我的问题是,它应该应用在哪里?是否有一般规则说“当编写执行 XXX 的组件时,您可以安全地应用 @BypassInterceptors”?例如,我应该将它应用到我的实体类吗?那么 DAO 呢?我非常想知道其他人在做什么,以及在正确应用它时您看到了什么样的性能提升。

I was wondering what advice the community could give me on the use of the @BypassInterceptors annotation when programming with Seam? I've been reading up on increasing Seam application performance, and without fail every article mentions that adding this annotation can increase performance. My question is, where should it be applied? Are there general rules that say "when writing a component that does XXX you can safely apply @BypassInterceptors"? For example, should I apply it to my entity classes? What about a DAO? I'd be very curious to know what everyone else out there is doing, as well as what sort of performance increases you saw when applying it correctly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

梦初启 2024-10-03 02:29:32

如果您确定您不需要拦截器功能,则可以依靠@BypassInterceptor注释来禁用拦截器。功能包括

等等...

因为双射功能是通过使用反射(运行时)来实现的 - 例如,参见这个 问题,您可以在其中了解反射会增加多少性能开销 - ,它是可以避免的(除了@BypassInterceptor) 通过使用

• Component.getInstance()

• getter 和 setter

如果您有

@Name("personManager")
public class PersonManager {

    private @In Person person;

}

<h:inputText value="#{person.name}"/>

您可以 代替 @In 注释

@Name("personManager")
public class PersonManager {

    private Person person;

    public Person getPerson() {return this.person;}
    public void setPerson(Person person) {this.person = person;}

}

,但不要忘记(注意其最新值属性)

<h:inputText value="#{personManager.person.name}"/>

If you are sure you do not need interceptor functionality, you can rely on @BypassInterceptor annotation to disable interceptors. Functionality includes

And so on...

Because bi-jection functionality is achieved by using reflection (runtime) - See, for instance, this question where you can have an idea how much performance overhead reflection can add -, it can be avoided (besides @BypassInterceptor) by using

• Component.getInstance(<COMPONENT_NAME_GOES_HERE>)

• getter's and setter's

If you have

@Name("personManager")
public class PersonManager {

    private @In Person person;

}

<h:inputText value="#{person.name}"/>

You can instead of @In annotation

@Name("personManager")
public class PersonManager {

    private Person person;

    public Person getPerson() {return this.person;}
    public void setPerson(Person person) {this.person = person;}

}

But do not forget (Notice its newest value attribute)

<h:inputText value="#{personManager.person.name}"/>
孤蝉 2024-10-03 02:29:32

只是亚瑟帖子的后续。

根据经验,如果您正在对一个不使用 Seam 中任何拦截器的方法进行一些计算,即:计算一些值,那么最好用 @ 标记该方法绕过拦截器。

但添加此注释后始终彻底测试。我遇到了奇怪的错误,因为我在初始测试中没有出现的方法和类上有这个注释。

如果您不确切知道自己在做什么或注释在做什么,那么顺其自然是更明智的做法。

Just a follow up to Arthur's post.

As a rule of thumb, if for instance, you are doing some calculation on a method that does not use any of the interceptors in Seam, ie: calculating some values, then it is a good thing to mark that method with @BypassInterceptors.

But always test thoroughly after adding this annotation. I have experienced strange bugs because I had this annotation on methods and classes that didn't come up on the initial testing.

It is wiser to let it be if you don't know exactly what you are doing or what the annotation is doing.

甜是你 2024-10-03 02:29:32

Dan Allen(Seam in Action)关于该主题的必读文章位于此处(第 1 部分)< /a> 和此处(第 2 部分)。它涵盖了 @BypassInterceptors 以及 Seam 应用程序中许多其他与性能相关的问题,例如条件渲染。

A must-read article by Dan Allen (Seam in Action) on the subject is here (part 1) and here (part 2). It covers @BypassInterceptors and many other performance-related issues in a Seam application, such as conditional rendering.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文