javavalidationaspectjoval

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:

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
)

Solution

  • 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