1 26 27 package org.objectweb.ccm.IDL3; 28 29 37 38 public class ProvidesDeclImpl 39 extends DeclarationImpl 40 implements ProvidesDecl 41 { 42 48 51 private org.omg.CORBA.ComponentIR.ProvidesDef provides_def_; 52 53 56 private InterfaceDeclImpl interface_; 57 58 61 private OperationDeclImpl[] client_mapping_; 62 63 66 private InterfaceDeclImpl local_mapping_; 67 68 74 79 protected 80 ProvidesDeclImpl(Repository rep, ScopeImpl parent) 81 { 82 super(rep, parent); 84 85 provides_def_ = null; 87 client_mapping_ = null; 88 local_mapping_ = null; 89 interface_ = null; 90 the_declaration_kind_ = DeclarationKind._dk_provides; 91 } 92 93 99 104 protected void 105 load(org.omg.CORBA.Contained contained) 106 { 107 provides_def_ = org.omg.CORBA.ComponentIR.ProvidesDefHelper.narrow(contained); 108 setInterface((InterfaceRef)getRepository().lookupId(provides_def_.interface_type().id())); 109 super.load(contained); 110 } 111 112 118 121 public void 122 create() 123 { 124 provides_def_ = the_parent_.getComponentDef().create_provides(getId(), getName(), 125 getVersion(), 126 interface_.getExtInterfaceDef()); 127 128 super.create(); 129 } 130 131 138 public Declaration[] 139 getDependencies() 140 { 141 if (dependencies_!=null) 142 return dependencies_; 143 144 org.objectweb.ccm.util.Vector provides_depend = new org.objectweb.ccm.util.Vector(); 145 146 if (getType().isDeclaration()) 148 provides_depend.add(getType()); 149 150 Declaration[] depend = getType().getDependencies(); 151 for (int i=0;i<depend.length;i++) 152 provides_depend.add(depend[i]); 153 154 155 dependencies_ = (Declaration[])provides_depend.toArray(new Declaration[0]); 156 return dependencies_; 157 } 158 159 165 170 public void 171 setInterface(InterfaceRef itf) 172 { 173 if(itf != null) 174 { 175 interface_ = (InterfaceDeclImpl)itf; 176 interface_.addRef(); 177 } 178 } 179 180 183 public TypeRef 184 getType() 185 { 186 return interface_; 187 } 188 189 192 public OperationDecl[] 193 getClientMapping() 194 { 195 if (client_mapping_!=null) 196 return client_mapping_; 197 198 InterfaceDecl client = ((ComponentDecl)the_parent_).getClientMapping(); 200 client.getContents(true, DeclarationKind._dk_null); 201 202 client_mapping_ = new OperationDeclImpl[1]; 203 client_mapping_[0] = (OperationDeclImpl)client.find("provide_"+getName()); 204 205 return client_mapping_; 206 } 207 208 213 public InterfaceDecl 214 getLocalMapping() 215 { 216 if (local_mapping_==null) 217 { 218 InterfaceDecl itf = (InterfaceDecl)getType(); 220 String parent_base_id = itf.getParent().getId(); 221 int idx = parent_base_id.lastIndexOf(':'); 222 parent_base_id = parent_base_id.substring(0, idx); 223 String id = parent_base_id + "/CCM_" + itf.getName() + ":" + getVersion(); 224 local_mapping_ = (InterfaceDeclImpl)getRepository().loadMapping(itf.getParent(), id); 225 } 226 return local_mapping_; 227 } 228 229 235 238 public void 239 destroy() 240 { 241 if (interface_!=null) 242 interface_.removeRef(); 243 244 super.destroy(); 245 } 246 247 252 protected org.omg.CORBA.Contained 253 getContained() 254 { 255 return provides_def_; 256 } 257 } 258 | Popular Tags |