2 Replies Latest reply on Feb 20, 2003 10:36 AM by thomasra

    ClientValidation interceptor

    thomasra

      I don't know if this has been discussed previously, but I had a brief talk to Juha in atlanta about this, and here is what I think...

      We could have a client-side interceptor that does logic validation, not just interface-compliancy. This means, we could write a configuration for the interceptor that defined a class name, a method signature, and a set of rules for each method. These rules I'm not sure how best to implement, but they could be something quasi-programmatic like "$1 > 0" or "name not null" etc. Okay, more about that later.

      Now, the proxy generated when you return to the client now includes a client-side validation scheme, which intercepts immediately after the deconstruction of the typed interface, and cheks the invocation to see if there are rules for this method on this class. If so, it checks the parameters, and throws a validation exception back to the client (with for instance a user-defined rule fail message).

      This means two things:

      * First of all we can throw exceptions back to the client immediately, without even going to the server side.

      * Second, we can now hot-plug logic validation into existing classes without touching the implementation. For future use, we could even drop writing this code in our beans, and just do it declaratively in the interceptor configuration instead.

      I know a few projects have been doing this in some way or another, but since we have a client side stack of interceptors, doing it in jboss should't be hard at all.

      Any ideas?

      thomas

        • 1. Re: ClientValidation interceptor
          thomasra

          To add some more ideas to this...how about writing some simple xdoclet tags on a method in a class, and have that generate a rule implementation to be used in a client-side validation interceptor? That would be really cool - keeping all the code still in the bean, but also declaratively putting parameter logic validation on methods....cool.

          thomas

          • 2. Re: ClientValidation interceptor
            thomasra

            ...like..


            /**
            * @jboss:client-validation-rule
            * name="User id must be larger than 0"
            * rule="id > 0"
            *
            */
            public String getUserNameById(int id) {
            ...
            }