1 17 18 package org.apache.geronimo.core.service; 19 20 import java.io.Externalizable ; 21 import java.io.IOException ; 22 import java.io.ObjectInput ; 23 import java.io.ObjectOutput ; 24 import java.util.HashMap ; 25 import java.util.Iterator ; 26 import java.util.Map ; 27 28 34 public class SimpleInvocation implements Invocation, Externalizable { 35 36 private Map data; 37 38 public Object get(InvocationKey key) { 39 if(data==null) 40 return null; 41 return data.get(key); 42 } 43 44 public void put(InvocationKey key, Object value) { 45 if(data==null) 46 data = new HashMap (); 47 data.put(key, value); 48 } 49 50 53 public void writeExternal(ObjectOutput out) throws IOException { 54 if( data !=null ) { 55 Iterator iterator = data.keySet().iterator(); 56 while(iterator.hasNext()) { 57 InvocationKey key = (InvocationKey) iterator.next(); 58 if( key.isTransient() ) 59 continue; Object value = data.get(key); 61 out.writeObject(key); 62 out.writeObject(value); 63 } 64 } 65 out.writeObject(null); 67 } 68 69 72 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 73 74 if( data!=null ) 75 data.clear(); 76 77 InvocationKey key = (InvocationKey) in.readObject(); 78 while( key!=null ) { 79 Object value = in.readObject(); 80 put(key,value); 81 key = (InvocationKey) in.readObject(); 82 } 83 84 } 85 86 87 } 88 | Popular Tags |