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 36 import org.objectweb.openccm.ast.api.InterfaceDecl; 37 38 39 import org.objectweb.openccm.ast.api.OperationDecl; 40 41 42 import org.objectweb.openccm.ast.api.ComponentDecl; 43 44 45 import org.omg.CORBA.ComponentIR.UsesDef; 46 import org.omg.CORBA.ComponentIR.UsesDefHelper; 47 48 61 62 public class UsesDeclImpl 63 extends InterfacePortDeclImpl 64 implements org.objectweb.openccm.ast.api.UsesDecl 65 { 66 72 73 private UsesDef uses_def_; 74 75 76 private boolean is_multiple_; 77 78 79 private OperationDecl[] local_context_mapping_; 80 81 87 93 protected 94 UsesDeclImpl(Repository rep, 95 ScopeImpl parent) 96 { 97 super(rep, parent); 99 100 uses_def_ = null; 102 is_multiple_ = false; 103 local_context_mapping_ = null; 104 } 105 106 112 118 123 protected void 124 load(org.omg.CORBA.Contained contained) 125 { 126 uses_def_ = UsesDefHelper.narrow(contained); 127 setInterface((InterfaceDecl)getRepository(). 128 lookupId(uses_def_.interface_type().id())); 129 is_multiple_ = uses_def_.is_multiple(); 130 super.load(contained); 131 } 132 133 138 protected org.omg.CORBA.Contained 139 getContained() 140 { 141 return uses_def_; 142 } 143 144 150 156 164 public Declaration[] 165 getDependencies() 166 { 167 if (dependencies_!=null) 168 return dependencies_; 169 170 java.util.List uses_depend = new java.util.ArrayList (); 171 172 if (getInterface().isDeclaration()) 176 uses_depend.add(getInterface()); 177 178 Declaration[] depend = getInterface().getDependencies(); 179 for (int i=0; i<depend.length; i++) 180 uses_depend.add(depend[i]); 181 182 dependencies_ = (Declaration[])uses_depend.toArray(new Declaration[0]); 183 return dependencies_; 184 } 185 186 192 197 public long 198 getDeclKind() 199 { 200 return DeclarationKind.dk_uses; 201 } 202 203 206 public void 207 create() 208 { 209 uses_def_ = the_parent_.getComponentDef(). 210 create_uses(getId(), getName(), getVersion(), 211 interface_.getInterfaceDef(), 212 is_multiple_); 213 super.create(); 214 } 215 216 222 227 public OperationDecl[] 228 getClientMapping() 229 { 230 if (client_mapping_!=null) 231 return client_mapping_; 232 233 InterfaceDecl client = ((ComponentDecl)the_parent_).getClientMapping(); 235 client.getContents(true, DeclarationKind.dk_null); 236 237 client_mapping_ = new OperationDecl[3]; 238 client_mapping_[0] = (OperationDecl)client.find("connect_"+getName()); 239 client_mapping_[1] = (OperationDecl)client.find("disconnect_"+getName()); 240 241 if (is_multiple_) 242 client_mapping_[2] = (OperationDecl) 243 client.find("get_connections_"+getName()); 244 else 245 client_mapping_[2] = (OperationDecl) 246 client.find("get_connection_"+getName()); 247 248 return client_mapping_; 249 } 250 251 257 263 268 public OperationDecl[] 269 getLocalContextMapping() 270 { 271 if (local_context_mapping_!=null) 272 return local_context_mapping_; 273 274 InterfaceDecl context = ((ComponentDecl)the_parent_). 276 getLocalContextMapping(); 277 context.getContents(true, DeclarationKind.dk_null); 278 279 local_context_mapping_ = new OperationDecl[1]; 280 if (is_multiple_) 281 local_context_mapping_[0] = (OperationDecl) 282 context.find("get_connections_"+getName()); 283 else 284 local_context_mapping_[0] = (OperationDecl) 285 context.find("get_connection_"+getName()); 286 287 return local_context_mapping_; 288 } 289 295 298 public void 299 setMultiple() 300 { 301 is_multiple_ = true; 302 } 303 304 309 public boolean 310 isMultiple() 311 { 312 return is_multiple_; 313 } 314 } 315 | Popular Tags |