Package com.google.opengse.webapp.codegen

Examples of com.google.opengse.webapp.codegen.ClassDefinition


    if (!javadir.exists()) {
      System.err.println("Can't create '" + javadir + "' for some reason.");
      return;
    }

    ClassDefinition classdef = new ClassDefinition(EXAMPLE_CODE_PACKAGE, EXAMPLE_CODE_CLASS);
    classdef.setSuperClass(HttpServlet.class);
    classdef.addImport(HttpServlet.class);
    classdef.addImport(HttpServletRequest.class);
    classdef.addImport(HttpServletResponse.class);
    classdef.addImport(ServletException.class);
    classdef.addImport(IOException.class);
    MethodDefinition method = new MethodDefinition("service");
    method.setPublic(true);
    method.addThrowsClause(ServletException.class).addThrowsClause(IOException.class);
    method.addArg(HttpServletRequest.class, "request");
    method.addArg(HttpServletResponse.class, "response");
    method.addLine("response.setContentType(\"text/plain\");");
    method.addLine("response.getWriter().println(\"Hello World!\");");
    classdef.addMethod(method);

    File javafile = new File(javadir
        , EXAMPLE_CODE_PACKAGE.replace('.', File.separatorChar) + File.separator + EXAMPLE_CODE_CLASS + ".java");
    javafile.getParentFile().mkdirs();
    PrintWriter java = new PrintWriter(javafile);
    try {
      classdef.write(java);
    } finally {
      java.close();
    }
   
    WebAppConfigurationBuilder wxmlb = new WebAppConfigurationBuilder();
View Full Code Here

TOP

Related Classes of com.google.opengse.webapp.codegen.ClassDefinition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.