KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Made > CDL > CompProvider


1 /* $Id: CompProvider.java,v 1.2 2004/05/20 14:23:51 bures Exp $ */
2 package SOFA.SOFAnode.Made.CDL;
3 import java.rmi.RemoteException JavaDoc;
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.ProviderDef;
12 import SOFA.SOFAnode.Made.TIR.TIRExceptCreate;
13 import SOFA.SOFAnode.Made.TIR.TIRExceptLock;
14
15 class CompProvider extends CompContainedContainerIm {
16    public CompProvider(ID id, CompContainer in, CompRepository inRep) {
17     super(ObjectsKind.o_Provider, 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 JavaDoc 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         // *****************
34
case ObjectsKind.o_AModule:
35           Contained[] cmod = obj.lookup_name(akt.getIdent().name);
36           if ((cmod == null) || (cmod.length == 0)) { //create new module
37
AModuleDef mod = null;
38             try {
39               mod = ((ProviderDef) 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 { // use old module
47
if (cmod.length!=1)
48               throw new CDLExceptToNormal("Unexpected error");
49             ((CompContainer) akt).addToNormal((Container) cmod[0], normRep, delayed);
50           }
51           break;
52         // *****************
53
case ObjectsKind.o_Architecture:
54           try {
55             ArchitectureDef arch = ((ProviderDef) 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 JavaDoc e) {
69       throw new CDLExceptRemote("Remote exception occured: "+e.getMessage());
70     } catch (TIRExceptLock e) {
71       throw new CDLExceptLock("Repository is locked: "+e.getMessage());
72     }
73   }
74 }
75
Popular Tags