开发者

Should I use OVal (Object Validation Framework) even if it requires AspectJ or not?

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://img6开发者_运维知识库51.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
)


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜