org.jboss.ejb.plugins
public class: CallValidationInterceptor [javadoc |
source]
java.lang.Object
org.jboss.ejb.plugins.AbstractInterceptor
org.jboss.ejb.plugins.CallValidationInterceptor
All Implemented Interfaces:
Interceptor
This Interceptor validates the incomming arguments and the return value of the call.
Here is the place where you want to make sure that local object don't pass through
the remote interface.
- author:
Thomas.Diesler - @jboss.org
- version:
$ - Revision: 37459 $
| Methods from org.jboss.ejb.plugins.AbstractInterceptor: |
|---|
|
create, destroy, getContainer, getNext, invoke, invokeHome, isAppException, setContainer, setNext, start, stop |
| Method from org.jboss.ejb.plugins.CallValidationInterceptor Detail: |
public Object invoke(Invocation mi) throws Exception {
validateArguments(mi);
Object obj = getNext().invoke(mi);
return validateReturnValue(mi, obj);
}
|
public Object invokeHome(Invocation mi) throws Exception {
validateArguments(mi);
Object obj = getNext().invokeHome(mi);
return validateReturnValue(mi, obj);
}
|
protected void validateArguments(Invocation mi) {
if (mi.getType() == InvocationType.REMOTE)
{
Object[] params = mi.getArguments();
for (int i = 0; i < params.length; i++)
{
Object obj = params[i];
if (obj instanceof TimerHandle)
throw new IllegalArgumentException("Cannot pass TimerHandle through remote interface");
}
}
}
Do some validation of the incoming parameters |
protected Object validateReturnValue(Invocation mi,
Object retValue) {
if (mi.getType() == InvocationType.REMOTE)
{
if (retValue instanceof TimerHandle)
throw new IllegalArgumentException("Cannot return TimerHandle from remote interface");
}
return retValue;
}
Do some validation of the return value |