1 16 17 package org.apache.tester; 18 19 20 import java.io.*; 21 import java.net.MalformedURLException ; 22 import java.net.URL ; 23 import javax.servlet.*; 24 import javax.servlet.http.*; 25 26 27 42 43 public class Lifecycle03 extends HttpServlet { 44 45 private static String staticTrail = ""; 46 47 private String instanceTrail = ""; 48 49 public void init() throws ServletException { 50 staticTrail += "I"; 51 instanceTrail += "I"; 52 } 53 54 public void destroy() { 55 staticTrail += "D"; 56 instanceTrail += "D"; 57 } 58 59 public void doGet(HttpServletRequest request, HttpServletResponse response) 60 throws IOException, ServletException { 61 62 staticTrail += "S"; 63 instanceTrail += "S"; 64 65 if ("1".equals(request.getParameter("step"))) { 67 staticTrail = "IS"; 68 throw new UnavailableException("Lifecycle03 is permanently unavailable"); 69 } 70 71 response.setContentType("text/plain"); 73 PrintWriter writer = response.getWriter(); 74 if (staticTrail.equals("ISDIS") && instanceTrail.equals("IS")) 75 writer.println("Lifecycle03 PASSED"); 76 else 77 writer.println("Lifecycle03 FAILED - staticTrail=" + staticTrail + 78 ", instanceTrail=" + instanceTrail); 79 80 while (true) { 81 String message = StaticLogger.read(); 82 if (message == null) 83 break; 84 writer.println(message); 85 } 86 StaticLogger.reset(); 87 88 } 89 90 91 } 92 | Popular Tags |