Validating Objects Through Metadata
Subject:   Sounds nice, but...
Date:   2005-01-20 07:29:15
From:   edburns

Here are some questions about your approach:

In general, with the simplicity of baking your configuration data into
the Java source file, you lose the flexibility to make changes to the
configuration data without recompilation.

JavaServer Faces was targeted at the corporate developer. The very
concept of annotations and leveraging them for validation seems to go
beyond the realm of what the corporate developer can easily handle.

How slow is the reflection involved in the public static void validate()

Is the complexity worth it?

In faces, currently a validator can be

1 a separate java class that implements the Validator interface. This
class is identified to the system by a combination of validatorId and

2 a method on a pojo that conforms to the signature of
Validator.validate(). The class on which this method is defined is
identified to the system by a combination of managed-bean-name and

In your system, you have the same amount of Java code to write, but
you can bake the validator itself into the bean that it is
validating. This is nice because logically it makes sense for the
validation logic to be tightly coupled to the bean...sometimes.
Note that you can achieve this same coupling using method 2 above.

1 to 2 of 2
1 to 2 of 2