1 20 21 package org.jacorb.orb.giop; 22 23 import org.jacorb.orb.*; 24 25 import org.omg.GIOP.*; 26 import org.omg.CORBA.portable.RemarshalException ; 27 28 36 public abstract class ReplyPlaceholder 37 { 38 protected boolean ready = false; 39 protected boolean communicationException = false; 40 protected boolean remarshalException = false; 41 protected boolean timeoutException = false; 42 43 protected MessageInputStream in = null; 44 45 protected int timeout ; 46 47 50 51 public ReplyPlaceholder(ORB orb) 52 { 53 timeout = 54 orb.getConfiguration().getAttributeAsInteger("jacorb.connection.client.pending_reply_timeout", 0); 55 } 56 57 public synchronized void replyReceived( MessageInputStream in ) 58 { 59 if( ! timeoutException ) 60 { 61 this.in = in; 62 ready = true; 63 notifyAll(); 64 } 65 } 66 67 public synchronized void cancel() 68 { 69 if( in == null ) 70 { 71 communicationException = true; 72 ready = true; 73 notify(); 74 } 75 } 76 77 78 public synchronized void retry() 79 { 80 remarshalException = true; 81 ready = true; 82 notify(); 83 } 84 85 92 99 protected synchronized MessageInputStream getInputStream() 100 throws RemarshalException 101 { 102 while( !ready ) 103 { 104 try 105 { 106 if( timeout > 0 ) 107 { 108 wait( timeout ); 110 if( ! ready ) 112 { 113 ready = true; timeoutException = true; 115 } 116 } 117 else 118 { 119 wait(); } 121 } 122 catch( InterruptedException e ) 123 {} 124 } 125 126 if( remarshalException ) 127 { 128 throw new org.omg.CORBA.portable.RemarshalException (); 129 } 130 131 if( communicationException ) 132 { 133 throw new org.omg.CORBA.COMM_FAILURE ( 134 0, 135 org.omg.CORBA.CompletionStatus.COMPLETED_MAYBE ); 136 } 137 138 if( timeoutException ) 139 { 140 throw new org.omg.CORBA.TIMEOUT ("client timeout reached"); 141 } 142 143 return in; 144 } 145 } | Popular Tags |