1 2 package SOFA.SOFAnode.Made.CDL; 3 import java.rmi.RemoteException ; 4 5 import SOFA.SOFAnode.Made.TIR.AModuleDef; 6 import SOFA.SOFAnode.Made.TIR.ArchitectureDef; 7 import SOFA.SOFAnode.Made.TIR.CDLRepository; 8 import SOFA.SOFAnode.Made.TIR.Contained; 9 import SOFA.SOFAnode.Made.TIR.Container; 10 import SOFA.SOFAnode.Made.TIR.FrameDef; 11 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate; 12 import SOFA.SOFAnode.Made.TIR.TIRExceptLock; 13 14 class CompAModule extends CompContainedContainerIm { 15 16 public CompAModule(ID id, CompContainer in, CompRepository inRep) { 17 super(ObjectsKind.o_AModule, id, in, inRep); 18 } 19 20 public void checkConsist(EnumList props, CompRepository rep) throws CDLExceptCheck, CDLExceptLock, CDLExceptRemote { 21 CompContained[] cont = contents(); 22 for (int i=0;i<cont.length;i++) { 23 cont[i].checkConsist(props, rep); 24 } 25 } 26 27 public void addToNormal(Container obj, CDLRepository normRep, java.util.ArrayList delayed) throws CDLExceptToNormal, CDLExceptRemote, CDLExceptLock { 28 cont.toFirst(); 29 try { 30 for (int i=0;i<cont.size(); i++) { 31 CompContained akt = (CompContained) cont.aktual(); 32 switch (akt.objectKind()) { 33 case ObjectsKind.o_AModule: 35 Contained[] cmod = obj.lookup_name(akt.getIdent().name); 36 if ((cmod == null) || (cmod.length == 0)) { AModuleDef mod = null; 38 try { 39 mod = ((AModuleDef) obj).create_amodule(akt.getIdent().id); 40 } catch (TIRExceptCreate ecr) { 41 throw new CDLExceptToNormal("Can't create amodule "+((CompContained)akt).fullName()); 42 } 43 if (mod==null) 44 throw new CDLExceptToNormal("Can't create amodule "+((CompContained)akt).fullName()); 45 ((CompContainer) akt).addToNormal(mod, normRep, delayed); 46 } else { if (cmod.length!=1) 48 throw new CDLExceptToNormal("Unexpected error"); 49 ((CompContainer) akt).addToNormal((Container) cmod[0], normRep, delayed); 50 } 51 break; 52 case ObjectsKind.o_Architecture: 54 try { 55 ArchitectureDef arch = ((AModuleDef) obj).create_architecture(akt.getIdent().id, (FrameDef) ((CompArchitecture) akt).frame.toNormal(normRep), ((CompArchitecture) akt).isSystem); 56 if (arch == null) 57 throw new CDLExceptToNormal("Can't create architecture "+((CompContained)akt).fullName()); 58 ((CompArchitecture) akt).addToNormal(arch, normRep, delayed); 59 } catch (TIRExceptCreate ecr) { 60 throw new CDLExceptToNormal("Can't create architecture "+((CompContained)akt).fullName()); 61 } 62 break; 63 default: 64 throw new CDLExceptToNormal("Unexcepted kind of object"); 65 } 66 cont.toNext(); 67 } 68 } catch (RemoteException e) { 69 throw new CDLExceptRemote("Remote exception occured: "+e.getMessage()); 70 } catch (TIRExceptLock e) { 71 throw new CDLExceptLock("Repository is locked."); 72 } 73 } 74 } 75 | Popular Tags |