1 26 27 package org.objectweb.openccm.ir3; 28 29 import org.omg.CORBA.*; 31 32 40 41 public class OperationDef_impl 42 extends FeatureContained 43 implements OperationDefOperations 44 { 45 51 52 protected IDLType_ref result_def_; 53 54 55 protected Parameters params_; 56 57 58 protected OperationMode mode_; 59 60 61 protected String [] contexts_; 62 63 64 protected ExceptionDef_ref[] exceptions_; 65 66 72 73 public 74 OperationDef_impl(IFR ifr, 75 Container_impl container) 76 { 77 this(ifr, container, false); 78 79 setServant(new OperationDefPOATie(this)); 81 } 82 83 84 public 85 OperationDef_impl(IFR ifr, 86 Container_impl container, 87 boolean dummy) 88 { 89 super(ifr, container); 91 92 result_def_ = new IDLType_ref(this, 94 ifr.getRepository().getPrimDefVoid()); 95 96 params_ = new Parameters(this); 98 mode_ = OperationMode.OP_NORMAL; 99 contexts_ = null; 100 exceptions_ = null; 101 } 102 103 109 112 public OperationDef 113 asOperationDef() 114 { 115 return OperationDefHelper.narrow(asObject()); 116 } 117 118 121 public OperationDescription 122 getOperationDescription() 123 { 124 OperationDescription description = new OperationDescription(); 126 127 description.name = name(); 129 description.id = id(); 130 description.defined_in = getContainerID(); 131 description.version = version(); 132 description.result = result(); 133 description.mode = mode(); 134 description.contexts = contexts(); 135 description.parameters = params(); 136 description.exceptions = 137 ExceptionDef_impl.compute_ExcDescriptionSeq(exceptions_); 138 139 return description; 140 } 141 142 148 151 public void 152 setDescriptionValue(Any any) 153 { 154 OperationDescriptionHelper.insert(any, getOperationDescription()); 156 } 157 158 164 167 protected void 168 cutDependencies() 169 { 170 result_def_.cutDependency(); 172 173 params_.cutDependencies(); 175 176 mode_ = null; 177 contexts_ = null; 178 179 ExceptionDef_ref.cutDependencies(exceptions_); 181 exceptions_ = null; 182 183 super.cutDependencies(); 185 } 186 187 193 196 public DefinitionKind 197 def_kind() 198 { 199 return DefinitionKind.dk_Operation; 200 } 201 202 208 211 public TypeCode 212 result() 213 { 214 return result_def_.recursiveType(); 216 } 217 218 221 public IDLType 222 result_def() 223 { 224 return result_def_.asIDLType(); 226 } 227 228 231 public void 232 result_def(IDLType val) 233 { 234 result_def_.setDependency( castToLocal(val) ); 237 } 238 239 242 public ParameterDescription[] 243 params() 244 { 245 return params_.getParameterDescriptionSeq(); 247 } 248 249 252 public void 253 params(ParameterDescription[] val) 254 { 255 if(mode_ == OperationMode.OP_ONEWAY) 257 for(int i=0; i<val.length; i++) 258 if(val[i].mode != ParameterMode.PARAM_IN) 259 throw exceptionNeedOnlyInParams(); 260 261 params_.setParameterDescriptionSeq(val); 263 } 264 265 268 public OperationMode 269 mode() 270 { 271 return mode_; 272 } 273 274 277 public void 278 mode(OperationMode val) 279 { 280 if(val == OperationMode.OP_ONEWAY) 282 { 283 params_.checkOnlyInModes(); 284 if(exceptions_ != null && exceptions_.length != 0) 285 throw exceptionNoExceptionsForOnewayOperation(); 286 } 287 mode_ = val; 288 } 289 290 293 public String [] 294 contexts() 295 { 296 return contexts_; 297 } 298 299 302 public void 303 contexts(String [] val) 304 { 305 contexts_ = val; 307 } 308 309 312 public ExceptionDef[] 313 exceptions() 314 { 315 ExceptionDef[] result = new ExceptionDef[exceptions_.length]; 316 317 for(int i=0; i<exceptions_.length; i++) 318 result[i] = exceptions_[i].asExceptionDef(); 319 320 return result; 321 } 322 323 326 public void 327 exceptions(ExceptionDef[] val) 328 { 329 if(mode_ == OperationMode.OP_ONEWAY) 331 { 332 if(val.length != 0) 333 throw exceptionNoExceptionsForOnewayOperation(); 334 } 335 336 ExceptionDef_impl[] exceptions = new ExceptionDef_impl[val.length]; 337 for (int i=0; i<val.length; i++) 338 exceptions[i] = castToLocal(val[i]); 339 340 342 ExceptionDef_ref[] refs = new ExceptionDef_ref[val.length]; 343 for (int i=0; i<val.length; i++) 344 refs[i] = new ExceptionDef_ref( this, exceptions[i] ); 345 346 ExceptionDef_ref.cutDependencies(exceptions_); 348 349 exceptions_ = refs; 350 } 351 352 358 361 protected void 362 whenCreated() 363 { 364 if (!getIFR().getRepository().enable_mappings_) 366 return ; 367 368 if (container_.def_kind().value()!=org.omg.CORBA.DefinitionKind._dk_Home) 370 return ; 371 372 374 InterfaceDef_impl explicit = ((HomeDef_impl)container_).base_interfaces_[0].getImpl(); 381 String explicit_base_id = explicit.getBaseID(); 382 String id = explicit_base_id + name() + ":" + version(); 383 384 container_.mapping_started_ = true; 385 explicit.create_operation(id, name(), version(), result_def(), mode(), 386 params(), exceptions(), contexts()); 387 container_.mapping_started_ = false; 388 389 String cont_base_id = container_.getBaseContainerID(); 396 397 String explicit_exe_id = cont_base_id + "CCM_" + container_.name() + "Explicit:" + container_.version(); 398 org.omg.CORBA.ExtLocalInterfaceDef explicit_exe = org.omg.CORBA.ExtLocalInterfaceDefHelper.narrow( 399 getIFR().getRepository().lookup_mapped_id(explicit_exe_id)); 400 401 id = cont_base_id + "CCM_" + container_.name() + "Explicit/" + name() + ":" + container_.version(); 402 explicit_exe.create_operation(id, name(), version(), 403 result_def(), 404 mode(), 405 params(), 406 exceptions(), 407 contexts()); 408 } 409 } 410 | Popular Tags |