1 20 package org.objectweb.modfact.corba.service; 21 22 import java.io.InputStream ; 23 import java.io.OutputStream ; 24 25 import org.omg.CosNaming.*; 26 27 import org.objectweb.modfact.corba.logging.Level; 29 import org.objectweb.modfact.corba.logging.ModFactLogger; 30 31 import org.objectweb.modfact.corba.io.Import; 33 import org.objectweb.modfact.corba.idl.MOFIDL1_3Generator; 34 import org.objectweb.modfact.corba.idl2java.IDL2JavaMOF1_3Generator; 35 import org.objectweb.modfact.corba.xmi.XMI1_1DTDGenerator; 36 import org.objectweb.modfact.corba.xmiio.exporter.XMIExportGenerator; 37 import org.objectweb.modfact.corba.xmiio.importer.XMIImportGenerator; 38 import org.objectweb.modfact.corba.server.ServerGenerator; 39 40 import org.objectweb.modfact.corba.helper.IDLCommon; 42 import org.objectweb.modfact.corba.helper.JavaCommon; 43 import org.objectweb.modfact.corba.helper.MOFCommon; 44 import org.objectweb.modfact.corba.helper.XMICommon; 45 import org.objectweb.modfact.corba.helper.XMIImportCommon; 46 47 import org.objectweb.modfact.corba.provider.IDLProvider; 49 import org.objectweb.modfact.corba.provider.JavaProvider; 50 import org.objectweb.modfact.corba.provider.MOFCachedProvider; 51 import org.objectweb.modfact.corba.provider.XMIImportProvider; 52 import org.objectweb.modfact.corba.provider.XMIProvider; 53 54 55 public class Generation {; 56 57 70 public void execute(boolean idl, boolean dtd, boolean java, boolean xmiImport, boolean xmiExport, boolean server, boolean mappingValid, InputStream input, OutputStream output, org.omg.CORBA.ORB orb) { 71 try { 72 org.omg.CORBA.Object objRef = 74 orb.resolve_initial_references("NameService"); 75 76 NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); 79 80 String name = "ModFactServer"; 82 org.omg.mof.Model.ModelPackageFactory _reference = 83 org.omg.mof.Model.ModelPackageFactoryHelper.narrow( 84 ncRef.resolve_str(name)); 85 86 org.omg.mof.Model._ModelPackage modelPackage = 88 _reference.create_model_package(); 89 90 ModFactLogger loggerImport = ModFactLogger.getLogger("org.objectweb.modfact.corba.io.Import"); 94 Import imp = new Import(); 95 imp.setIdlHelper(new IDLProvider()); 96 imp.setLogger(loggerImport); 97 imp.initiate(modelPackage, orb); 98 99 org.omg.mof.Model.Package[] outermostPackages = 101 imp.parse(input); 102 103 if (idl) { 105 ModFactLogger logger = 106 ModFactLogger.getLogger( 107 "org.objectweb.modfact.corba.idl.MOFIDL1_3Generator"); 108 MOFIDL1_3Generator idlGenerator = new MOFIDL1_3Generator(); 109 idlGenerator.setLogger(logger); 110 idlGenerator.setInput(outermostPackages); 111 idlGenerator.setOutput(output); 112 MOFCommon mofHelper = new MOFCachedProvider(outermostPackages); 113 idlGenerator.setMofHelper(mofHelper); 114 IDLCommon idlHelper = new IDLProvider(mofHelper); 115 idlGenerator.setIdlHelper(idlHelper); 116 idlGenerator.generate(); 117 119 } 121 122 if (dtd) { 124 ModFactLogger logger = 125 ModFactLogger.getLogger( 126 "org.objectweb.modfact.corba.xmi.XMI1_1DTDGenerator"); 127 XMI1_1DTDGenerator dtdGenerator = new XMI1_1DTDGenerator(); 128 dtdGenerator.setLogger(logger); 129 dtdGenerator.setInput(outermostPackages); 130 dtdGenerator.setOutput(output); 131 MOFCommon mofHelper = new MOFCachedProvider(outermostPackages); 132 dtdGenerator.setMofHelper(mofHelper); 133 XMICommon xmiHelper = new XMIProvider(mofHelper); 134 dtdGenerator.setXmiHelper(xmiHelper); 135 dtdGenerator.generate(); 136 } 138 139 if (java) { 141 ModFactLogger logger = 142 ModFactLogger.getLogger( 143 "org.objectweb.modfact.corba.idl2java.IDL2JavaMOF1_3Generator"); 144 IDL2JavaMOF1_3Generator javaGenerator = 145 new IDL2JavaMOF1_3Generator(); 146 javaGenerator.setLogger(logger); 147 javaGenerator.setInput(outermostPackages); 148 javaGenerator.setOutput(output); 149 MOFCommon mofHelper = new MOFCachedProvider(outermostPackages); 150 javaGenerator.setMofHelper(mofHelper); 151 JavaCommon javaHelper = new JavaProvider(mofHelper); 152 javaGenerator.setJavaHelper(javaHelper); 153 javaGenerator.generate(); 154 } 156 157 if (xmiImport) { 159 ModFactLogger logger = 160 ModFactLogger.getLogger( 161 "org.objectweb.modfact.corba.xmiio.importer.XMIImportGenerator"); 162 XMIImportGenerator xmiImpGenerator = new XMIImportGenerator(); 163 xmiImpGenerator.setLogger(logger); 164 xmiImpGenerator.setInput(outermostPackages); 165 xmiImpGenerator.setOutput(output); 166 MOFCommon mofHelper = new MOFCachedProvider(outermostPackages); 167 xmiImpGenerator.setMofHelper(mofHelper); 168 JavaCommon javaHelper = new JavaProvider(mofHelper); 169 xmiImpGenerator.setJavaHelper(javaHelper); 170 IDLCommon idlHelper = new IDLProvider(mofHelper); 171 xmiImpGenerator.setIdlHelper(idlHelper); 172 XMIImportCommon xmiImpHelper = new XMIImportProvider(idlHelper, mofHelper, javaHelper); 173 xmiImpGenerator.setXmiImportHelper(xmiImpHelper); 174 xmiImpGenerator.setMappingValid(mappingValid); 175 xmiImpGenerator.generate(); 176 } 178 179 if (xmiExport) { 181 ModFactLogger logger = 182 ModFactLogger.getLogger( 183 "org.objectweb.modfact.corba.xmiio.exporter.XMIExportGenerator"); 184 XMIExportGenerator xmiExpGenerator = new XMIExportGenerator(); 185 xmiExpGenerator.setLogger(logger); 186 xmiExpGenerator.setInput(outermostPackages); 187 xmiExpGenerator.setOutput(output); 188 MOFCommon mofHelper = new MOFCachedProvider(outermostPackages); 189 xmiExpGenerator.setMofHelper(mofHelper); 190 JavaCommon javaHelper = new JavaProvider(mofHelper); 191 xmiExpGenerator.setJavaHelper(javaHelper); 192 IDLCommon idlHelper = new IDLProvider(mofHelper); 193 xmiExpGenerator.setIdlHelper(idlHelper); 194 xmiExpGenerator.setMappingValid(mappingValid); 195 xmiExpGenerator.generate(); 196 } 198 199 if (server) { 201 ModFactLogger logger = 202 ModFactLogger.getLogger( 203 "org.objectweb.modfact.corba.server.ServerGenerator"); 204 ServerGenerator serverGenerator = new ServerGenerator(); 205 serverGenerator.setLogger(logger); 206 serverGenerator.setInput(outermostPackages); 207 serverGenerator.setOutput(output); 208 MOFCommon mofHelper = new MOFCachedProvider(outermostPackages); 209 IDLCommon idlHelper = new IDLProvider(mofHelper); 210 serverGenerator.setIdlHelper(idlHelper); 211 JavaCommon javaHelper = new JavaProvider(mofHelper); 212 serverGenerator.setJavaHelper(javaHelper); 213 serverGenerator.setMappingValid(mappingValid); 214 serverGenerator.generate(); 215 } 217 218 } catch (Exception e) { 219 ModFactLogger logger = ModFactLogger.getLogger("org.objectweb.modfact.corba.service.Generation"); 220 logger.log(Level.ERROR, e.toString()); 221 } 222 } 223 224 } 225 | Popular Tags |