1 16 17 package org.apache.axis.transport.http ; 18 19 import org.apache.axis.components.logger.LogFactory; 20 import org.apache.axis.server.AxisServer; 21 import org.apache.axis.utils.Messages; 22 import org.apache.axis.AxisFault; 23 import org.apache.axis.ConfigurationException; 24 import org.apache.axis.handlers.soap.SOAPService; 25 import org.apache.axis.description.ServiceDesc; 26 import org.apache.commons.logging.Log; 27 28 import javax.servlet.ServletException ; 29 import javax.servlet.http.HttpServletRequest ; 30 import javax.servlet.http.HttpServletResponse ; 31 import javax.xml.namespace.QName ; 32 import java.io.IOException ; 33 import java.util.Iterator ; 34 35 48 public class AdminServlet extends AxisServletBase { 49 50 private static Log log = 51 LogFactory.getLog(AxisServlet.class.getName()); 52 53 54 61 public void doGet(HttpServletRequest request, HttpServletResponse response) 62 throws ServletException , IOException { 63 response.setContentType("text/html; charset=utf-8"); 64 StringBuffer buffer=new StringBuffer (512); 65 buffer.append("<html><head><title>Axis</title></head><body>\n"); 66 AxisServer server = getEngine(); 68 69 String cmd = request.getParameter("cmd"); 71 if (cmd != null) { 72 String callerIP=request.getRemoteAddr(); 74 if (isDevelopment()) { 75 if (cmd.equals("start")) { 77 log.info(Messages.getMessage("adminServiceStart", callerIP)); 78 server.start(); 79 } 80 else if (cmd.equals("stop")) { 81 log.info(Messages.getMessage("adminServiceStop", callerIP)); 82 server.stop(); 83 } 84 else if (cmd.equals("suspend")) { 85 String name = request.getParameter("service"); 86 log.info(Messages.getMessage("adminServiceSuspend", name, callerIP)); 87 SOAPService service = server.getConfig().getService(new QName ("",name)); 88 service.stop(); 89 } 90 else if (cmd.equals("resume")) { 91 String name = request.getParameter("service"); 92 log.info(Messages.getMessage("adminServiceResume", name, callerIP)); 93 SOAPService service = server.getConfig().getService(new QName ("",name)); 94 service.start(); 95 } 96 } else { 97 log.info(Messages.getMessage("adminServiceDeny", callerIP)); 100 } 101 } 102 103 if (server.isRunning()) { 105 buffer.append("<H2>"); 106 buffer.append(Messages.getMessage("serverRun00")); 107 buffer.append("</H2>"); 108 } 109 else { 110 buffer.append("<H2>"); 111 buffer.append(Messages.getMessage("serverStop00")); 112 buffer.append("</H2>"); 113 } 114 if(isDevelopment()) { 116 buffer.append("<p><a HREF=\"AdminServlet?cmd=start\">start server</a>\n"); 117 buffer.append("<p><a HREF=\"AdminServlet?cmd=stop\">stop server</a>\n"); 118 119 Iterator i; 120 try { 121 i = server.getConfig().getDeployedServices(); 122 } catch (ConfigurationException configException) { 123 if(configException.getContainedException() instanceof AxisFault) { 126 throw (AxisFault) configException.getContainedException(); 127 } else { 128 throw configException; 129 } 130 } 131 132 buffer.append("<p><h2>Services</h2>"); 133 buffer.append("<ul>"); 134 while (i.hasNext()) { 135 ServiceDesc sd = (ServiceDesc)i.next(); 136 StringBuffer sb = new StringBuffer (); 137 sb.append("<li>"); 138 String name = sd.getName(); 139 sb.append(name); 140 SOAPService service = server.getConfig().getService(new QName ("",name)); 141 if(service.isRunning()) { 142 sb.append(" <a HREF=\"AdminServlet?cmd=suspend&service=" + name + "\">suspend</a>\n"); 143 } else { 144 sb.append(" <a HREF=\"AdminServlet?cmd=resume&service=" + name + "\">resume</a>\n"); 145 } 146 sb.append("</li>"); 147 buffer.append(sb.toString()); 148 } 149 buffer.append("</ul>"); 150 } 151 buffer.append("<p>"); 153 buffer.append(Messages.getMessage("adminServiceLoad", 154 Integer.toString(getLoadCounter()))); 155 buffer.append("\n</body></html>\n"); 156 response.getWriter().print( new String (buffer) ); 157 } 158 } 159 | Popular Tags |