1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 40 abstract public class CallInterceptorStubBase 41 { 42 static private String _class_name = "CallInterceptorSkBase"; 44 private ORBService _orb_service; 45 private ServicesSet _services_set; 46 private String _uuid; 47 48 private org.omg.CORBA.Object _delegate; 49 private ClientCallContextImpl _call_ctx; 50 private java.util.Hashtable _informations; 51 52 protected 54 CallInterceptorStubBase(ORBService orbs, ServicesSet sset, 55 String uuid, org.omg.CORBA.Object del) 56 { 57 _orb_service = orbs; 59 _services_set = sset; 60 _uuid = uuid; 61 _delegate = del; 62 _informations = new java.util.Hashtable (); 63 64 _call_ctx = new ClientCallContextImpl(_orb_service, _services_set, del); 66 } 67 68 72 final protected ORBService 73 _getORBService() 74 { 75 return _orb_service; 76 } 77 78 final protected ClientCallContextImpl 79 _getCallCtx() 80 { 81 return _call_ctx; 82 } 83 84 final protected CallInformation 85 _getCallInformation(String sname) 86 { 87 CallInformation info = (CallInformation)_informations.get(sname); 89 90 if (info==null) { 91 info = new CallInformation(); 93 _informations.put(sname, info); 95 } 96 97 if (info.policies==null) { 100 info.policies = _services_set.get_policies(_uuid, sname); 101 } 102 103 105 return info; 106 } 107 108 final protected short 109 _preinvoke(org.coach.ECA.ClientCallController[] ctrls) 110 { 111 final String opname = "preinvoke"; 112 org.omg.CORBA.Any curr_exc = null; 113 org.omg.CORBA.Any curr_res = null; 114 115 short fstate = FlowState.SEND_REQUEST; 117 int ctrl_idx = 0; 118 boolean finished = false; 119 org.coach.ECA.ClientCallController ctrl = null; 120 121 while ((!finished) && (ctrl_idx<ctrls.length)){ 122 curr_exc = _getCallCtx().system_exception(); 124 if (curr_exc!=null) { 125 fstate = FlowState.RECEIVE_SYSTEM_EXCEPTION; 127 } 128 129 curr_exc = _getCallCtx().user_exception(); 131 if (curr_exc!=null) { 132 fstate = FlowState.RECEIVE_USER_EXCEPTION; 134 } 135 136 curr_res = _getCallCtx().result(); 138 if (curr_res!=null) { 139 final String msg = "FAILED (unexpected state in preinvoke: RECEIVE_REPLY)"; 141 TheLogger.error(_class_name, opname, msg); 142 } 143 144 if (fstate==FlowState.SEND_REQUEST) { 146 ctrl = ctrls[ctrl_idx++]; 148 ctrl.send_request(_getCallCtx()); 149 150 _getCallCtx().pushController(ctrl); 152 } 153 else if (_getCallCtx().isEmpty()) { 155 finished = true; 156 } 157 else if (fstate==FlowState.RECEIVE_SYSTEM_EXCEPTION) { 159 ctrl = _getCallCtx().popController(); 161 ctrl.receive_system_exception(_getCallCtx()); 162 } 163 else if (fstate==FlowState.RECEIVE_SYSTEM_EXCEPTION) { 165 ctrl = _getCallCtx().popController(); 167 ctrl.receive_user_exception(_getCallCtx()); 168 } 169 else { 171 final String msg = "FAILED (unexpected state in preinvoke: RECEIVE_REPLY)"; 173 TheLogger.error(_class_name, opname, msg); 174 } 175 } 176 177 return fstate; 179 } 180 181 final protected short 182 _postinvoke(short fstate) 183 { 184 org.omg.CORBA.Any curr_exc = null; 185 org.omg.CORBA.Any curr_res = null; 186 boolean finished = false; 187 org.coach.ECA.ClientCallController ctrl = null; 188 189 192 curr_exc = _getCallCtx().system_exception(); 194 curr_exc = _getCallCtx().user_exception(); 195 if (curr_exc!=null) { 196 fstate = FlowState.RECEIVE_SYSTEM_EXCEPTION; 198 } 199 else if (curr_exc!=null) { 201 fstate = FlowState.RECEIVE_USER_EXCEPTION; 203 } 204 else { 205 fstate = FlowState.RECEIVE_REPLY; 207 } 208 209 while (!finished) { 210 if (_getCallCtx().isEmpty()) { 212 finished = true; 213 } 214 else if (fstate==FlowState.RECEIVE_SYSTEM_EXCEPTION) { 216 ctrl = _getCallCtx().popController(); 218 ctrl.receive_system_exception(_getCallCtx()); 219 } 220 else if (fstate==FlowState.RECEIVE_SYSTEM_EXCEPTION) { 222 ctrl = _getCallCtx().popController(); 224 ctrl.receive_user_exception(_getCallCtx()); 225 } 226 else { 228 ctrl = _getCallCtx().popController(); 230 ctrl.receive_reply(_getCallCtx()); 231 } 232 233 curr_exc = _getCallCtx().system_exception(); 235 if (curr_exc!=null) { 236 fstate = FlowState.RECEIVE_SYSTEM_EXCEPTION; 238 } 239 240 curr_exc = _getCallCtx().user_exception(); 242 if (curr_exc!=null) { 243 fstate = FlowState.RECEIVE_USER_EXCEPTION; 245 } 246 247 curr_res = _getCallCtx().result(); 249 if (curr_res!=null) { 250 fstate = FlowState.RECEIVE_REPLY; 252 } 253 } 254 255 return fstate; 257 } 258 } | Popular Tags |