1 28 29 30 package org.objectweb.ccm.runtime; 31 32 import org.objectweb.corba.runtime.*; 33 34 37 public class ServerCallContextImpl 38 extends org.omg.CORBA.LocalObject 39 implements org.coach.ECA.ServerCallContext 40 { 41 static private String _class_name = "ServerCallContextImpl"; 43 private java.util.Hashtable _call_infos; private ORBService _orb_service; 45 private ServicesSet _services_set; 46 private org.omg.Components.ExecutorSegmentBase _segment_executor; 50 private org.coach.ECM.ECMExecutor _ecm_executor; 51 52 public 54 ServerCallContextImpl(ORBService orbs, 55 ServicesSet services, 56 org.omg.CORBA.Object exe) 57 { 58 _orb_service = orbs; 59 _services_set = services; 60 _ecm_executor = null; 61 _segment_executor = null; 62 63 if (exe instanceof org.coach.ECM.ECMExecutor) { 64 _ecm_executor = (org.coach.ECM.ECMExecutor)exe; 65 } else if (exe instanceof org.omg.Components.ExecutorSegmentBase) { 66 _segment_executor = (org.omg.Components.ExecutorSegmentBase)exe; 67 } else { 68 final String opname = "ServerCallContextImpl"; 69 final String msg = "FAILED (class not supported: "+exe.getClass()+")"; 70 TheLogger.error(_class_name, opname, msg); 71 } 72 73 _call_infos = new java.util.Hashtable (); 74 } 75 76 80 final public org.coach.ECA.ServerCallController 81 popController() 82 { 83 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 84 return (org.coach.ECA.ServerCallController)callinfo.controller_stack.pop(); 85 } 86 87 final public void 88 pushController(org.coach.ECA.ServerCallController ctrl) 89 { 90 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 91 callinfo.controller_stack.push(ctrl); 92 } 93 94 final public boolean 95 isEmpty() 96 { 97 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 98 return callinfo.controller_stack.isEmpty(); 99 } 100 101 final public void 102 addEntry(CallInformation cinfo, String opname) 103 { 104 ServerCallInformation callinfo = new ServerCallInformation(); 106 107 callinfo.call_information = cinfo; 109 callinfo.result = null; 110 callinfo.system_exception = null; 111 callinfo.user_exception = null; 112 callinfo.eca_call_information.operation_name = opname; 113 114 _call_infos.put(Thread.currentThread().getName(), callinfo); 116 } 117 118 final public void 119 removeEntry() 120 { 121 _call_infos.remove(Thread.currentThread().getName()); 123 } 124 125 final public void 126 setResult(org.omg.CORBA.Any res) 127 { 128 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 129 callinfo.result = res; 130 } 131 132 136 final public org.coach.ECA.CallInformation 137 call_information() 138 { 139 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 140 return callinfo.eca_call_information; 141 } 142 143 final public org.omg.CORBA.Any 144 result() 145 { 146 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 147 return callinfo.result; 148 } 149 150 final public org.omg.CORBA.Any 151 system_exception() 152 { 153 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 154 return callinfo.system_exception; 155 } 156 157 final public org.omg.CORBA.Any 158 user_exception() 159 { 160 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 161 return callinfo.user_exception; 162 } 163 164 final public void 165 send_system_exception(org.omg.CORBA.Any exc) 166 { 167 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 168 callinfo.system_exception = exc; 169 } 170 171 final public void 172 send_user_exception(org.omg.CORBA.Any exc) 173 { 174 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 175 callinfo.user_exception = exc; 176 } 177 178 final public org.omg.CORBA.Object 179 get_service_internal(String sid, String internal_id) 180 { 181 Service s = _services_set.find_service(sid); 182 if (s==null) { 183 return null; 184 } 185 186 return s.get_service_internal(internal_id); 187 } 188 189 final public org.omg.CORBA.Object 190 get_service_callback(String sid, String callback_id) 191 throws org.coach.ECM.UnknownService, 192 org.coach.ECM.UnknownServiceCallback 193 { 194 if (_ecm_executor==null) { 195 throw new org.coach.ECM.UnknownService(); 196 } 197 198 return _ecm_executor.get_service_callback(sid, callback_id); 199 } 200 201 final public org.coach.ECA.Slot 202 get_slot(int slot_id) 203 { 204 return ComponentRuntime.getSlotFactory().getSlot(slot_id); 205 } 206 207 final public org.omg.CORBA.Any 208 create_any() 209 { 210 return _orb_service.create_any(); 211 } 212 213 217 final public org.omg.CORBA.Policy 218 get_server_policy(int ptype) 219 { 220 ServerCallInformation callinfo = (ServerCallInformation)_call_infos.get(Thread.currentThread().getName()); 221 CallInformation cinfo = callinfo.call_information; 222 Policy[] pols = cinfo.policies; 223 for (int i=0;i<pols.length;i++) { 224 if (pols[i].corba_policy().policy_type()==ptype) { 225 return pols[i].corba_policy(); 226 } 227 } 228 229 return null; 230 } 231 } 232 233 class ServerCallInformation 234 { 235 public org.omg.CORBA.Any result; 236 public org.omg.CORBA.Any system_exception; 237 public org.omg.CORBA.Any user_exception; 238 public CallInformation call_information; 239 public java.util.Stack controller_stack; 240 public org.coach.ECA.CallInformation eca_call_information; 241 242 public 243 ServerCallInformation() 244 { 245 result = null; 246 system_exception = null; 247 user_exception = null; 248 call_information = null; 249 controller_stack = new java.util.Stack (); 250 eca_call_information = new org.coach.ECA.CallInformation(); 251 } 252 } 253 | Popular Tags |