1 26 27 package org.objectweb.corba.generator.cif.lib; 28 29 import org.objectweb.openccm.generator.java.ast.api.*; 31 import org.objectweb.openccm.generator.java.ast.lib.*; 32 import org.objectweb.openccm.ast.api.SegmentDecl; 33 34 35 42 43 public class SegmentImplMapping 44 implements org.objectweb.corba.generator.cif.api.SegmentImplMapping 45 { 46 52 53 static public org.objectweb.openccm.generator.translator.idl2java.api.IDL_JavaTranslator translator_; 54 55 56 private org.objectweb.openccm.ast.utils.api.CompositionInfo comp_; 57 58 64 69 public SegmentImplMapping(org.objectweb.openccm.ast.api.CompositionDecl composition) 70 { 71 comp_ = new org.objectweb.openccm.ast.utils.lib.CompositionInfo(composition); 72 } 73 74 80 83 static 84 { 85 translator_ = new org.objectweb.openccm.generator.translator.idl2java.lib.IDL_JavaTranslator(); 86 } 87 88 94 private void 95 businessOperations(ClassObject clazz, 96 SegmentDecl seg) 97 { 98 String [] facets = null, 99 sinks = null; 100 101 facets = seg.getFacetList().getStrings(); 103 for (int i=0; i<facets.length; i++) 104 { 105 org.objectweb.openccm.ast.api.InterfacePortDecl itf_port = null; 106 org.objectweb.openccm.ast.api.ComponentDecl current = null; 107 108 current = comp_.getComponent(); 109 while ((current != null) && (itf_port == null)) 110 { 111 itf_port = (org.objectweb.openccm.ast.api.InterfacePortDecl)current.lookup(facets[i]); 112 current = current.getBaseComponent(); 113 } 114 translator_.mapInterfaceOps( clazz, 115 itf_port.getLocalMapping() ); 116 } 117 118 sinks = seg.getSinkList().getStrings(); 120 for (int i=0; i<sinks.length; i++) 121 { 122 org.objectweb.openccm.ast.api.EventPortDecl event_port = null; 123 org.objectweb.openccm.ast.api.ComponentDecl current = null; 124 125 current = comp_.getComponent(); 126 while ((current != null) && (event_port == null)) 127 { 128 event_port = (org.objectweb.openccm.ast.api.EventPortDecl)current.lookup(sinks[i]); 129 current = current.getBaseComponent(); 130 } 131 translator_.mapInterfaceOps( clazz, 132 event_port.getEvent().getLocalConsumerMapping() ); 133 } 134 } 135 136 142 147 public void 148 toJavaSegmentTemplates(Repository repository) 149 { 150 ClassObject clazz = null; 151 ConstructorObject ct = null; 152 SegmentDecl[] segments = null; 153 154 segments = comp_.getSegments(); 155 for (int i=0; i<segments.length; i++) 156 { 157 clazz = new ClassObjectImpl(segments[i].getName()+"Impl"); 158 clazz.addComment(" This is the CIDL-based implementation of the"); 159 clazz.addComment(" OMG IDL3 " 160 + segments[i].getId() 161 + " segment type."); 162 clazz.addComment(""); 163 clazz.addComment(" @author OpenCCM CIF_Jimpl Compiler."); 164 clazz.setModifier(ModifierKindImpl.mk_public); 165 clazz.setPackage( translator_.getPackage(comp_.getHomeExecutor()) ); 166 clazz.addInheritedObject( translator_.getPackage(comp_.getHomeExecutor()) + 167 "." + segments[i].getName() ); 168 169 ct = new ConstructorObjectImpl(); 171 clazz.addConstructor(ct); 172 173 businessOperations(clazz, segments[i]); 175 176 repository.addObject(clazz); 178 } 179 } 180 181 187 } 188 | Popular Tags |