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