1 package org.masukomi.aspirin.core;
2
3
4 import org.masukomi.prefs.*;
5 import org.masukomi.aspirin.core.dnsserver.*;
6
7 import java.io.IOException;
8 import java.net.*;
9 //import javax.mail.*;
10 /***
11 * @author
12 */
13 public class Aspirin extends Thread{
14
15 /*** should contain the following keys
16 *
17 * <ul>
18 * <li>port - the port to bind to</li>
19 * <li>queSize - the number of incoming connections to all to be qued up.
20 * </li>
21 *
22 * </ul>
23 */
24 private XMLClassPreferences preferences;
25
26 static {
27 XMLPreferences.setPreferencesRoot(System.getProperty("user.dir") + "/prefs");
28
29 }
30
31
32
33 public static void main(String[] args) {
34 // doesn't currently take any arguments
35 Aspirin theAspirin = new Aspirin();
36 theAspirin.setName("Aspirin Main Thread");
37 theAspirin.start();
38
39 }
40
41 public Aspirin(){
42 preferences = XMLClassPreferences.systemNodeForClass(this.getClass());
43
44 }
45
46 /***
47 * @todo log the errors
48 * @see java.lang.Runnable#run()
49 */
50 public void run(){
51 // open a socket on port 25
52 ServerSocket serverSocket;
53 try {
54 serverSocket =
55 new ServerSocket(
56 preferences.getInt("port", 25),
57 preferences.getInt("queSize", 20));
58
59
60 System.out.println("Aspirin running");
61 DNSServer dns = new DNSServer();
62 if (DNSServer.ready){
63 while (true) {
64 System.out.println("waiting for connection");
65
66 final Socket socket = serverSocket.accept();
67 System.out.println("got a connection");
68 SMTPHandler currentHandler = new SMTPHandler(socket);
69 //ConnectionHandler currentHandler = new ConnectionHandler(socket);
70 currentHandler.start();
71 }
72 } else {
73 System.out.println("unable to load DNS");
74 }
75
76
77 } catch (IOException e) {
78
79 // log the error
80 System.out.println("Aspirin.run() " + e);
81 return;
82 }
83
84 // the SMTPHandler will read in the mail and pass it on to
85 // the appropriate place
86
87
88
89 }
90
91
92 }
93
This page was automatically generated by Maven