Announcement Announcement Module
Collapse

Spring Modules forum decommissioned in favor of Spring Extensions

As the Spring Modules project has been replaced by the Spring Extensions (http://www.springsource.org/extensions) project, this forum has been decommissioned in favour of Spring Extensions one at:
http://forum.springsource.org/forumdisplay.php?f=44

Please see the Spring Extensions home page for a complete list of current projects in Java, .NET and ActionScript. You can also propose one if you want.

Cheers,
Costin Leau
SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
http://twitter.com/costinl
See more
See less
Validation interceptor (use in business tier) Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validation interceptor (use in business tier)

    Hello,

    I would like to validate every argument sent to a service method with a org.springmodules.validation.bean.BeanValidator.

    I've not found any ValidationMethodInterceptor class in springmodules 0.9.

    Am I missing something ?

    I've found a lot of samples on the web :
    http://nishgoel.blogspot.com/2005_10_01_archive.html
    http://my-garbage-collector.blogspot...alidation.html
    http://www.google.fr/url?sa=t&ct=res...2yOduX63PI_GiQ

    If there's no interceptor in springmodules wouldn't it be interesting to add one (appears to be a common need) ?

    Thanks

    N.B sample of code of interceptor (didn't tested it or even compiled it, just to illustrate the idea) :
    Code:
    public class ValidationInterceptor implements MethodBeforeAdvice {
        
        private Validator validator = null;
        
        public void     before(Method method, Object[] args, Object target) {
        for (Object arg : args) {
                Errors lErrors = new BindException(lPerson, Integer.valueOf(i));
                validator.validate(arg, lErrors);
                if (lErrors.hasErrors()) {
                    throw lErrors;
                }
            }
            method.invoke (target, args);
        }
        
        public void setValidator (BeanValidator aValidator) {
            mValidator = aValidator;
        }
    }
Working...
X