1
2
3
4
5
6
7 package org.mule.transport.servlet.jetty;
8
9 import org.mule.api.MuleException;
10 import org.mule.api.lifecycle.LifecycleException;
11 import org.mule.api.transport.MessageReceiver;
12
13 import javax.servlet.Servlet;
14
15 import org.apache.commons.logging.Log;
16 import org.apache.commons.logging.LogFactory;
17 import org.mortbay.jetty.Connector;
18
19
20
21
22 public abstract class AbstractConnectorHolder<S extends Servlet, R extends MessageReceiver> implements ConnectorHolder<S, R>
23 {
24
25
26
27 protected transient final Log logger = LogFactory.getLog(AbstractConnectorHolder.class);
28 protected Connector connector;
29 protected S servlet;
30 protected boolean started = false;
31
32 @SuppressWarnings("unused")
33 public AbstractConnectorHolder(Connector connector, S servlet, R receiver)
34 {
35 this.connector = connector;
36 this.servlet = servlet;
37 }
38
39 public S getServlet()
40 {
41 return servlet;
42 }
43
44 public Connector getConnector()
45 {
46 return connector;
47 }
48
49
50 public void start() throws MuleException
51 {
52 try
53 {
54 connector.start();
55 started = true;
56 }
57 catch (Exception e)
58 {
59 throw new LifecycleException(e, this);
60 }
61 }
62
63 public void stop() throws MuleException
64 {
65 try
66 {
67 connector.stop();
68 started = false;
69 }
70 catch (Exception e)
71 {
72 logger.warn("Jetty connector did not close cleanly: " + e.getMessage());
73 }
74
75 }
76
77 }