1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.rss;
12
13 import java.io.IOException;
14 import java.net.InetSocketAddress;
15 import java.net.SocketAddress;
16
17 import org.simpleframework.http.core.Container;
18 import org.simpleframework.transport.connect.Connection;
19 import org.simpleframework.transport.connect.SocketConnection;
20
21
22
23
24
25
26 public class SimpleHttpServer
27 {
28 private Container container;
29 private SocketAddress address;
30 private Connection connection;
31
32 public SimpleHttpServer(int port, Container container)
33 {
34 super();
35 this.address = new InetSocketAddress(port);
36 this.container = container;
37 }
38
39 public void start() throws IOException
40 {
41 connection = new SocketConnection(container);
42 connection.connect(address);
43 }
44
45 public void stop()
46 {
47 try
48 {
49 if (connection != null)
50 {
51 connection.close();
52 }
53 }
54 catch (IOException e)
55 {
56 throw new IllegalStateException(e);
57 }
58 }
59 }