View Javadoc

1   package ca.uhn.hl7v2.examples.hoh;
2   
3   import javax.servlet.Servlet;
4   
5   import org.mortbay.jetty.Server;
6   import org.mortbay.jetty.servlet.Context;
7   import org.mortbay.jetty.servlet.ServletHolder;
8   
9   public class JettyBasedRawServer {
10  
11  	/**
12  	 * @param args
13  	 * @throws Exception 
14  	 */
15  	public static void main(String[] args) throws Exception {
16  
17  // START SNIPPET: server 
18  // The port to listen on
19  int port = 8080;
20  
21  // Create a Jetty server instance
22  Server server = new Server(port);
23  Context context = new Context(server, "/Hl7Listener", Context.SESSIONS);
24  Servlet servlet = new ExampleRawHl7OverHttpServlet();
25  
26  /* 
27   * Adds the servlet to listen at 
28   * http://localhost:8080/Hl7Listener/Incoming
29   */
30  context.addServlet(new ServletHolder(servlet), "/Incoming");
31  
32  // Start the server
33  server.start();
34  
35  // .. let the application run ..
36  
37  /*
38   * Later it will probably be appropriate to shut the server
39   * down.
40   */
41  server.stop();
42  // END SNIPPET: server 
43  
44  	}
45  
46  }