1 17 18 package org.apache.geronimo.security.remoting.jmx; 19 20 import java.io.IOException ; 21 import java.io.ObjectInput ; 22 import java.io.ObjectOutput ; 23 import java.io.Externalizable ; 24 import java.lang.reflect.Method ; 25 import java.util.Map ; 26 import java.util.HashMap ; 27 import java.util.Iterator ; 28 29 import org.apache.geronimo.interceptor.Invocation; 30 import org.apache.geronimo.interceptor.InvocationKey; 31 32 35 final public class SerializableInvocation implements Invocation, Externalizable { 36 37 private Map data; 38 private Method method; 39 private Object args[]; 40 private Object proxy; 41 42 public SerializableInvocation() { 43 super(); 44 } 45 46 public SerializableInvocation(Method method, Object [] args, Object proxy) { 47 super(); 48 this.method = method; 49 this.args = args; 50 this.proxy = proxy; 51 } 52 53 public Object get(InvocationKey key) { 54 if(data==null) { 55 return null; 56 } 57 return data.get(key); 58 } 59 60 public void put(InvocationKey key, Object value) { 61 if(data==null) 62 data = new HashMap (); 63 data.put(key, value); 64 } 65 66 public void writeExternal(ObjectOutput out) throws IOException { 67 if( data !=null ) { 68 Iterator iterator = data.keySet().iterator(); 69 while(iterator.hasNext()) { 70 InvocationKey key = (InvocationKey) iterator.next(); 71 if( key.isTransient() ) 72 continue; Object value = data.get(key); 74 out.writeObject(key); 75 out.writeObject(value); 76 } 77 } 78 out.writeObject(null); 80 out.writeObject(args); 81 out.writeObject(new MarshalledMethod(method)); 82 } 83 84 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 85 86 if( data!=null ) 87 data.clear(); 88 89 InvocationKey key = (InvocationKey) in.readObject(); 90 while( key!=null ) { 91 Object value = in.readObject(); 92 put(key,value); 93 key = (InvocationKey) in.readObject(); 94 } 95 args = (Object []) in.readObject(); 96 method = ((MarshalledMethod) in.readObject()).getMethod(); 97 } 98 99 public Method getMethod() { 100 return method; 101 } 102 103 public Object [] getArgs() { 104 return args; 105 } 106 107 } 108 | Popular Tags |