1 22 package org.jboss.invocation.pooled.interfaces; 23 24 import java.io.IOException ; 25 import java.io.OutputStream ; 26 import java.io.ObjectOutputStream ; 27 import java.io.ObjectStreamClass ; 28 import java.rmi.Remote ; 29 import java.rmi.server.RemoteObject ; 30 import java.rmi.server.RemoteStub ; 31 32 42 public class OptimizedObjectOutputStream 43 extends ObjectOutputStream 44 { 45 46 51 public OptimizedObjectOutputStream(OutputStream os) throws IOException 52 { 53 super(os); 54 enableReplaceObject(true); 55 } 56 57 62 protected void writeClassDescriptor(ObjectStreamClass classdesc) 63 throws IOException 64 { 65 if (CompatibilityVersion.pooledInvokerLegacy) 66 { 67 writeUTF(classdesc.getName()); 68 } 69 else 70 { 71 super.writeClassDescriptor(classdesc); 72 } 73 } 74 75 78 protected Object replaceObject(Object obj) throws IOException 79 { 80 if( (obj instanceof Remote ) && !(obj instanceof RemoteStub ) ) 81 { 82 Remote remote = (Remote ) obj; 83 try 84 { 85 obj = RemoteObject.toStub(remote); 86 } 87 catch(IOException ignore) 88 { 89 } 91 } 92 return obj; 93 } 94 } 95 | Popular Tags |