markash
Oct 1st, 2004, 02:00 AM
Good Day,
I have an method interceptor that retrieves the meta data attributes of a parameter to determine the validation that should be applied to it.
The problem is that the ProxyFactory wants a Interface for the object.
public interface IInvitation {
/**
* @param email
* @@.email com.connext.attributes.ValidateEmail ()
*/
public abstract void setEmail(final String email);
}
public class Invitation implements IInvitation {
private String m_email = null;
/**
* @param email
*/
public void setEmail(final String email) {
m_email = email;
}
}
This means that as the example shows, the attributes need to be applied to the interface instead of the implementation class.
Here is my method interceptor
public class ValidationInterceptor implements MethodInterceptor {
public final Object invoke(final MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
System.out.println(method.getName());
Class[] paramTypes = method.getParameterTypes();
for (int i = 0; i < paramTypes.length; i++) {
if (Attributes.hasParameterAttributeType(method, i, ValidateEmail.class)) {
System.out.println("Has validate email");
}
}
return invocation.proceed();
}
}
Does anyone know how I can apply the attributes the the implementation class so that I can read it in this interceptor?
I have an method interceptor that retrieves the meta data attributes of a parameter to determine the validation that should be applied to it.
The problem is that the ProxyFactory wants a Interface for the object.
public interface IInvitation {
/**
* @param email
* @@.email com.connext.attributes.ValidateEmail ()
*/
public abstract void setEmail(final String email);
}
public class Invitation implements IInvitation {
private String m_email = null;
/**
* @param email
*/
public void setEmail(final String email) {
m_email = email;
}
}
This means that as the example shows, the attributes need to be applied to the interface instead of the implementation class.
Here is my method interceptor
public class ValidationInterceptor implements MethodInterceptor {
public final Object invoke(final MethodInvocation invocation) throws Throwable {
Method method = invocation.getMethod();
System.out.println(method.getName());
Class[] paramTypes = method.getParameterTypes();
for (int i = 0; i < paramTypes.length; i++) {
if (Attributes.hasParameterAttributeType(method, i, ValidateEmail.class)) {
System.out.println("Has validate email");
}
}
return invocation.proceed();
}
}
Does anyone know how I can apply the attributes the the implementation class so that I can read it in this interceptor?