1 26 27 package org.objectweb.openccm.ast.lib; 28 29 30 import org.objectweb.openccm.ast.api.DeclarationKind; 31 32 33 import org.objectweb.openccm.ast.api.Declaration; 34 35 46 47 public class ModuleDeclImpl 48 extends ForwardScopeIDLImpl 49 implements org.objectweb.openccm.ast.api.ModuleDecl, 50 org.objectweb.openccm.ast.api.PsdlModuleDecl, 51 org.objectweb.openccm.ast.api.CidlModuleDecl 52 { 53 59 60 private org.omg.CORBA.ComponentIR.ModuleDef component_module_def_; 61 62 65 private boolean completed_; 66 67 73 79 protected 80 ModuleDeclImpl(Repository rep, 81 ScopeImpl parent) 82 { 83 super(rep, parent); 85 86 component_module_def_ = null; 88 completed_ = false; 89 90 } 92 93 99 105 110 protected void 111 load(org.omg.CORBA.Contained contained) 112 { 113 component_module_def_ = org.omg.CORBA.ComponentIR.ModuleDefHelper. 114 narrow(contained); 115 super.load(contained); 116 } 117 118 123 protected void 124 loadAsMapping(org.omg.CORBA.Contained contained) 125 { 126 component_module_def_ = org.omg.CORBA.ComponentIR.ModuleDefHelper. 127 narrow(contained); 128 super.loadAsMapping(contained); 129 } 130 131 136 protected org.omg.CORBA.Contained 137 getContained() 138 { 139 return component_module_def_; 140 } 141 142 148 153 protected org.omg.CORBA.Container 154 getContainer() 155 { 156 return component_module_def_; 157 } 158 159 164 protected org.omg.CORBA.ComponentIR.Container 165 getComponentContainer() 166 { 167 return component_module_def_; 168 } 169 170 176 182 185 protected void 186 createContainer() 187 { 188 if (component_module_def_ == null) 190 { 191 component_module_def_ = 193 the_parent_.getComponentContainer(). 194 create_component_module(getId(), getName(), getVersion()); 195 } 196 } 197 198 201 protected void 202 completeContainer() 203 { 204 completed_ = true; 205 } 206 207 213 219 227 public Declaration[] 228 getDependencies() 229 { 230 if (dependencies_!=null) 231 return dependencies_; 232 233 Declaration[] decls = getContents(true, 234 org.objectweb.openccm.ast.api.DeclarationKind.dk_all); 235 Declaration[] depend = null; 236 java.util.List module_depend = new java.util.ArrayList (); 237 238 for (int i=0; i<decls.length; i++) 240 { 241 depend = decls[i].getDependencies(); 242 for (int j=0; j<depend.length; j++) 243 { 244 if ((!containsDecl(depend[j])) && 245 (module_depend.indexOf(depend[j])==-1)) 246 module_depend.add(depend[j]); 247 } 248 } 249 250 dependencies_ = (Declaration[])module_depend.toArray( 251 new Declaration[0]); 252 return dependencies_; 253 } 254 255 261 266 public long 267 getDeclKind() 268 { 269 return DeclarationKind.dk_module; 270 } 271 272 275 public void 276 create() 277 { 278 if (getContainer() == null) 279 { 280 createContainer(); 281 if (the_parent_!=null) 282 the_parent_.addDecl(this); 283 } 284 else if (!completed_) 285 completeContainer(); 286 } 287 288 295 public void 296 destroy() 297 { 298 for (int i=contained_decls_.size()-1; i>=0; i--) 300 { 301 Declaration decl = (Declaration)contained_decls_.get(i); 302 decl.destroy(); 303 } 304 305 org.omg.CORBA.Contained [] contents = 307 getContainer().contents(org.omg.CORBA.DefinitionKind.dk_all, true); 308 309 if (contents.length==0) 311 { 312 super.destroy(); 313 } 314 } 315 316 322 328 334 340 } 346 | Popular Tags |