Intercepting Specific Annotations with Spring AOP
I'm looking to see whether or not the following is even possible, as all preliminary searches haven't turned back anything to indicate either way.

I'd like to use Hibernate's Validator annotations to validate bean methods, and I would like to use *some* AOP framework (Spring, AOP Alliance, AspectJ, etc.) to intercept methods annotated with a subset of the Hibernate Validator annotations (`@NotNull`, `@NotEmpty`, `@Email`, etc.); I then want AOP advice to run when they are encountered.

Is this possible to do? If so, I am having a tough time visualizing how the code would work. Using Spring AOP's `MethodInterceptor` interface as an example:

First, the bean using Hibernate Validator:

    public class SomeBean
    {
        private String data;

        // Hibernate Validator annotation specifying that "data" cannot be an empty
        // string.
        @NotEmpty
        public String getData() { ... } // etc.
    }

Then, some code using that bean:

    public void someMethod()
    {
        SomeBean oBean = new SomeBean();

        // Validation should fail because we specified that "data" cannot be empty.
        oBean.setData("");
    }

Next, the AOP advice to be ran when Hibernate Validator-annotated methods are encountered.

    public class ValidationInterceptor implements MethodInterceptor
    {
        public Object invoke(MethodInvocation invocation)
        {
            // Here's where we would use Hibernate's validator classes.
            // My code example here is wrong, but it gets the point across.
            Class targetClass = invocation.getClass(); // Should give me SomeBean.class
            ClassValidator<targetClass> oValidator= new ClassValidator<targetClass>();

            // Here I need to get a reference to the instance of the offending
            // SomeBean object whose data has been set to empty...not sure how!
            SomeBean oOffendingBean = getTheBadBeanSomehow();

            InvalidValue[] badVals = oValidator.getInvalidValues(oOffendingBean);
        }
    }

So, not only am I choking on what the Spring AOP (pointcut definitions, etc.) configuration would look like to intercept the Hibernate Validator annotations I want, and not only do I not fully grasp how to implement the actual advice (e.g. how to instantiate the offending `SomeBean` from inside the advice as I mention above in the comments), but I'm not even sure if this solution is possible, Spring or otherwise.

Thanks in advance for some gentle "nudges" in the right direction!
Intercepting Specific Annotations with Spring AOP
===

I'm looking to see whether or not the following is even possible, as all preliminary searches haven't turned back anything to indicate either way.

I'd like to use Hibernate's Validator annotations to validate bean methods, and I would like to use *some* AOP framework (Spring, AOP Alliance, AspectJ, etc.) to intercept methods annotated with a subset of the Hibernate Validator annotations (`@NotNull`, `@NotEmpty`, `@Email`, etc.); I then want AOP advice to run when they are encountered.

Is this possible to do? If so, I am having a tough time visualizing how the code would work. Using Spring AOP's `MethodInterceptor` interface as an example:

First, the bean using Hibernate Validator:

    public class SomeBean
    {
        private String data;

        // Hibernate Validator annotation specifying that "data" cannot be an empty
        // string.
        @NotEmpty
        public String getData() { ... } // etc.
    }

Then, some code using that bean:

    public void someMethod()
    {
        SomeBean oBean = new SomeBean();

        // Validation should fail because we specified that "data" cannot be empty.
        oBean.setData("");
    }

Next, the AOP advice to be ran when Hibernate Validator-annotated methods are encountered.

    public class ValidationInterceptor implements MethodInterceptor
    {
        public Object invoke(MethodInvocation invocation)
        {
            // Here's where we would use Hibernate's validator classes.
            // My code example here is wrong, but it gets the point across.
            Class targetClass = invocation.getClass(); // Should give me SomeBean.class
            ClassValidator<targetClass> oValidator= new ClassValidator<targetClass>();

            // Here I need to get a reference to the instance of the offending
            // SomeBean object whose data has been set to empty...not sure how!
            SomeBean oOffendingBean = getTheBadBeanSomehow();

            InvalidValue[] badVals = oValidator.getInvalidValues(oOffendingBean);
        }
    }

So, not only am I choking on what the Spring AOP (pointcut definitions, etc.) configuration would look like to intercept the Hibernate Validator annotations I want, and not only do I not fully grasp how to implement the actual advice (e.g. how to instantiate the offending `SomeBean` from inside the advice as I mention above in the comments), but I'm not even sure if this solution is possible, Spring or otherwise.

Thanks in advance for some gentle "nudges" in the right direction!