1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.monitor;
14
15 import org.mortbay.jetty.bio.SocketConnector;
16 import org.mortbay.jetty.servlet.Context;
17 import org.mortbay.jetty.servlet.ServletHolder;
18
19 import com.eviware.soapui.impl.wsdl.monitor.jettyproxy.ProxyServlet;
20 import com.eviware.soapui.impl.wsdl.monitor.jettyproxy.Server;
21 import com.eviware.soapui.support.UISupport;
22
23 public class SoapMonitorEngineImpl implements SoapMonitorEngine {
24
25 Server server = new Server();
26 SocketConnector connector = new SocketConnector();
27
28 public boolean isRunning() {
29 return server.isRunning();
30 }
31
32 public void start(SoapMonitor soapMonitor, int localPort) {
33
34 connector.setPort(localPort);
35 server.addConnector(connector);
36 Context context = new Context(server, "/", 0);
37 context.addServlet(new ServletHolder(new ProxyServlet(soapMonitor)), "/");
38
39 try
40 {
41 server.start();
42 }
43 catch (Exception e)
44 {
45 UISupport.showErrorMessage("Error starting monitor: " + e.getMessage());
46 }
47
48 }
49
50 public void stop() {
51
52 try {
53 if( server != null ) {
54 server.stop();
55 }
56 } catch (Exception e) {
57 e.printStackTrace();
58 } finally {
59 if ( server != null ) {
60 server.destroy();
61 }
62 }
63
64 }
65
66 }