package org.jboss.resource.adapter.jdbc.remote;
import org.jboss.invocation.Invocation;
import org.jboss.proxy.Interceptor;
import java.io.InputStream;
import java.io.Reader;
import java.lang.reflect.Method;
public class StatementInterceptor extends Interceptor
{
public Object invoke(Invocation mi) throws Throwable
{
Method m = mi.getMethod();
String methodName = m.getName();
if (methodName.equals("setAsciiStream") ||
methodName.equals("setBinaryStream"))
{
Object[] args = mi.getArguments();
InputStream ins = (InputStream) args[1];
args[1] = new SerializableInputStream(ins);
}
else if (methodName.equals("setCharacterStream"))
{
Object[] args = mi.getArguments();
Reader rdr = (Reader) args[1];
args[1] = new SerializableReader(rdr);
}
return getNext().invoke(mi);
}
}