AspectJ、Spring AOP 与 JBoss AOP 的异常处理

发布于 2024-08-20 11:14:20 字数 278 浏览 8 评论 0原文

我正在为外部系统编写一个网络服务。

我的服务包装类有许多调用 Web 服务的所有 Soap 接口的方法。 该调用可能会引发异常,然后该异常会自动触发重新连接到 Web 服务。

为了处理这种情况,我想使用 AOP,这样所有调用 SOAP 接口的方法都应该由 try/catch 块“包装”。在 catch 块中重新连接完成。

我目前没有使用Spring,所以我正在考虑引入JBoss AOP。如果 AspectJ 或 Spring AOP 是更好的选择,我需要一些建议。

谢谢。

I'm writing a webservice to an external system.

My service wrapper class has a number of methods which call all the soap interface of the webservice.
The call can throw an exception which should then automatically trigger a reconnect to the webservice.

To handle that scenario I'd like to use AOP such that all methods which call the SOAP interface should be "wrapped" by an try/catch block. In the catch block the reconnect is done.

I'm not using Spring at the moment, so I'm thinking about introducing JBoss AOP. I need some advice if AspectJ or Spring AOP would be a better alternative.

Thanks.

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

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

发布评论

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

评论(1

回眸一遍 2024-08-27 11:14:20

您的需求非常基本,因此 AspectJ、JBoss AOP 或 Spring AOP 都适合您。这表明采用最简单的选择效果最好。

  • 我相信 AspectJ 在编译时或加载时使用字节码操作来工作,这(取决于您的设置)要么很简单,要么是一场噩梦。它的功能非常灵活,但可能有点令人生畏。
  • Spring AOP 是有限的(这不是问题,因为您的需求也是如此),但它是一个纯粹的运行时解决方案。它缺乏灵活性可能是一个好处,因为它很容易理解
  • 我不太熟悉的 JBoss AOP,但它比 AspectJ 更接近 Spring AOP

Your requirements are pretty basic, so either AspectJ, JBoss AOP or Spring AOP would work for you. That would suggest that going with the simplest option would work best.

  • I believe that AspectJ works using byte-code manipulation, either at compile-time or load-time, which (depending on your setup) is either simple, or a nightmare. It's highly flexible in what you can do, but can be a bit intimidating.
  • Spring AOP is limited (which isn't a problem here, since so are your requirements), but is a purely run-time solution. Its lack of flexibility may be a bonus here, since it's easy to understand
  • JBoss AOP I'm not very familiar with, but it's closer to Spring AOP than it is to AspectJ
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文