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.ProvidesDef; 46 import org.omg.CORBA.ComponentIR.ProvidesDefHelper; 47 48 58 59 public class ProvidesDeclImpl 60 extends InterfacePortDeclImpl 61 implements org.objectweb.openccm.ast.api.ProvidesDecl 62 { 63 69 70 private ProvidesDef provides_def_; 71 72 78 84 protected 85 ProvidesDeclImpl(Repository rep, 86 ScopeImpl parent) 87 { 88 super(rep, parent); 90 91 provides_def_ = null; 93 } 94 95 101 107 112 protected void 113 load(org.omg.CORBA.Contained contained) 114 { 115 provides_def_ = ProvidesDefHelper.narrow(contained); 116 setInterface((InterfaceDecl)getRepository(). 117 lookupId(provides_def_.interface_type().id())); 118 super.load(contained); 119 } 120 121 126 protected org.omg.CORBA.Contained 127 getContained() 128 { 129 return provides_def_; 130 } 131 132 138 144 152 public Declaration[] 153 getDependencies() 154 { 155 if (dependencies_!=null) 156 return dependencies_; 157 158 java.util.List provides_depend = new java.util.ArrayList (); 159 160 if (getInterface().isDeclaration()) 164 provides_depend.add(getInterface()); 165 166 Declaration[] depend = getInterface().getDependencies(); 167 for (int i=0;i<depend.length;i++) 168 provides_depend.add(depend[i]); 169 170 dependencies_ = (Declaration[])provides_depend.toArray( 171 new Declaration[0]); 172 return dependencies_; 173 } 174 175 181 186 public long 187 getDeclKind() 188 { 189 return DeclarationKind.dk_provides; 190 } 191 192 195 public void 196 create() 197 { 198 provides_def_ = the_parent_.getComponentDef(). 199 create_provides(getId(), getName(), getVersion(), 200 interface_.getExtInterfaceDef()); 201 super.create(); 202 } 203 204 210 215 public OperationDecl[] 216 getClientMapping() 217 { 218 if (client_mapping_!=null) 219 return client_mapping_; 220 221 InterfaceDecl client = ((ComponentDecl)the_parent_).getClientMapping(); 223 client.getContents(true, DeclarationKind.dk_null); 224 225 client_mapping_ = new OperationDecl[1]; 226 client_mapping_[0] = (OperationDecl)client.find("provide_"+getName()); 227 return client_mapping_; 228 } 229 230 236 } 242 | Popular Tags |