KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > transport > mail > server > MailServer


1 package org.apache.axis2.transport.mail.server;
2
3 import org.apache.axis2.context.ConfigurationContext;
4 import org.apache.axis2.context.ConfigurationContextFactory;
5 import org.apache.axis2.engine.AxisFault;
6 import org.apache.axis2.transport.mail.SimpleMailListener;
7 import org.apache.commons.logging.Log;
8 import org.apache.commons.logging.LogFactory;
9
10 /**
11  * @author Chamil Thanthrimudalige
12  */

13 public class MailServer {
14     Storage st = null;
15     public ConfigurationContext configurationContext = null;
16     protected static Log log = LogFactory.getLog(SimpleMailListener.class.getName());
17
18     public MailServer(String JavaDoc dir, int popPort,int smtpPort) throws AxisFault {
19             try {
20                 ConfigurationContextFactory builder = new ConfigurationContextFactory();
21                 configurationContext = builder.buildConfigurationContext(dir);
22             } catch (Exception JavaDoc e) {
23                 log.error(e);
24             }
25             try {
26                 System.out.println("Sleeping for a bit to let the engine start up.");
27                 Thread.sleep(2000);
28             } catch (InterruptedException JavaDoc e1) {
29                 log.error(e1);
30             }
31             st = new Storage();
32             // Start up the two servers and lets have some fun. - CT
33
SMTPServer smtpServer = new SMTPServer(st,configurationContext,smtpPort);
34             smtpServer.start();
35             POP3Server pop3Server = new POP3Server(st,popPort);
36             pop3Server.start();
37
38         }
39     public MailServer(ConfigurationContext configurationContext,int popPort,int smtpPort) throws AxisFault{
40         this.configurationContext = configurationContext;
41         try {
42             System.out.println("Sleeping for a bit to let the engine start up.");
43             Thread.sleep(2000);
44         } catch (InterruptedException JavaDoc e1) {
45             log.error(e1);
46         }
47
48         st = new Storage();
49         // Start up the two servers and lets have some fun. - CT
50
SMTPServer smtpServer = new SMTPServer(st,configurationContext,smtpPort);
51         smtpServer.start();
52         POP3Server pop3Server = new POP3Server(st,popPort);
53         pop3Server.start();
54     }
55 }
56
Popular Tags