1 22 package org.jboss.resource.binding.remote; 23 24 import java.io.ByteArrayInputStream ; 25 import java.io.ByteArrayOutputStream ; 26 import java.io.ObjectOutputStream ; 27 import java.io.OutputStream ; 28 import java.io.Serializable ; 29 30 import org.jboss.invocation.Invocation; 31 import org.jboss.proxy.Interceptor; 32 33 39 public class RemoteSerializableInterceptor extends Interceptor 40 { 41 42 43 private static final long serialVersionUID = -6940983640563009944L; 44 45 public Object invoke(Invocation mi) throws Throwable 46 { 47 48 final Object [] arguments = mi.getArguments(); 49 50 for (int i = 0; i < arguments.length; i++) 51 { 52 53 final Object argument = arguments[i]; 54 55 if(wrapArgument(argument)){ 56 57 arguments[i] = generateWrapper(argument); 58 59 } 60 61 } 62 63 return getNext().invoke(mi); 64 } 65 66 private boolean wrapArgument(final Object obj){ 67 68 return (obj instanceof Serializable ); 69 70 } 71 72 private Object generateWrapper(Object argument) throws Exception { 73 74 RemoteSerializer serializer = RemoteSerializerFactory.getSerializer(); 75 Object wrapper = serializer.serialize(argument); 76 return wrapper; 77 78 } 79 80 } 81 | Popular Tags |