1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class UsesDeclImpl 39 extends DeclarationImpl 40 implements UsesDecl 41 { 42 48 51 private org.omg.CORBA.ComponentIR.UsesDef uses_def_; 52 53 56 private InterfaceDeclImpl interface_; 57 58 61 private boolean is_multiple_; 62 63 66 private OperationDeclImpl[] client_mapping_; 67 68 71 private OperationDeclImpl[] local_context_mapping_; 72 73 79 84 protected 85 UsesDeclImpl(Repository rep, ScopeImpl parent) 86 { 87 super(rep, parent); 89 90 uses_def_ = null; 92 client_mapping_ = null; 93 local_context_mapping_ = null; 94 interface_ = null; 95 is_multiple_ = false; 96 the_declaration_kind_ = DeclarationKind._dk_uses; 97 } 98 99 105 110 protected void 111 load(org.omg.CORBA.Contained contained) 112 { 113 uses_def_ = org.omg.CORBA.ComponentIR.UsesDefHelper.narrow(contained); 114 setInterface((InterfaceRef)getRepository().lookupId(uses_def_.interface_type().id())); 115 is_multiple_ = uses_def_.is_multiple(); 116 super.load(contained); 117 } 118 119 125 128 public void 129 create() 130 { 131 uses_def_ = the_parent_.getComponentDef().create_uses(getId(), getName(), 132 getVersion(), 133 interface_.getInterfaceDef(), 134 is_multiple_); 135 136 super.create(); 137 } 138 139 146 public Declaration[] 147 getDependencies() 148 { 149 if (dependencies_!=null) 150 return dependencies_; 151 152 org.objectweb.ccm.util.Vector uses_depend = new org.objectweb.ccm.util.Vector(); 153 154 if (getType().isDeclaration()) 156 uses_depend.add(getType()); 157 158 Declaration[] depend = getType().getDependencies(); 159 for (int i=0;i<depend.length;i++) 160 uses_depend.add(depend[i]); 161 162 163 dependencies_ = (Declaration[])uses_depend.toArray(new Declaration[0]); 164 return dependencies_; 165 } 166 167 173 176 public void 177 setMultiple() 178 { 179 is_multiple_ = true; 180 } 181 182 187 public void 188 setInterface(InterfaceRef itf) 189 { 190 if(itf != null) 191 { 192 interface_ = (InterfaceDeclImpl)itf; 193 interface_.addRef(); 194 } 195 } 196 197 200 public TypeRef 201 getType() 202 { 203 return interface_; 204 } 205 206 209 public boolean 210 isMultiple() 211 { 212 return is_multiple_; 213 } 214 215 218 public OperationDecl[] 219 getClientMapping() 220 { 221 if (client_mapping_!=null) 222 return client_mapping_; 223 224 InterfaceDecl client = ((ComponentDecl)the_parent_).getClientMapping(); 226 client.getContents(true, DeclarationKind._dk_null); 227 228 client_mapping_ = new OperationDeclImpl[3]; 229 client_mapping_[0] = (OperationDeclImpl)client.find("connect_"+getName()); 230 client_mapping_[1] = (OperationDeclImpl)client.find("disconnect_"+getName()); 231 232 if (is_multiple_) 233 client_mapping_[2] = (OperationDeclImpl)client.find("get_connections_"+getName()); 234 else 235 client_mapping_[2] = (OperationDeclImpl)client.find("get_connection_"+getName()); 236 237 return client_mapping_; 238 } 239 240 243 public OperationDecl[] 244 getLocalContextMapping() 245 { 246 if (local_context_mapping_!=null) 247 return local_context_mapping_; 248 249 InterfaceDecl context = ((ComponentDecl)the_parent_).getLocalContextMapping(); 251 context.getContents(true, DeclarationKind._dk_null); 252 253 local_context_mapping_ = new OperationDeclImpl[1]; 254 if (is_multiple_) 255 local_context_mapping_[0] = (OperationDeclImpl)context.find("get_connections_"+getName()); 256 else 257 local_context_mapping_[0] = (OperationDeclImpl)context.find("get_connection_"+getName()); 258 259 return local_context_mapping_; 260 } 261 262 268 271 public void 272 destroy() 273 { 274 if (interface_!=null) 275 interface_.removeRef(); 276 277 super.destroy(); 278 } 279 280 285 protected org.omg.CORBA.Contained 286 getContained() 287 { 288 return uses_def_; 289 } 290 } 291 | Popular Tags |