1 16 17 package org.apache.axis.transport.http; 18 19 import org.apache.axis.components.logger.LogFactory; 20 import org.apache.axis.utils.Messages; 21 import org.apache.axis.utils.Options; 22 import org.apache.commons.logging.Log; 23 import org.mortbay.http.HttpContext; 24 import org.mortbay.http.HttpServer; 25 import org.mortbay.http.SocketListener; 26 import org.mortbay.http.handler.ResourceHandler; 27 import org.mortbay.jetty.servlet.ServletHandler; 28 29 import java.net.MalformedURLException ; 30 31 public class JettyAxisServer { 32 protected static Log log = 33 LogFactory.getLog(JettyAxisServer.class.getName()); 34 35 38 HttpServer server = new HttpServer(); 39 40 43 SocketListener listener = new SocketListener(); 44 45 48 HttpContext context = new HttpContext(); 49 50 public JettyAxisServer() { 51 context.setContextPath("/axis/*"); 53 server.addContext(context); 54 55 ServletHandler servlets = new ServletHandler(); 57 context.addHandler(servlets); 58 59 servlets.addServlet("AdminServlet", "/servlet/AdminServlet", 61 "org.apache.axis.transport.http.AdminServlet"); 62 servlets.addServlet("AxisServlet", "/servlet/AxisServlet", 63 "org.apache.axis.transport.http.AxisServlet"); 64 servlets.addServlet("AxisServlet", "/services/*", 65 "org.apache.axis.transport.http.AxisServlet"); 66 servlets.addServlet("AxisServlet", "*.jws", 67 "org.apache.axis.transport.http.AxisServlet"); 68 context.addHandler(new ResourceHandler()); 69 } 70 71 76 public void setPort(int port) { 77 listener.setPort(port); 78 server.addListener(listener); 79 } 80 81 86 public void setResourceBase(String dir) { 87 context.setResourceBase(dir); 88 } 89 90 95 public void start() throws Exception { 96 server.start(); 97 log.info( 98 Messages.getMessage("start00", "JettyAxisServer", 99 new Integer (listener.getServerSocket().getLocalPort()).toString())); 100 } 101 102 public static void main(String [] args) { 103 Options opts = null; 104 try { 105 opts = new Options(args); 106 } catch (MalformedURLException e) { 107 log.error(Messages.getMessage("malformedURLException00"), e); 108 return; 109 } 110 JettyAxisServer server = new JettyAxisServer(); 111 server.setPort(opts.getPort()); 112 String dir = opts.isValueSet('d'); 113 if (dir == null) { 114 dir = System.getProperty("jetty.home", ".") + "/webapps/axis/"; 116 } 117 server.setResourceBase(dir); 118 119 try { 121 server.start(); 122 } catch (Exception e) { 123 log.error(Messages.getMessage("exception00"), e); 124 } 125 } 126 } | Popular Tags |