| 1 package org.sapia.ubik.rmi.server.transport; 2 import java.io.IOException ; 3 import java.io.ObjectOutputStream ; 4 import java.io.OutputStream ; 5 6 import org.sapia.ubik.rmi.server.Hub; 7 import org.sapia.ubik.rmi.server.VmId; 8 import org.sapia.ubik.rmi.server.perf.PerfAnalyzer; 9 10 11 25 public class MarshalOutputStream extends ObjectOutputStream { 26 private VmId _id; 27 private String _transportType; 28 private PerfAnalyzer _perf = PerfAnalyzer.getInstance(); 29 30 33 public MarshalOutputStream(OutputStream os) throws IOException { 34 super(os); 35 super.enableReplaceObject(true); 36 } 37 38 public void setUp(VmId id, String transportType) { 39 _id = id; 40 _transportType = transportType; 41 } 42 43 46 protected Object replaceObject(Object obj) throws IOException { 47 if (obj instanceof java.rmi.Remote ) { 48 if (_id == null) { 49 throw new IllegalStateException ("VmId not set on " + 50 getClass().getName()); 51 } 52 53 if (_perf.isEnabled()) { 54 _perf.getTopic(getClass().getName() + ".StubOutput").start(); 55 } 56 57 Object remote = Hub.asRemote(obj, _id, _transportType); 58 59 if (_perf.isEnabled()) { 60 _perf.getTopic(getClass().getName() + ".StubOutput").end(); 61 } 62 63 return remote; 64 } else { 65 return obj; 66 } 67 } 68 } 69 | Popular Tags |