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