Source Code Cross Referenced for SessionController.java in  » Mail-Clients » columba-1.4 » org » columba » core » main » 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 » Mail Clients » columba 1.4 » org.columba.core.main 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //The contents of this file are subject to the Mozilla Public License Version 1.1
002:        //(the "License"); you may not use this file except in compliance with the 
003:        //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004:        //
005:        //Software distributed under the License is distributed on an "AS IS" basis,
006:        //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
007:        //for the specific language governing rights and
008:        //limitations under the License.
009:        //
010:        //The Original Code is "The Columba Project"
011:        //
012:        //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013:        //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003. 
014:        //
015:        //All Rights Reserved.
016:
017:        package org.columba.core.main;
018:
019:        import java.io.BufferedReader;
020:        import java.io.BufferedWriter;
021:        import java.io.File;
022:        import java.io.FileReader;
023:        import java.io.FileWriter;
024:        import java.io.IOException;
025:
026:        import javax.swing.JOptionPane;
027:
028:        import org.columba.api.exception.AuthenticationException;
029:        import org.columba.core.config.Config;
030:        import org.columba.core.resourceloader.GlobalResourceLoader;
031:
032:        /**
033:         * Contains the logic necessary to search for running Columba sessions and
034:         * pass command line arguments to it or to start a new session.
035:         */
036:        public class SessionController {
037:
038:            /**
039:             * Tries to connect to a running ColumbaServer using a new ColumbaClient.
040:             * If this works, the given command line arguments are passed to the
041:             * running server and the startup process is terminated.
042:             * If this doesn't work, a new ColumbaServer instance is created and
043:             * the startup process isn't terminated.
044:             */
045:            public static void passToRunningSessionAndExit(String[] args) {
046:                //create new client and try to connect to server
047:                ColumbaClient client = new ColumbaClient();
048:
049:                try {
050:                    client.connect();
051:                    client.sendCommandLine(args);
052:                    System.exit(5);
053:                } catch (IOException ioe1) {
054:                    //no server running, start our own
055:                    try {
056:                        ColumbaServer.getColumbaServer().start();
057:                    } catch (IOException ioe2) {
058:                        ioe2.printStackTrace();
059:                        //display error message
060:                        System.exit(1);
061:                    }
062:                } catch (AuthenticationException ae) {
063:                    JOptionPane.showMessageDialog(null, GlobalResourceLoader
064:                            .getString(ColumbaServer.RESOURCE_PATH, "session",
065:                                    "err_auth_msg"), GlobalResourceLoader
066:                            .getString(ColumbaServer.RESOURCE_PATH, "session",
067:                                    "err_auth_title"),
068:                            JOptionPane.ERROR_MESSAGE);
069:                    System.exit(5);
070:                } finally {
071:                    client.close();
072:                }
073:            }
074:
075:            /**
076:             * Reads a stored port number from the file ".auth" in the config directory.
077:             */
078:            protected static int deserializePortNumber() throws IOException {
079:                File file = new File(Config.getInstance().getConfigDirectory(),
080:                        ".auth");
081:                BufferedReader reader = null;
082:
083:                try {
084:                    reader = new BufferedReader(new FileReader(file));
085:
086:                    String line = reader.readLine();
087:
088:                    return Integer.parseInt(line);
089:                } catch (NumberFormatException nfe) {
090:                    IOException ioe = new IOException();
091:                    ioe.initCause(nfe);
092:                    throw ioe;
093:                } finally {
094:                    if (reader != null) {
095:                        reader.close();
096:                    }
097:                }
098:            }
099:
100:            /**
101:             * Stores the given port number in the file ".auth" in the config directory.
102:             * If the passed port number is -1, the existing file is deleted.
103:             */
104:            protected static void serializePortNumber(int port)
105:                    throws IOException {
106:                File file = new File(Config.getInstance().getConfigDirectory(),
107:                        ".auth");
108:
109:                if (port == -1) {
110:                    file.delete();
111:                } else {
112:                    BufferedWriter writer = null;
113:
114:                    try {
115:                        writer = new BufferedWriter(new FileWriter(file));
116:                        writer.write(Integer.toString(port));
117:                        writer.newLine();
118:                    } finally {
119:                        if (writer != null) {
120:                            writer.close();
121:                        }
122:                    }
123:                }
124:            }
125:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.