即使 OVal(对象验证框架)是否需要 AspectJ,我是否应该使用它?
我有一个由多人开发的 Java Maven 项目。
因为我真的很喜欢做 JUnit 测试等,OVal 的概念引起了我的兴趣,因为我可以编写如下代码:
@NotNull
@NotEmpty
@Length(max=32)
private String name
然而缺点是:
- 现在每个人都必须将 AspectJ 插件安装到他的 Eclipse 中,
- 至少对我来说这会给我一个错误在每次启动时(我可以点击它,但它仍然很烦人)
- 我想 AspectJ 会减慢一切速度
所以这值得吗?有没有我不需要 AspectJ 的替代方案?
PS:这是我在 Eclipse 中遇到的错误: 截图http://img651.imageshack.us/img651/1089/aspectjerror.png
这是 getCommonProperties() 方法的头部,它似乎有问题:
public static LinkedHashMap<String,Integer> getCommonProperties
(
@NotEmpty @NotNull String endpoint,
@NotEmpty @NotNull String where,
@Range(min=0, max=1) Double threshold,
@Min(1) Integer maxResultSize,
@Min(1) Integer sampleSize
)
I have a Java Maven project which is developed by multiple people.
As I really like doing JUnit Tests and the like, the concept of OVal intrigues me because I can write code like:
@NotNull
@NotEmpty
@Length(max=32)
private String name
However the disadvantage is that:
- everyone now has to install the AspectJ plugin to his Eclipse
- at least for me that gives me an error at each startup (which I can click away but it is still annoying)
- I guess AspectJ slows everything down
So is it worth it and is there an alternative where I don't need AspectJ?
P.S.: This is the error I get in Eclipse:
screenshot http://img651.imageshack.us/img651/1089/aspectjerror.png
And this is the head of the method getCommonProperties() that it seems to have problems with:
public static LinkedHashMap<String,Integer> getCommonProperties
(
@NotEmpty @NotNull String endpoint,
@NotEmpty @NotNull String where,
@Range(min=0, max=1) Double threshold,
@Min(1) Integer maxResultSize,
@Min(1) Integer sampleSize
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
OVal 本身不需要使用 AspectJ。仅当您想将其用于按合同编程时,例如自动方法参数验证。如果您不想使用 AspectJ,可以使用 Spring AOP 作为替代方案来启用 Spring 托管服务的方法参数验证,请参阅 http://oval.sourceforge.net/userguide.html#spring-aop
OVal does not require the usage of AspectJ per se. Only if you want to use it for programming-by-contract, e.g. automatic method parameter validation. If you do not want to use AspectJ you can use Spring AOP as an alternative to enable method parameter validation of Spring managed services, see http://oval.sourceforge.net/userguide.html#spring-aop
我不了解 OVal 框架,但我知道 AspectJ 和 Eclipse 工具已经成熟。由于编织过程,编译时间会稍微长一些,但可能不会显着延长。
我的建议是,如果你发现这个框架对你有帮助,那么它就值得使用。
如果你能告诉我启动时的错误是什么,那么也许我们可以找到一种方法,让你不再遇到这个错误。
I do not know the OVal framework, but I do know that AspectJ and the Eclipse tooling is mature. Compile time would be slightly longer due to the weaving process, but probably not significantly longer.
My suggestion is that if you find that the framework helps you, then it is worth using.
If you can tell me what the error on startup is, then perhaps we can figure out a way so that you don't get it any more.