1 20 package org.objectweb.modfact.corba.server; 21 22 import org.objectweb.modfact.corba.generator.BracketGenerator; 23 import org.objectweb.modfact.corba.helper.JavaCommon; 24 import org.objectweb.modfact.corba.logging.Level; 25 import org.objectweb.modfact.corba.logging.ModFactLogger; 26 import org.omg.mof.Model.ModelElement; 27 28 29 32 public class GenerationServerApplication extends BracketGenerator { 33 34 35 private JavaCommon javaHelper; 36 37 38 protected ModFactLogger _logger = ModFactLogger.getLogger("fr.lip6.src.mdafactory.generation.server.GenerationServerApplication"); 39 40 46 public void generateServerApplication(org.omg.mof.Model.Package package_, String class_name_, String class_name_application_) throws org.omg.mof.Reflective.MofError, org.omg.CORBA.TypeCodePackage.BadKind , org.omg.CORBA.TypeCodePackage.Bounds { 47 _logger.log(Level.FINE, "Server - beginning of the generation"); 48 _logger.log(Level.INFO, class_name_application_ + " generation ..."); 49 head(package_, class_name_application_); 50 constructors(package_.name(), class_name_application_); 51 startMethod(package_.name(), class_name_); 52 mainMethod(class_name_application_); 53 outputln("} // end class " + class_name_); 54 flushFile(); 55 } 56 57 62 public void head(org.omg.mof.Model.Package package_, String class_name_application_) 63 throws org.omg.mof.Reflective.MofError { 64 outputln("package " + javaHelper.javaPackage(package_) + ";"); 65 outputln(); 66 outputln("public class " + class_name_application_); 67 outputln(" extends org.objectweb.modfact.corba.service.cmdline.common.ModfactApplicationBase {"); 68 outputln(); 69 } 70 71 76 public void constructors(String package_name_, String class_name_application_) { 77 outputln("public " + class_name_application_ + "() {"); 78 outputln("super(new org.objectweb.util.cmdline.lib.DefaultCommandLine(new java.lang.String [] {\"" + class_name_application_ + "\"},"); 79 outputln(" new java.lang.String [0],"); 80 outputln(" new java.lang.String [] {\"Run the " + package_name_ + " Server.\"},"); 81 outputln(" true));"); 82 outputln("}"); 83 outputln(); 84 } 85 86 90 public void mainMethod(String class_name_application_) throws org.omg.mof.Reflective.MofError { 91 outputln("/**"); 92 outputln(" * The main method"); 93 outputln(" */"); 94 outputln("public static void main (java.lang.String [] args) {"); 95 outputln(class_name_application_ + " application = new " + class_name_application_ + "();"); 96 outputln("application.runMain(args);"); 97 outputln("}"); 98 outputln(); 99 } 100 101 106 public void startMethod(String package_name_, String class_name_) { 107 outputln("/**"); 108 outputln(" * Starts the main function"); 109 outputln(" */"); 110 outputln("public int start(java.lang.String[] args) {"); 111 outputln(class_name_ + " server = new " + class_name_ + "(orb_);"); 112 outputln("server.run();"); 113 outputln("return 0;"); 114 outputln("}"); 115 outputln(); 116 } 117 118 121 public void generate() throws Exception { 122 124 } 125 126 129 public void setInput(ModelElement[] elt) throws Exception { 130 132 } 133 134 137 public void setLogger(ModFactLogger log) throws Exception { 138 _logger = log; 139 140 } 141 142 145 public void setJavaHelper(JavaCommon common) { 146 javaHelper = common; 147 } 148 149 } 150 | Popular Tags |