1 2 package SOFA.SOFAnode.Made.TIR.Impl; 3 import java.rmi.RemoteException ; 4 import java.rmi.server.ServerNotActiveException ; 5 import java.rmi.server.UnicastRemoteObject ; 6 7 import SOFA.SOFAnode.Made.TIR.ConstantDef; 8 import SOFA.SOFAnode.Made.TIR.Contained; 9 import SOFA.SOFAnode.Made.TIR.Container; 10 import SOFA.SOFAnode.Made.TIR.DefinitionKind; 11 import SOFA.SOFAnode.Made.TIR.EnumDef; 12 import SOFA.SOFAnode.Made.TIR.EnumMember; 13 import SOFA.SOFAnode.Made.TIR.ExprBinOperationDef; 14 import SOFA.SOFAnode.Made.TIR.ExprBoolean; 15 import SOFA.SOFAnode.Made.TIR.ExprChar; 16 import SOFA.SOFAnode.Made.TIR.ExprConstant; 17 import SOFA.SOFAnode.Made.TIR.ExprDefault; 18 import SOFA.SOFAnode.Made.TIR.ExprDouble; 19 import SOFA.SOFAnode.Made.TIR.ExprEnum; 20 import SOFA.SOFAnode.Made.TIR.ExprFixed; 21 import SOFA.SOFAnode.Made.TIR.ExprFloat; 22 import SOFA.SOFAnode.Made.TIR.ExprLong; 23 import SOFA.SOFAnode.Made.TIR.ExprLongDouble; 24 import SOFA.SOFAnode.Made.TIR.ExprLongLong; 25 import SOFA.SOFAnode.Made.TIR.ExprOctet; 26 import SOFA.SOFAnode.Made.TIR.ExprOperDef; 27 import SOFA.SOFAnode.Made.TIR.ExprProperty; 28 import SOFA.SOFAnode.Made.TIR.ExprShort; 29 import SOFA.SOFAnode.Made.TIR.ExprString; 30 import SOFA.SOFAnode.Made.TIR.ExprUnOperationDef; 31 import SOFA.SOFAnode.Made.TIR.ExprUnsigLong; 32 import SOFA.SOFAnode.Made.TIR.ExprUnsigLongLong; 33 import SOFA.SOFAnode.Made.TIR.ExprUnsigShort; 34 import SOFA.SOFAnode.Made.TIR.ExprWchar; 35 import SOFA.SOFAnode.Made.TIR.ExprWstring; 36 import SOFA.SOFAnode.Made.TIR.Identification; 37 import SOFA.SOFAnode.Made.TIR.ManageProfiles; 38 import SOFA.SOFAnode.Made.TIR.ManageRepository; 39 import SOFA.SOFAnode.Made.TIR.PrimitiveDef; 40 import SOFA.SOFAnode.Made.TIR.ProfileDef; 41 import SOFA.SOFAnode.Made.TIR.Repository; 42 import SOFA.SOFAnode.Made.TIR.StateKind; 43 import SOFA.SOFAnode.Made.TIR.TIRExceptCommit; 44 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate; 45 import SOFA.SOFAnode.Made.TIR.TIRExceptLock; 46 import SOFA.SOFAnode.Made.TIR.TIRExceptSave; 47 import SOFA.SOFAnode.Made.TIR.TIRObject; 48 import SOFA.SOFAnode.Made.TIR.ValueGen; 49 import SOFA.SOFAnode.Made.TIR.WorkRepository; 50 51 public class WorkRepositoryImpl extends ContainerImpl implements WorkRepository, Repository { 52 53 Lock lock; 54 RepositoryImpl normalRep; 55 DefinitionKindImpl defKindImpl; 56 StateKindImpl stKindImpl; 57 PrimitiveDef[] primitives; 59 60 ProfileDef actProfile; 61 ManageProfilesImpl mProfiles; 62 63 boolean commited; 64 boolean aborted; 65 66 long workId; String workIdString; 68 boolean lockForMe; 70 LiIdItem firstId; LiIdItem lastId; 72 int numOfIds; 73 74 public WorkRepositoryImpl(RepositoryImpl nR, ProfileDef prof) throws RemoteException , TIRExceptCreate, TIRExceptLock { 75 normalRep = nR; 76 normalRep.lockProfiles.lock(); 77 lock = nR.lock; 78 mProfiles = new ManageProfilesImpl(normalRep.mProfiles, this); 79 if (prof == null) { 80 actProfile = null; 81 } else { 82 ProfileDef a = mProfiles.lookup(prof.name()); 83 if (a==null) { normalRep.lockProfiles.unlock(); 85 throw new TIRExceptCreate("Bad profile"); 86 } 87 if (((SProfileDef)a).isLocked()) { normalRep.lockProfiles.unlock(); 89 throw new TIRExceptCreate("Profile is locked"); 90 } 91 92 if (!((SProfileDef)a).lock()) { normalRep.lockProfiles.unlock(); 94 throw new TIRExceptLock("Profile can not lock."); 95 } 96 97 actProfile = a; 98 } 99 normalRep.lockProfiles.unlock(); 100 workId = nR.getUniqueNumber(); 101 try { 102 workIdString = UnicastRemoteObject.getClientHost(); 103 } catch (ServerNotActiveException e) { 104 workIdString = "unknown"; 105 } 106 workIdString = workIdString + " : " + workId; 107 defKindImpl = new DefinitionKindImpl(DefinitionKind.dk_WorkRepository); 108 stKindImpl = new StateKindImpl(StateKind.sk_work); 109 primitives = new PrimitiveDef [17]; 111 for(int i=0;i<17;i++) { 112 primitives[i] = new PrimitiveDefImpl(i,StateKind.sk_work); 113 } 114 commited = false; 115 aborted = false; 116 firstId = lastId = null; 117 numOfIds = 0; 118 } 119 120 public Contained lookup(Identification id) throws RemoteException , TIRExceptLock { 121 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 122 fromNormRep(); 123 } 124 Contained ret = null; 125 LiItem akt = firstChild; 126 for(int i=0;i<numOfItems;i++) { 127 if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(id.name())==0) { 128 ret = (Contained) akt.obj; 129 break; 130 } else { 131 akt = akt.next; 132 } 133 } 134 return ret; 135 } 136 137 public Contained lookup(String name, String version) throws RemoteException , TIRExceptLock { 138 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 139 fromNormRep(); 140 } 141 Contained ret = null; 142 LiItem akt = firstChild; 143 for(int i=0;i<numOfItems;i++) { 144 if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(name)==0) { 145 ret = (Contained) akt.obj; 146 break; 147 } else { 148 akt = akt.next; 149 } 150 } 151 return ret; 152 } 153 154 public Contained[] contents(DefinitionKind type) throws RemoteException , TIRExceptLock { 155 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 156 fromNormRep(); 157 } 158 return super.contents(type); 159 } 160 161 public Contained[] lookup_name(Identification id) throws RemoteException , TIRExceptLock { 162 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 163 fromNormRep(); 164 } 165 return super.lookup_name(id); 166 } 167 168 public Contained[] lookup_name(String name) throws RemoteException , TIRExceptLock { 169 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 170 fromNormRep(); 171 } 172 return super.lookup_name(name); 173 } 174 175 public Contained lookup_tag(String name, String tag) throws RemoteException , TIRExceptLock { 176 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 177 fromNormRep(); 178 } 179 return super.lookup_tag(name, tag); 180 } 181 182 public Contained[] lookup_branchtag(String name, String brtag) throws RemoteException , TIRExceptLock { 183 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 184 fromNormRep(); 185 } 186 return super.lookup_branchtag(name, brtag); 187 } 188 189 public Contained lookup_lastinbranch(String name, String brtag) throws RemoteException , TIRExceptLock { 190 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 191 fromNormRep(); 192 } 193 return super.lookup_lastinbranch(name, brtag); 194 } 195 196 public Contained lookup_lastfromversion(String name, String version) throws RemoteException , TIRExceptLock { 197 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 198 fromNormRep(); 199 } 200 return super.lookup_lastfromversion(name, version); 201 } 202 203 public Contained[] scontents(DefinitionKind type) throws RemoteException , TIRExceptLock { 204 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 205 fromNormRep(); 206 } 207 return super.scontents(type); 208 } 209 210 public Contained slookup(Identification id) throws RemoteException , TIRExceptLock { 211 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 212 fromNormRep(); 213 } 214 Contained ret = null; 215 LiItem akt = firstChild; 216 for(int i=0;i<numOfItems;i++) { 217 if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(id.name())==0) { 218 ret = (Contained) akt.obj; 219 break; 220 } else { 221 akt = akt.next; 222 } 223 } 224 return ret; 225 } 226 227 public Contained slookup(String name, String version) throws RemoteException , TIRExceptLock { 228 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 229 fromNormRep(); 230 } 231 Contained ret = null; 232 LiItem akt = firstChild; 233 for(int i=0;i<numOfItems;i++) { 234 if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(name)==0) { 235 ret = (Contained) akt.obj; 236 break; 237 } else { 238 akt = akt.next; 239 } 240 } 241 return ret; 242 } 243 244 public Contained[] slookup_name(Identification id) throws RemoteException , TIRExceptLock { 245 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 246 fromNormRep(); 247 } 248 Contained[] ret = null; 249 LiItem akt = firstChild; 250 for(int i=0;i<numOfItems;i++) { 251 if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(id.name())==0) { 252 ret = new Contained [1]; 253 ret[0] = (Contained) akt.obj; 254 break; 255 } else { 256 akt = akt.next; 257 } 258 } 259 return ret; 260 } 261 262 public Contained[] slookup_name(String name) throws RemoteException , TIRExceptLock { 263 if ((stKindImpl.value()==StateKind.sk_work) && (!hasCont)) { 264 fromNormRep(); 265 } 266 Contained[] ret = null; 267 LiItem akt = firstChild; 268 for(int i=0;i<numOfItems;i++) { 269 if (((SIdentification) ((Contained)akt.obj).get_identification()).language().compareTo(name)==0) { 270 ret = new Contained [1]; 271 ret[0] = (Contained) akt.obj; 272 break; 273 } else { 274 akt = akt.next; 275 } 276 } 277 return ret; 278 } 279 280 public DefinitionKind get_spec_def_kind(int kind) throws RemoteException { 281 return new DefinitionKindImpl(kind); 282 } 283 284 static public TIRObject newWorkFromNormal(TIRObject norm, Repository r, Container in, long workId) throws RemoteException { 285 TIRObject ret=null; 286 int val = norm.get_def_kind().value(); 287 switch (val) { 288 case DefinitionKind.dk_CDLRepository: 289 ret = new CDLRepositoryImpl((CDLRepositoryImpl) norm, r, workId); 290 break; 291 case DefinitionKind.dk_Module: 292 ret = new ModuleDefImpl((ModuleDefImpl) norm,in,r,workId); 293 break; 294 case DefinitionKind.dk_Provider: 295 ret = new ProviderDefImpl((ProviderDefImpl)norm,in,r,workId); 296 break; 297 case DefinitionKind.dk_Struct: 298 ret = new StructDefImpl((StructDefImpl)norm,in,r,workId); 299 break; 300 case DefinitionKind.dk_Exception: 301 ret = new ExceptionDefImpl((ExceptionDefImpl)norm,in,r,workId); 302 break; 303 case DefinitionKind.dk_Enum: 304 ret = new EnumDefImpl((EnumDefImpl)norm,in,r, workId); 305 break; 306 case DefinitionKind.dk_Union: 307 ret = new UnionDefImpl((UnionDefImpl)norm,in,r,workId); 308 break; 309 case DefinitionKind.dk_Constant: 310 ret = new ConstantDefImpl((ConstantDefImpl)norm,in,r, workId); 311 break; 312 case DefinitionKind.dk_Typedef: 313 ret = new TypedefDefImpl((TypedefDefImpl)norm,in,r,workId); 314 break; 315 case DefinitionKind.dk_Interface: 316 ret = new InterfaceDefImpl((InterfaceDefImpl)norm,in,r,workId); 317 break; 318 case DefinitionKind.dk_Frame: 319 ret = new FrameDefImpl((FrameDefImpl)norm,in,r, workId); 320 break; 321 case DefinitionKind.dk_AModule: 322 ret = new AModuleDefImpl((AModuleDefImpl)norm,in,r,workId); 323 break; 324 case DefinitionKind.dk_Architecture: 325 ret = new ArchitectureDefImpl((ArchitectureDefImpl)norm,in,r, workId); 326 break; 327 case DefinitionKind.dk_Attribute: 328 ret = new AttributeDefImpl((AttributeDefImpl)norm,in,r,workId); 329 break; 330 case DefinitionKind.dk_Operation: 331 ret = new OperationDefImpl((OperationDefImpl)norm,in,r,workId); 332 break; 333 case DefinitionKind.dk_Inst: 334 ret = new InstDefImpl((InstDefImpl)norm,in,r,workId); 335 break; 336 case DefinitionKind.dk_Property: 337 ret = new PropertyDefImpl((PropertyDefImpl)norm,in,r,workId); 338 break; 339 case DefinitionKind.dk_Provides: 340 ret = new ProvideDefImpl((ProvideDefImpl)norm,in,r,workId); 341 break; 342 case DefinitionKind.dk_Requires: 343 ret = new RequireDefImpl((RequireDefImpl)norm,in,r,workId); 344 break; 345 case DefinitionKind.dk_StructMember: 346 ret = new StructMemberImpl((StructMemberImpl)norm,in,r); 347 break; 348 case DefinitionKind.dk_UnionMember: 349 ret = new UnionMemberImpl((UnionMemberImpl)norm,in,r); 350 break; 351 case DefinitionKind.dk_Bind: 352 ret = new BindDefImpl((BindDefImpl)norm,in,r); 353 break; 354 case DefinitionKind.dk_EnumMember: 355 ret = new EnumMemberImpl((EnumMemberImpl)norm); 356 break; 357 } 358 return ret; 359 } 360 361 private void fromNormRep() throws RemoteException , TIRExceptLock { 362 if (normalRep.lock.isLocked()) 363 throw new TIRExceptLock("Repository is locked"); 364 int i; 365 LiItem akt; 366 akt = normalRep.firstChild; 368 for(i=0;i<normalRep.numOfItems;i++) { 369 addListItem(newWorkFromNormal(akt.obj,this,this, workId)); 370 akt = akt.next; 371 } 372 hasCont = true; 373 } 375 376 377 public DefinitionKind get_def_kind() throws RemoteException { 378 return (DefinitionKind) defKindImpl; 379 } 380 381 382 public StateKind get_state() throws RemoteException { 383 return (StateKind) stKindImpl; 384 } 385 386 public void canCommit() {;} 387 public void doCommit(Container in, Repository rep) {;} 388 public void doAbort(long workId) {;} 389 public ManageRepository getManage() throws RemoteException { return null; } 390 public WorkRepository[] getActiveWork() throws RemoteException { return null; } 391 392 synchronized public boolean commit() throws RemoteException , TIRExceptCommit { 393 if (commited || aborted) 394 return false; 395 lock.lock(); 396 LiItem akt; 397 int i,j; 398 399 akt = firstChild; 400 for (i=0;i<numOfItems;i++) { 401 if (((TIRImplObject)akt.obj).isNew()) { 402 LiItem nak = normalRep.firstChild; 403 for (j=0;j<normalRep.numOfItems;j++) { 404 if (((SIdentification) ((Contained)nak.obj).get_identification()).is_short_name_equal(((Contained)akt.obj).get_identification())) { 405 if (akt.obj.get_def_kind().value()!=nak.obj.get_def_kind().value()) 406 throw new TIRExceptCommit("Object with name \""+((SContained)nak.obj).get_absolute_name().name()+"\"exists."); 407 if (((SIdentification) ((Contained)nak.obj).get_identification()).is_short_equal(((Contained)akt.obj).get_identification())) 408 throw new TIRExceptCommit("Object with identification \""+((Contained)nak.obj).get_identification()+"\"in container \"::\" exists."); 409 } 410 nak = nak.next; 411 } 412 } 413 ((TIRImplObject)akt.obj).canCommit(); 414 akt = akt.next; 415 } 416 mProfiles.canCommit(); 417 418 akt = firstChild; 419 boolean nn = false; 420 for(i=0;i<numOfItems;i++) { 421 if (((TIRImplObject)akt.obj).isNew()) 422 nn = true; 423 ((TIRImplObject)akt.obj).doCommit(normalRep,normalRep); 424 if (nn) { 425 normalRep.addListItem(akt.obj); 426 } 427 akt = akt.next; 428 nn = false; 429 } 430 try { 431 normalRep.postLoad(normalRep); 432 } catch (TIRExceptStorage e) { 433 throw new TIRExceptCommit("Some unexcepted error. Repository is in unstable state posibly.\n"+ 434 e.getMessage()); 435 } 436 mProfiles.doCommit(normalRep, normalRep); 437 438 if (lockForMe) { 439 normalRep.lockFor = -1L; 440 normalRep.lockCreate.unlock(); 441 lockForMe = false; 442 } 443 444 LiIdItem aktId = firstId; 445 for(i=0;i<numOfIds;i++) { 446 ((SIdentification)aktId.obj).setNextVersion(); 447 ((SIdentification)aktId.obj).unlock(); 448 aktId = aktId.next; 449 } 450 normalRep.removeWork(workId); 451 commited = true; 452 try { 453 normalRep.commitSave(); 454 } catch (TIRExceptSave e) { 455 lock.unlock(); 456 throw new TIRExceptCommit("Unsuccessful saving of repository.\n"+e.getMessage()); 457 } 458 lock.unlock(); 459 return true; 460 } 461 462 synchronized public boolean abort() throws RemoteException { 463 if (commited || aborted) 464 return false; 465 int i; 466 lock.lock(); 467 LiItem akt = firstChild; 468 for(i=0;i<numOfItems;i++) { 469 ((TIRImplObject)akt.obj).doAbort(workId); 472 akt = akt.next; 473 } 474 mProfiles.doAbort(workId); 475 476 if (lockForMe) { 477 normalRep.lockFor = -1L; 478 normalRep.lockCreate.unlock(); 479 lockForMe = false; 480 } 481 482 LiIdItem aktId = firstId; 483 for(i=0;i<numOfIds;i++) { 484 ((SIdentification)aktId.obj).unlock(); 485 aktId = aktId.next; 486 } 487 normalRep.removeWork(workId); 488 aborted = true; 489 lock.unlock(); 490 return true; 491 } 492 493 494 public Identification create_identification(String lang, String name, String version) throws RemoteException , TIRExceptCreate { 495 if (name==null || version==null || lang ==null) 496 return null; 497 if (name.length()<3) 498 throw new TIRExceptCreate("Bad name for identification."); 499 if (name.charAt(0)!=':' && name.charAt(0)!=':') 500 throw new TIRExceptCreate("You must give absolute name."); 501 if (lang.compareTo("cdl")!=0) throw new TIRExceptCreate("Bad language specification."); 503 return (Identification) new IdentificationImpl(new String (lang), new String (name), new String (version)); 504 } 505 506 507 public Identification create_nextversion(Identification id) throws RemoteException , TIRExceptCreate { 508 String ver = id.version(); 510 StringBuffer ip = new StringBuffer (); 511 int i = 0; 512 while ((i<ver.length()) && (ver.charAt(i)!='!')) { 513 ip.append(ver.charAt(i)); 514 i++; 515 } 516 517 if (normalRep.sofaNodeName.compareTo(ip.toString())!=0) 519 throw new TIRExceptCreate("You must create branch first."); 520 if (((SIdentification)id).hasNextVersion()) 521 throw new TIRExceptCreate("Next version from this exists."); 522 if (((SIdentification)id).isLocked()) 523 throw new TIRExceptCreate("Identification is locked for next version."); 524 ((SIdentification)id).lock(workId); 525 int last = ver.lastIndexOf('!'); 526 if (last != -1) { 527 long a = 0; 528 int j = last; 529 last++; 530 while ((last < ver.length())&&(Character.isDigit(ver.charAt(last)))) { 531 a *= 10; 532 a += (int) (ver.charAt(last)-'0'); 533 last++; 534 } 535 a++; 536 537 String rver = new String (ver.substring(0,j+1) + Long.toString(a)); 538 Identification newId = new IdentificationImpl(((SIdentification) id).language(), id.absolute_name().name(), rver); 539 540 LiIdItem item = new LiIdItem(id); 541 if (firstId == null) { 542 firstId = lastId = item; 543 } else { 544 LiIdItem akt = firstId; 545 while (akt.next != null) akt = akt.next; 546 akt.next = item; 547 item.prev = akt; 548 lastId = item; 549 } 550 numOfIds++; 551 552 return newId; 553 } else { 554 ((SIdentification)id).unlock(); 555 throw new TIRExceptCreate("Version parse error."); 556 } 557 } 558 559 public Identification create_initialversion(String lang, String name) throws RemoteException , TIRExceptCreate { 560 if (name==null || lang == null) 561 return null; 562 if (name.length()<3) 563 throw new TIRExceptCreate("Bad name for identification."); 564 if (name.charAt(0)!=':' && name.charAt(0)!=':') 565 throw new TIRExceptCreate("You must give absolute name."); 566 if (lang.compareTo("cdl")!=0) throw new TIRExceptCreate("Bad language specification."); 568 return new IdentificationImpl(new String (lang), new String (name), normalRep.sofaNodeName+"!0"); 569 } 570 571 public Identification create_branch(Identification from, String branchTag) throws RemoteException , TIRExceptCreate { 572 if (branchTag==null || branchTag.length()==0) 573 throw new TIRExceptCreate("You must give branchTag."); 574 String ver = from.version(); 575 String rver = normalRep.sofaNodeName+"!"+ver+"!"+((SIdentification)from).nextNumBranch()+"!1"; 576 ((SIdentification)from).incNextNumBranch(); 577 return new IdentificationImpl(((SIdentification) from).language(), from.absolute_name().name(), rver, branchTag); 578 } 579 580 public PrimitiveDef get_primitive(int kind) throws RemoteException , TIRExceptCreate { 581 if (kind>=0 && kind<=17) 582 return primitives[kind]; 583 else 584 return null; 585 } 586 587 923 924 public ExprBoolean create_exprboolean(boolean val) throws RemoteException , TIRExceptCreate { 925 return new ExprBooleanImpl(val); 926 } 927 public ExprShort create_exprshort(short val) throws RemoteException , TIRExceptCreate { 928 return new ExprShortImpl(val); 929 } 930 public ExprOctet create_exproctet(byte val) throws RemoteException , TIRExceptCreate { 931 return new ExprOctetImpl(val); 932 } 933 934 public ExprLong create_exprlong(int val) throws RemoteException , TIRExceptCreate { 935 return new ExprLongImpl(val); 936 } 937 public ExprLongLong create_exprlonglong(long val) throws RemoteException , TIRExceptCreate { 938 return new ExprLongLongImpl(val); 939 } 940 public ExprUnsigShort create_exprunsigshort(short val) throws RemoteException , TIRExceptCreate { 941 return new ExprUnsigShortImpl(val); 942 } 943 public ExprUnsigLong create_exprunsiglong(int val) throws RemoteException , TIRExceptCreate { 944 return new ExprUnsigLongImpl(val); 945 } 946 public ExprUnsigLongLong create_exprunsiglonglong(long val) throws RemoteException , TIRExceptCreate { 947 return new ExprUnsigLongLongImpl(val); 948 } 949 public ExprFloat create_exprfloat(float val) throws RemoteException , TIRExceptCreate { 950 return new ExprFloatImpl(val); 951 } 952 public ExprDouble create_exprdouble(double val) throws RemoteException , TIRExceptCreate { 953 return new ExprDoubleImpl(val); 954 } 955 public ExprLongDouble create_exprlongdouble(double val) throws RemoteException , TIRExceptCreate { 956 throw new TIRExceptCreate("No mapping for type \"long double\"."); 957 } 958 public ExprFixed create_exprfixed(java.math.BigDecimal val, int digits, int scale) throws RemoteException , TIRExceptCreate { 959 return new ExprFixedImpl(val, digits, scale); 960 } 961 public ExprChar create_exprchar(char val) throws RemoteException , TIRExceptCreate { 962 return new ExprCharImpl(val); 963 } 964 public ExprWchar create_exprwchar(char val) throws RemoteException , TIRExceptCreate { 965 return new ExprWcharImpl(val); 966 } 967 public ExprString create_exprstring(String val) throws RemoteException , TIRExceptCreate { 968 return new ExprStringImpl(val); 969 } 970 public ExprWstring create_exprwstring(String val) throws RemoteException , TIRExceptCreate { 971 return new ExprWstringImpl(val); 972 } 973 public ExprConstant create_exprconstant(ConstantDef val) throws RemoteException , TIRExceptCreate { 974 return new ExprConstantImpl(val); 975 } 976 977 public ExprProperty create_exprproperty(String pr) throws RemoteException , TIRExceptCreate { 978 if (pr!=null && pr.length()!=0) 979 return new ExprPropertyImpl(pr); 980 return null; 981 } 982 983 public ExprEnum create_exprenum(EnumDef en, String enMember) throws RemoteException , TIRExceptCreate, TIRExceptLock { 984 if (en==null || enMember==null || enMember.length()==0) 985 return null; 986 EnumMember[] emm = en.members(); 987 boolean found = false; 988 for(int i=0;i<emm.length;i++) { 989 if (emm[i].name().compareTo(enMember)==0) { 990 found = true; 991 break; 992 } 993 } 994 if (!found) 995 throw new TIRExceptCreate("No member with name "+enMember+" in this enum."); 996 return new ExprEnumImpl(en, enMember); 997 } 998 999 public ExprDefault create_exprdefault() throws RemoteException , TIRExceptCreate { 1000 return new ExprDefaultImpl(StateKind.sk_work); 1001 } 1002 1003 public ExprUnOperationDef create_exprunoperation(int kind, ExprOperDef op) throws RemoteException , TIRExceptCreate { 1004 if (op.get_state().value()==StateKind.sk_work ) { 1005 return new ExprUnOperationDefImpl(kind, op); 1006 } else { 1007 throw new TIRExceptCreate("Given object isn't work."); 1008 } 1009 } 1010 public ExprBinOperationDef create_exprbinoperation(int kind, ExprOperDef op1, ExprOperDef op2) throws RemoteException , TIRExceptCreate { 1011 if (op1.get_state().value()==StateKind.sk_work && 1012 op2.get_state().value()==StateKind.sk_work) { 1013 return new ExprBinOperationDefImpl(kind, op1,op2); 1014 } else { 1015 throw new TIRExceptCreate("Given objects aren't work."); 1016 } 1017 } 1018 public ValueGen create_valuegen() throws RemoteException , TIRExceptCreate { 1019 return new ValueGenImpl(StateKind.sk_work); 1020 } 1021 1022 public WorkRepository beginChanges(ProfileDef prof) throws RemoteException { 1023 return null; 1024 } 1025 1026 public void postLoad(RepositoryImpl r) throws RemoteException , TIRExceptStorage {;} 1027 public void save(Storage st) throws RemoteException , TIRExceptStorage {;} 1028 public void load(Storage st) throws RemoteException , TIRExceptStorage {;} 1029 public void save() throws RemoteException , TIRExceptSave {;} 1030 1031 public boolean isNew() { 1032 return true; 1033 } 1034 1035 1036 public long isLockedForCreate() throws RemoteException { 1037 if (normalRep.lockCreate.isLocked()) { 1038 return normalRep.lockFor; 1039 } 1040 return -1L; 1041 } 1042 1043 1044 public long canLock() throws RemoteException { 1045 long a; 1046 if ((a=isLockedForCreate())!=-1L) return a; 1048 LiItem akt = firstChild; 1050 for(int i=0;i<numOfItems;i++) { 1051 switch (akt.obj.get_def_kind().value()) { 1052 case DefinitionKind.dk_Module: 1053 if ((a=((ModuleDefImpl)akt.obj).isLockedForCreate())!=-1L) 1054 return a; 1055 else { 1056 if ((a=((ModuleDefImpl)akt.obj).canLockChild())!=-1L) 1057 return a; 1058 } 1059 break; 1060 case DefinitionKind.dk_Provider: 1061 if ((a=((ProviderDefImpl)akt.obj).isLockedForCreate())!=-1L) 1062 return a; 1063 else { 1064 if ((a=((ProviderDefImpl)akt.obj).canLockChild())!=-1L) 1065 return a; 1066 } 1067 break; 1068 } 1069 } 1070 return -1L; 1071 } 1072 1073 1074 boolean getCreateLock() throws RemoteException { 1075 if (lockForMe) 1076 return true; 1077 if (normalRep.lockCreate.isLocked()) 1078 return false; 1079 normalRep.lockGetCreate.lock(); 1080 long a = canLock(); 1081 if ((a==-1L) || (a==workId)) { 1082 lockForMe = true; 1083 normalRep.lockCreate.lock(); 1084 normalRep.lockFor = workId; 1085 } 1086 normalRep.lockGetCreate.unlock(); 1087 return true; 1088 } 1089 1090 public String workIdent() throws RemoteException { 1091 return workIdString; 1092 } 1093 1094 public ProfileDef profile() throws RemoteException { 1095 return actProfile; 1096 } 1097 1098 public ManageProfiles getProfiles() throws RemoteException { 1099 return mProfiles; 1100 } 1101} 1102 | Popular Tags |