KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scioworks > imap > spec > ImapWebConstant


1 /* -----------------------------------------------------------------------------
2  * Copyright (c) 2001, Low Kin Onn
3  * All rights reserved.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  *
8  * Redistributions of source code must retain the above copyright notice, this
9  * list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * Neither name of the Scioworks Pte. Ltd. nor the names of its contributors
16  * may beused to endorse or promote products derived from this software without
17  * specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  *
30  * -----------------------------------------------------------------------------
31  */

32
33 package scioworks.imap.spec;
34
35 import com.lutris.util.Config;
36 import com.lutris.util.ConfigException;
37 import com.lutris.appserver.server.Enhydra;
38
39 public class ImapWebConstant {
40
41   private static ImapWebConstant fSingleton;
42
43   private String JavaDoc fDomain;
44   private String JavaDoc fSmtpHost;
45   private String JavaDoc fImapHost;
46   private int fImapPort;
47
48   private String JavaDoc fFolderSent;
49   private String JavaDoc fFolderTrash;
50
51   private String JavaDoc fFileTmpDir;
52   private int fFileCount;
53   private int fFileTotalSize;
54
55   private ImapWebConstant() {
56
57     Config config = Enhydra.getApplication().getConfig();
58
59     try {
60       fDomain = config.getString("ImapWeb.Server.Domain");
61       fSmtpHost = config.getString("ImapWeb.Server.SmtpHost");
62       fImapHost = config.getString("ImapWeb.Server.ImapHost");
63       fImapPort = config.getInt ("ImapWeb.Server.ImapPort");
64
65       fFolderSent = config.getString("ImapWeb.Folder.FolderSent");
66       fFolderTrash = config.getString("ImapWeb.Folder.FolderTrash");
67
68       fFileTmpDir = config.getString("ImapWeb.Attachment.FileTmpDir");
69       fFileCount = config.getInt ("ImapWeb.Attachment.FileCount");
70       fFileTotalSize = config.getInt("ImapWeb.Attachment.FileTotalSize");
71
72     } catch (ConfigException e) {
73       e.printStackTrace();
74     }
75
76     // Currently values are hard-coded
77
/*
78     fDomain = "scioworks.com";
79     fSmtpHost = "gecko.scioworks.com";
80     fImapHost = "gecko.scioworks.com";
81     fImapPort = 143;
82
83     fFolderSent = "Sent";
84     fFolderTrash = "Trash";
85
86     fFileTmpDir = "c:\\temp\\";
87     fFileCount = 3;
88     fFileTotalSize = 10 * 1024 * 1024; // size in bytes
89     */

90   }
91
92   public static synchronized ImapWebConstant singleton() {
93     if (fSingleton == null) {
94       fSingleton = new ImapWebConstant();
95     }
96     return fSingleton;
97   }
98
99   // Attributes retrieval methods goes here
100

101   public String JavaDoc domain() {
102     return fDomain;
103   }
104
105   public String JavaDoc smtpHost() {
106     return fSmtpHost;
107   }
108
109   public String JavaDoc imapHost() {
110     return fImapHost ;
111   }
112
113   public int imapPort() {
114     return fImapPort;
115   }
116
117   public String JavaDoc folderSent() {
118     return fFolderSent;
119   }
120
121   public String JavaDoc folderTrash() {
122     return fFolderTrash;
123   }
124
125   public String JavaDoc fileTmpDir() {
126     return fFileTmpDir;
127   }
128
129   public int fileCount() {
130     return fFileCount;
131   }
132
133   public int fileTotalSize() {
134     return fFileTotalSize;
135   }
136 }
137
138
Popular Tags