Source Code Cross Referenced for JwmaKernel.java in  » Web-Mail » Jwma » dtw » webmail » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Mail » Jwma » dtw.webmail 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /***
002:         * jwma Java WebMail
003:         * Copyright (c) 2000-2003 jwma team
004:         *
005:         * jwma is free software; you can distribute and use this source
006:         * under the terms of the BSD-style license received along with
007:         * the distribution.
008:         ***/package dtw.webmail;
009:
010:        import java.util.*;
011:        import java.io.*;
012:        import java.net.*;
013:
014:        import org.apache.log4j.Logger;
015:        import org.apache.log4j.PropertyConfigurator;
016:        import org.apache.log4j.BasicConfigurator;
017:
018:        import dtw.webmail.util.*;
019:        import dtw.webmail.util.config.*;
020:        import dtw.webmail.model.*;
021:        import dtw.webmail.admin.*;
022:        import dtw.webmail.plugin.*;
023:        import dtw.webmail.plugin.std.CastorHelper;
024:        import net.wimpi.text.*;
025:
026:        import javax.mail.Transport;
027:
028:        /**
029:         * A kernel that represents a hub for internal "globally" used
030:         * jwma functions & data (system settings).
031:         *
032:         * This class implements the singleton pattern, which means there is
033:         * only one instance throughout run-time.
034:         *
035:         * @author Dieter Wimberger
036:         * @version 0.9.7 07/02/2003
037:         */
038:        public class JwmaKernel {
039:
040:            //class attributes
041:            private static JwmaKernel c_Self = null; //Singleton instance
042:            //logging
043:            private static Logger log = Logger.getLogger(JwmaKernel.class);
044:
045:            //instance attributes
046:            private int m_Diag = 0; //diagnostic counter
047:            private String m_ConfigurationFile;
048:            private JwmaConfiguration m_Configuration; //configuration
049:
050:            //i18n
051:            private URLClassLoader m_i18nLoader; //class loader for resource bundles
052:            private ResourceBundle m_LogMessages; //Log message resource bundle
053:            private ResourceBundle m_ErrorMessages; //Error message resource bundle
054:
055:            //Admin related
056:            private boolean m_StatusEnabled; //Status enabled
057:            private String[] m_Admins; //administrator usernames
058:
059:            //Text processing
060:            private Processor m_MessageProcessor; //default message processor
061:            private ProcessingKernel m_ProcessingKernel; //processing kernel
062:            private String m_TextProcFile; //jTextproc properties
063:
064:            //Directories
065:            private String m_RootDir; //root directory
066:            private String m_EtcDir; //etc dir
067:            private String m_DataDir; //data dir
068:            private String m_LogDir; //log dir
069:            private String m_i18nDir; //i18n bundle dir
070:
071:            //Logging
072:            private String m_LogProperties; //log4j properties file
073:
074:            //Plugin references
075:            private PreferencesPersistencePlugin m_PrefsPersistencePlugin;
076:            private RandomAppendPlugin m_RandomAppendPlugin;
077:            private ContactManagementPlugin m_ContactManagementPlugin;
078:
079:            //Controller Urls
080:            private String m_MainController;
081:            private String m_MailingController;
082:            private String m_AdminController;
083:            private String m_ContactsController;
084:
085:            //View urls
086:            private Properties m_Views;
087:
088:            /**
089:             * Constructs a JwmaKernel instance.
090:             * Private to prevent construction from outside of
091:             * this class.
092:             */
093:            private JwmaKernel() {
094:                c_Self = this ;
095:                m_Views = new Properties();
096:            }//constructor
097:
098:            /**
099:             * Prepares the kernel for service.
100:             *
101:             * @param path representing the root directory where jwma's
102:             *        files reside, as <tt>String</tt>.
103:             *
104:             * @throws Exception when it fails to load the properties or
105:             *         set up system functionality according to the settings
106:             *         in the properties.
107:             */
108:            public void setup(String path) throws Exception {
109:                //Configure to log to standard out at least.
110:                BasicConfigurator.configure();
111:
112:                //1.setup directories
113:                setupDirectories(path);
114:                m_Diag++;
115:
116:                //2.setup filenames
117:                setupFiles();
118:                m_Diag++;
119:
120:                //3.load configuration
121:                loadConfiguration();
122:                m_Diag++;
123:
124:                //4.setup i18n
125:                prepareI18N();
126:                m_Diag++;
127:
128:                //5.prepare log files
129:                prepareLogging();
130:                m_Diag++;
131:
132:                //From here on we write to the own log
133:                try {
134:
135:                    //6.prepare plugins
136:                    preparePlugins();
137:                    m_Diag++;
138:                    //7.prepare processing
139:                    prepareProcessing();
140:                    m_Diag++;
141:
142:                    //8.prepare postoffice and transport settings
143:                    prepareMailServices();
144:                    m_Diag++;
145:
146:                    //9.prepare controller urls
147:                    prepareControllerUrls();
148:                    m_Diag++;
149:
150:                    //10.prepare view urls
151:                    prepareViewUrls();
152:                    m_Diag++;
153:
154:                } catch (JwmaException err) {
155:                    //log exception with description and trace if inlined exception
156:                    //available, else with stacktrace.
157:                    if (err.hasException()) {
158:                        log.error(err.getMessage(), err.getException());
159:                    } else {
160:                        log.error(err.getMessage(), err);
161:                    }
162:                    throw err;
163:                } catch (Exception ex) {
164:                    log.error(ex.getMessage(), ex);
165:                    throw ex;
166:                } finally {
167:                    //JwmaStatus.createJwmaStatus();
168:                }
169:            }//setup
170:
171:            /**
172:             * Sets up all necessary directory paths.
173:             *
174:             * @param path the root path pointing to the directory where
175:             *        the jwma data resides.
176:             */
177:            private void setupDirectories(String path) {
178:                //Directories
179:                m_RootDir = path;
180:                m_EtcDir = m_RootDir + File.separator + JwmaSettings.ETC_DIR
181:                        + File.separator;
182:                m_LogDir = m_RootDir + File.separator + JwmaSettings.LOG_DIR
183:                        + File.separator;
184:                m_DataDir = m_RootDir + File.separator + JwmaSettings.DATA_DIR
185:                        + File.separator;
186:                m_i18nDir = StringUtil.repairPath(m_RootDir + File.separator
187:                        + JwmaSettings.I18N_DIR + File.separator);
188:            }//setupDirectories
189:
190:            /**
191:             * Sets up all necessary file paths.
192:             */
193:            private void setupFiles() {
194:                m_ConfigurationFile = m_EtcDir
195:                        + JwmaConfiguration.CONFIG_FILENAME;
196:                m_LogProperties = m_EtcDir + JwmaConfiguration.LOG4J_CONFIG;
197:                m_TextProcFile = m_EtcDir + JwmaConfiguration.JTEXTPROC_CONFIG;
198:            }//setupFiles
199:
200:            private void loadConfiguration() throws Exception {
201:
202:                CastorXMLConfiguration cxmlconf = new CastorXMLConfiguration(
203:                        new File(m_ConfigurationFile));
204:                m_Configuration = cxmlconf.load();
205:                log.info("Loaded configuration.");
206:            }//loadConfiguration
207:
208:            /**
209:             * Prepares i18n for jwma
210:             */
211:            private void prepareI18N() throws Exception {
212:
213:                //1. setup classloader for bundles
214:                URL[] urls = { new File(m_i18nDir).toURL() };
215:                log.debug(urls[0].toString());
216:                m_i18nLoader = new URLClassLoader(urls);
217:
218:                //2. retrieve instance from configuration
219:                Internationalization i18n = m_Configuration.getI18N();
220:
221:                log.debug("Loading logmessage bundle:"
222:                        + i18n.getSystemLanguage());
223:                //3. load log messages bundle for system locale
224:                m_LogMessages = ResourceBundle.getBundle("logmessages", i18n
225:                        .getSystemLocale(), m_i18nLoader);
226:
227:                log.debug("Loading logmessage bundle:"
228:                        + i18n.getSystemLanguage());
229:                //4. load error messages for system locale
230:                m_ErrorMessages = ResourceBundle.getBundle("errormessages",
231:                        i18n.getSystemLocale(), m_i18nLoader);
232:
233:                log.info(getLogMessage("jwma.kernel.prepared.i18n"));
234:            }//prepareI18N
235:
236:            /**
237:             * Prepares jwma log files.
238:             */
239:            private void prepareLogging()
240:      throws Exception {
241:
242:    //1.load the properties
243:    Properties props = new Properties();
244:    props.load(new FileInputStream(m_LogProperties));
245:
246:    //2. fix relative paths
247:    for (Enumeration enum = props.propertyNames(); enum.hasMoreElements();) {
248:      String property = (String) enum.nextElement();
249:      if (property.indexOf(".File") > 0) {
250:        File file = new File(props.getProperty(property));
251:        if (!file.isAbsolute()) {
252:          props.setProperty(property, m_LogDir + file.getPath());
253:        }
254:      }
255:    }
256:
257:    //configure log4j
258:    PropertyConfigurator.configure(props);
259:
260:    log.info(getLogMessage("jwma.kernel.prepared.logging"));
261:  }//prepareLogging
262:
263:            /**
264:             * Prepare contact management.
265:             */
266:            private void preparePlugins() throws Exception {
267:
268:                log.debug("Loading and activating plugins.");
269:                //1. Load & activate preferences persistence plugin
270:                m_PrefsPersistencePlugin = (PreferencesPersistencePlugin) Class
271:                        .forName(
272:                                m_Configuration
273:                                        .getPreferencePersistencePlugin())
274:                        .newInstance();
275:                m_PrefsPersistencePlugin.activate();
276:
277:                //2. Load & activate contact management plugin
278:                m_ContactManagementPlugin = (ContactManagementPlugin) Class
279:                        .forName(m_Configuration.getContactManagementPlugin())
280:                        .newInstance();
281:                m_ContactManagementPlugin.activate();
282:
283:                //3. Load & activate random append plugin
284:                String rndapp = m_Configuration.getRandomAppendPlugin();
285:                if (rndapp != null && rndapp.length() != 0) {
286:                    m_RandomAppendPlugin = (RandomAppendPlugin) Class.forName(
287:                            rndapp).newInstance();
288:                    m_RandomAppendPlugin.activate();
289:                }
290:
291:            }//preparePlugins
292:
293:            /**
294:             * Prepares the processing.
295:             */
296:            private void prepareProcessing() throws Exception {
297:
298:                Properties procprops = new Properties();
299:                FileInputStream in = new FileInputStream(m_TextProcFile);
300:                procprops.load(in);
301:
302:                //create processing kernel
303:                m_ProcessingKernel = ProcessingKernel
304:                        .createProcessingKernel(procprops);
305:
306:                //lookup default message processing pipe
307:                m_MessageProcessor = getMessageProcessor(m_Configuration
308:                        .getDefaultMessageProcessor());
309:
310:                if (m_MessageProcessor == null) {
311:                    throw new Exception(
312:                            "Failed to load default message processing pipe.");
313:                }
314:
315:                log.info(getLogMessage("jwma.kernel.prepared.processing"));
316:            }//prepareProcessing
317:
318:            /**
319:             * Prepares the mail service related settings.
320:             */
321:            private void prepareMailServices() throws Exception {
322:
323:                //1. setup transport agent
324:                MailTransportAgent mta = m_Configuration.getMTA();
325:
326:                //set system properties
327:                //TODO: Check if really required
328:                System.getProperties().put(
329:                        "mail." + mta.getProtocol() + ".auth",
330:                        new Boolean(mta.isAuthenticated()).toString());
331:                System.getProperties().put("mail.smtp.host", mta.getAddress());
332:                if (mta.isSecure()) {
333:                    m_Configuration.getSecurity().addSocketProperties(
334:                            mta.getProtocol(), mta.getPort());
335:                }
336:
337:                //2. post office security setup
338:                for (Iterator iter = m_Configuration.getPostOffices(); iter
339:                        .hasNext();) {
340:                    PostOffice po = (PostOffice) iter.next();
341:                    if (po.isSecure()) {
342:                        m_Configuration.getSecurity().addSocketProperties(
343:                                po.getProtocol(), po.getPort());
344:                    }
345:                }
346:
347:                log.info(getLogMessage("jwma.kernel.prepared.mailservices"));
348:            }//prepareMailServices
349:
350:            /**
351:             * Prepares the controller url's
352:             */
353:            private void prepareControllerUrls() {
354:                Properties ctrls = new Properties();
355:                try {
356:                    ctrls
357:                            .load(Thread
358:                                    .currentThread()
359:                                    .getContextClassLoader()
360:                                    .getResourceAsStream(
361:                                            "dtw/webmail/resources/controllers.properties"));
362:                    m_MainController = ctrls
363:                            .getProperty("jwma.controller.main");
364:                    m_MailingController = ctrls
365:                            .getProperty("jwma.controller.mailing");
366:                    m_ContactsController = ctrls
367:                            .getProperty("jwma.controller.contacts");
368:                    m_AdminController = ctrls
369:                            .getProperty("jwma.controller.admin");
370:                } catch (IOException ex) {
371:                    log.error("prepareControllerUrls()", ex);
372:                    return;
373:                }
374:                for (Iterator iter = ctrls.keySet().iterator(); iter.hasNext();) {
375:                    String key = (String) iter.next();
376:                    log.debug(key + "=" + ctrls.get(key));
377:                }
378:                log.info(getLogMessage("jwma.kernel.prepared.curls"));
379:            }//prepareControllerUrls
380:
381:            /**
382:             * Prepares the view url's.
383:             */
384:            private void prepareViewUrls() {
385:                m_Views = new Properties();
386:                try {
387:                    m_Views.load(Thread.currentThread().getContextClassLoader()
388:                            .getResourceAsStream(
389:                                    "dtw/webmail/resources/views.properties"));
390:                    for (Iterator iter = m_Views.keySet().iterator(); iter
391:                            .hasNext();) {
392:                        String key = (String) iter.next();
393:                        log.debug(key + "=" + m_Views.get(key));
394:                    }
395:                } catch (IOException ex) {
396:                    log.error("prepareViewUrls()", ex);
397:                    return;
398:                }
399:                log.info(getLogMessage("jwma.kernel.prepared.vurls"));
400:            }//prepareViewUrls
401:
402:            /**
403:             * Returns the active <tt>JwmaConfiguration</tt>
404:             * instance.
405:             *
406:             * @return a <tt>JwmaConfiguration</tt> instance.
407:             */
408:            public JwmaConfiguration getConfiguration() {
409:                return m_Configuration;
410:            }//getConfiguration
411:
412:            /**
413:             * Returns the controller URL setting of the local
414:             * jwma installation.
415:             *
416:             * @return local controller's URL as <tt>String</tt>.
417:             */
418:            public String getMainControllerUrl() {
419:                return m_MainController;
420:            }//getMainControllerUrl
421:
422:            /**
423:             * Returns the sendmail controller URL setting of the local
424:             * jwma installation.
425:             *
426:             * @return local sendmail controller's URL as <tt>String</tt>.
427:             */
428:            public String getSendMailControllerUrl() {
429:                return m_MailingController;
430:            }//getSendMailControllerUrl
431:
432:            /**
433:             * Returns the admin controller URL setting of the local
434:             * jwma installation.
435:             *
436:             * @return local admin controller's URL as <tt>String</tt>.
437:             */
438:            public String getAdminControllerUrl() {
439:                return m_AdminController;
440:            }//getAdminControllerUrl
441:
442:            /**
443:             * Returns the contacts controller URL setting of the local
444:             * jwma installation.
445:             *
446:             * @return local contacts controller's URL as <tt>String</tt>.
447:             */
448:            public String getContactsControllerUrl() {
449:                return m_ContactsController;
450:            }//getContactsControllerUrl
451:
452:            /**
453:             * Returns the site's configured view URL for the given view
454:             * as <tt>String</tt>.
455:             *
456:             * <p>
457:             * The <tt>String</tt> parameter passed in <b>has to be</b>
458:             * one of the defined abstract view constants.
459:             *
460:             * @param view representing one of the constants defining an abstract
461:             *        view.
462:             *
463:             * @return local configured view URL of a given abstract view
464:             *         as <tt>String</tt>.
465:             *
466:             * @see #LOGIN_VIEW
467:             * @see #ERROR_VIEW
468:             * @see #LOGOUT_VIEW
469:             * @see #FOLDER_VIEW
470:             * @see #MESSAGE_VIEW
471:             * @see #PREFERENCES_VIEW
472:             * @see #COMPOSE_VIEW
473:             * @see #FIRSTTIME_VIEW
474:             * @see #CONTACTS_VIEW
475:             * @see #CONTACT_VIEW
476:             * @see #CONTACT_EDIT_VIEW
477:             * @see #CONTACTGROUP_VIEW
478:             * @see #CONTACTGROUP_EDIT_VIEW
479:             */
480:            public String getViewUrl(String view) {
481:                log.debug("getViewUrl():" + view + ":"
482:                        + m_Views.containsKey(view));
483:                return m_Views.getProperty(view);
484:            }//getViewUrl
485:
486:            /**
487:             * Returns the active and activated <tt>PreferencesPersistencePlugin</tt>
488:             * instance that provides the persistency related functionality.
489:             *
490:             * @see dtw.webmail.plugin.PreferencesPersistencePlugin
491:             */
492:            public PreferencesPersistencePlugin getPrefsPersistencePlugin() {
493:                return m_PrefsPersistencePlugin;
494:            }//getPrefsPersistencePlugin
495:
496:            /**
497:             * Returns the active and activated <tt>RandomAppendPlugin</tt>
498:             * instance that provides random appending functionality.
499:             * This method returns <tt>null</tt> if no such plugin is registered.
500:             *
501:             * @see dtw.webmail.plugin.RandomAppendPlugin
502:             */
503:            public RandomAppendPlugin getRandomAppendPlugin() {
504:                return m_RandomAppendPlugin;
505:            }//getRandomAppendPlugin
506:
507:            /**
508:             * Returns the active and activated <tt>ContactManagementPlugin</tt>
509:             * instance that provides contact management related functionality.
510:             *
511:             * @see dtw.webmail.plugin.ContactManagementPlugin
512:             */
513:            public ContactManagementPlugin getContactManagementPlugin() {
514:                return m_ContactManagementPlugin;
515:            }//getContactManagementPlugin
516:
517:            /**
518:             * Returns the class loader for i18n resource bundles.
519:             * <p>
520:             * @return the <tt>ClassLoader</tt> used for loading i18n <tt>ResourceBundle</tt>s.
521:             */
522:            public ClassLoader getResourceClassLoader() {
523:                return m_i18nLoader;
524:            }//getResourceClassLoader
525:
526:            /**
527:             * Returns the error message for the given key in the
528:             * set system locale.
529:             * <p>
530:             * @return the error message as localized <tt>String</tt>.
531:             */
532:            public String getErrorMessage(String key) {
533:                if (key == null) {
534:                    return "KEY NULL!!!!!!!!";
535:                }
536:                try {
537:                    return m_ErrorMessages.getString(key);
538:                } catch (MissingResourceException mrex) {
539:                    return ("#UNDEFINED=" + key + "#");
540:                }
541:            }//getErrorMessage
542:
543:            /**
544:             * Returns the log message for the given key in the
545:             * set system locale.
546:             * <p>
547:             * @return the log message as localized <tt>String</tt>.
548:             */
549:            public String getLogMessage(String key) {
550:                if (key == null) {
551:                    return "KEY NULL!!!!!!!!";
552:                }
553:                try {
554:                    return m_LogMessages.getString(key);
555:                } catch (MissingResourceException mrex) {
556:                    return ("#UNDEFINED=" + key + "#");
557:                }
558:            }//getLogMessage
559:
560:            /*** Administration *************************************************************/
561:
562:            /**
563:             * Tests if status is enabled.
564:             *
565:             * @return true if status is enabled, false otherwise.
566:             */
567:            public boolean isJwmaStatusEnabled() {
568:                return m_StatusEnabled;
569:            }//isJwmaStatusEnabled
570:
571:            /**
572:             * Sets the flag that controls if the system's status is
573:             * enabled.
574:             *
575:             * @param true if status is enabled, false otherwise.
576:             */
577:            public void setJwmaStatusEnabled(boolean enabled) {
578:                m_StatusEnabled = enabled;
579:            }//setJwmaStatusEnabled
580:
581:            /*** Status report related methods ***********************************************/
582:
583:            /**
584:             * Returns the kernel status as <tt>int</tt>.
585:             * <ol>
586:             * <li>Directories set</li>
587:             * <li>Settings loaded</li>
588:             * <li>Logs prepared</li>
589:             * <li>Loaded error messages</li>
590:             * <li>prepared preferences persistency</li>
591:             * <li>prepared text processing</li>
592:             * <li>prepared mail services</li>
593:             * <li>prepared view urls</li>
594:             * </ol>
595:             *
596:             * @return kernel status as <tt>int</tt>.
597:             */
598:            public int getKernelStatus() {
599:                return m_Diag;
600:            }//getDiagnostic
601:
602:            /**
603:             * Lists the directories jwma needs to access.
604:             *
605:             * @return array of strings representing the directories.
606:             */
607:            public String[] listDirectories() {
608:                String[] dirs = { m_RootDir, m_EtcDir, m_LogDir, m_DataDir };
609:                return dirs;
610:            }//listDirectories
611:
612:            /**
613:             * Returns the path of the given directory.
614:             */
615:            public String getDirectoryPath(int DIRECTORY) {
616:                switch (DIRECTORY) {
617:                case ROOT_DIR:
618:                    return m_RootDir;
619:                case ETC_DIR:
620:                    return m_EtcDir;
621:                case LOG_DIR:
622:                    return m_LogDir;
623:                case DATA_DIR:
624:                    return m_DataDir;
625:                default:
626:                    return null;
627:                }
628:            }//getDirectory
629:
630:            /**
631:             * Lists the files jwma needs to access.
632:             *
633:             * @return array of strings representing the files.
634:             */
635:            public String[] listFiles() {
636:                String[] files = new String[0];
637:                /*
638:                if (m_Diag<2) {
639:                  files=new String[1];
640:                  files[0]=m_Settings.getPath();
641:                } else {
642:                  //FILES:
643:                  //String[] lang=new String[m_ErrorResources.size()];
644:                  //lang=(String[]) m_ErrorResources.keySet().toArray(lang);
645:
646:                  files=new String[3+lang.length];
647:                  //settings file path
648:                  files[0]=m_Settings.getPath();
649:                  //log files
650:                  //files[1]=m_SyslogFile;
651:                  //files[2]=m_DebuglogFile;
652:
653:                  //mapping file
654:                  //files[3]=m_PreferencesMappingFile;
655:
656:                  //site preferences template
657:                  //files[4]=m_PreferencesTemplateFile;
658:
659:                  //3- error messages files
660:                  for (int i=0; i<lang.length; i++) {
661:                    files[3+i]=m_EtcDir+"errormessages_"+lang[i]+".properties";
662:
663:                  }
664:                }
665:                 */
666:                return files;
667:            }//listFiles
668:
669:            /*** End status report related methods *******************************************/
670:
671:            /*** Text processing related methods *********************************************/
672:
673:            /**
674:             * Returns the message processor indicated by the given
675:             * name. If the name does not refer to any processing pipe,
676:             * then the default processing pipe will be returned.
677:             *
678:             * @param name String that should represent a valid processing
679:             *        pipe name.
680:             * @return Processor to be used for message processing.
681:             */
682:            public Processor getMessageProcessor(String name) {
683:                //shortcut for null name
684:                if (name == null || name.length() == 0) {
685:                    return m_MessageProcessor;
686:                }
687:                //Try to get a pipe with the specified name
688:                Processor proc = m_ProcessingKernel.getProcessingPipe(name);
689:                if (proc == null) {
690:                    //try to get a processor with the specified name
691:                    proc = m_ProcessingKernel.getProcessor(name);
692:                    if (proc == null) {
693:                        //set the default processor
694:                        proc = m_MessageProcessor;
695:                    }
696:                }
697:                //return the pipe, the processor or the default
698:                return proc;
699:            }//getMessageProcessor
700:
701:            public String[] listMessageProcessors() {
702:                //return just processing pipes for now
703:                return m_ProcessingKernel.listProcessingPipes();
704:            }//listMessageProcessors
705:
706:            /*************************************************************************/
707:
708:            /**
709:             * Returns the reference of the JwmaKernel singleton
710:             * instance.
711:             *
712:             * <p>
713:             * <i><b>Note:</b>this also implements kind of a factory method pattern.
714:             * If the singleton instance does not exist yet, it will be created.</i>
715:             *
716:             * @return reference of the <tt>JwmaKernel</tt> singleton
717:             *         instance.
718:             *
719:             */
720:            public static JwmaKernel getReference() {
721:                if (c_Self != null) {
722:                    return c_Self;
723:                } else {
724:                    return new JwmaKernel();
725:                }
726:            }//getReference
727:
728:            /**
729:             * Defines the abstract login view.
730:             */
731:            public static final String LOGIN_VIEW = "view.login";
732:
733:            /**
734:             * Defines the abstract error view.
735:             */
736:            public static final String ERROR_VIEW = "view.error";
737:
738:            /**
739:             * Defines the abstract loggedout view.
740:             */
741:            public static final String LOGOUT_VIEW = "view.logout";
742:
743:            /**
744:             * Defines the abstract subscribe view.
745:             */
746:            public static final String SUBSCRIBED_VIEW = "view.subscribed";
747:
748:            /**
749:             * Defines the abstract unsubscribe view.
750:             */
751:            public static final String UNSUBSCRIBED_VIEW = "view.unsubscribed";
752:
753:            /**
754:             * Defines the abstract folder view.
755:             */
756:            public static final String FOLDER_VIEW = "view.folder";
757:
758:            /**
759:             * Defines the abstract mailbox view.
760:             */
761:            public static final String MAILBOX_VIEW = "view.mailbox";
762:
763:            /**
764:             * Defines the abstract message view.
765:             */
766:            public static final String MESSAGE_VIEW = "view.message";
767:
768:            /**
769:             * Defines the abstract compose view.
770:             */
771:            public static final String COMPOSE_VIEW = "view.compose";
772:
773:            /**
774:             * Defines the abstract preferences view.
775:             */
776:            public static final String PREFERENCES_VIEW = "view.preferences";
777:
778:            /**
779:             * Defines the abstract error firsttime view.
780:             */
781:            public static final String FIRSTTIME_VIEW = "view.firsttime";
782:
783:            /**
784:             * Defines the abstract contacts view.
785:             */
786:            public static final String CONTACTS_VIEW = "view.contacts";
787:
788:            /**
789:             * Defines the abstract contact view.
790:             */
791:            public static final String CONTACT_VIEW = "view.contact";
792:
793:            /**
794:             * Defines the abstract contact edit view.
795:             */
796:            public static final String CONTACT_EDIT_VIEW = "view.contact.edit";
797:
798:            /**
799:             * Defines the abstract contact group view.
800:             */
801:            public static final String CONTACTGROUP_VIEW = "view.contactgroup";
802:
803:            /**
804:             * Defines the abstract contact group edit view.
805:             */
806:            public static final String CONTACTGROUP_EDIT_VIEW = "view.contactgroup.edit";
807:
808:            /**
809:             * Defines the abstract admin status view.
810:             */
811:            public static final String ADMIN_STATUS_VIEW = "view.admin.status";
812:
813:            /**
814:             * Defines the abstract admin preferences view.
815:             */
816:            public static final String ADMIN_PREFERENCES_VIEW = "view.admin.preferences";
817:
818:            /**
819:             * Defines the abstract admin settings view.
820:             */
821:            public static final String ADMIN_SETTINGS_VIEW = "view.admin.settings";
822:
823:            /**
824:             * Defines the abstract admin login view.
825:             */
826:            public static final String ADMIN_LOGIN_VIEW = "view.admin.login";
827:
828:            /**
829:             * Defines the abstract admin menu view.
830:             */
831:            public static final String ADMIN_MENU_VIEW = "view.admin.menu";
832:
833:            /**
834:             * Defines the abstract admin error view.
835:             */
836:            public static final String ADMIN_ERROR_VIEW = "view.admin.error";
837:
838:            /**
839:             * Defines the abstract account creation view.
840:             */
841:            public static final String ACCOUNT_CREATION_VIEW = "view.account.creation";
842:
843:            /**
844:             * Defines the root directory.
845:             */
846:            public static final int ROOT_DIR = 1;
847:
848:            /**
849:             * Defines the root directory.
850:             */
851:            public static final int ETC_DIR = 2;
852:
853:            /**
854:             * Defines the root directory.
855:             */
856:            public static final int LOG_DIR = 3;
857:
858:            /**
859:             * Defines the data directory.
860:             */
861:            public static final int DATA_DIR = 4;
862:
863:        }//JwmaKernel
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.