TeamCity插件开发Maven

时间:2017-11-06 07:37:00

标签: servlets teamcity maven-plugin

所以我想开发一个非常简单的TeamCity插件。插件只是假设接受用户输入并显示它。我的代码似乎可以在我的本地Tomcat服务器上运行,但是当我尝试通过jetbrains的Basecontroller类将它集成到TeamCity时,似乎没有输出。这是我的代码

public class AppServer extends BaseController{

private PluginDescriptor myDescriptor;

public AppServer (WebControllerManager manager, PluginDescriptor descriptor) {
    manager.registerController("/demoPlugin.html",this);
    myDescriptor=descriptor;
}


public void doGet(HttpServletRequest request, HttpServletResponse responseone)throws IOException, ServletException {
        try {
            responseone.setContentType("text/html; charset=UTF-8");
            PrintWriter out = responseone.getWriter();

            try {
                out.println("<!DOCTYPE html>");
                out.println("<html><head>");
                out.println("<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>");
                out.println("<title>Echo Servlet</title></head>");
                out.println("<body><h2>You have enter</h2>");

                String requirement = request.getParameter("requirement");
                if (requirement == null || (requirement = htmlFilter(requirement.trim())).length() == 0) {
                    out.println("<p>Agent Requirement: Not specified</p>");
                }
                else {
                    out.println("<p>Agent Requirement: " + requirement + "</p>");

                }
                out.println("<a href='form_input.html'>BACK</a>");
                out.println("</body></html>");
            }
            finally{
                out.close();  
            }
        } 
         finally{
                return;
            }
}

    public void doPost(HttpServletRequest request, HttpServletResponse responseone)
        throws IOException, ServletException {
            doGet(request, responseone);
    }

private static String htmlFilter(String message) {
    if (message == null) return null;
    int len = message.length();
    StringBuffer result = new StringBuffer(len + 20);
    char aChar;

   for (int i = 0; i < len; ++i) {
        aChar = message.charAt(i);
        switch (aChar) {
            case '<': result.append("&lt;"); break;
            case '>': result.append("&gt;"); break;
            case '&': result.append("&amp;"); break;
            case '"': result.append("&quot;"); break;
            default: result.append(aChar);
        }
    }
  return (result.toString());
   }
       protected ModelAndView doHandle(HttpServletRequest httpServletRequest, 

    HttpServletResponse httpServletResponse) throws Exception {
            return new ModelAndView(myDescriptor.getPluginResourcesPath("Hello.jsp"));
        }
    }

老实说,我不知道自己在做什么,似乎无法找到有关Jetbrains的Basecontroller类的任何好的教程。请帮忙。

0 个答案:

没有答案