Source Code Cross Referenced for SessionProviderFactory.java in  » Net » j2ssh » com » sshtools » common » ui » 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 » Net » j2ssh » com.sshtools.common.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  SSHTools - Java SSH2 API
003:         *
004:         *  Copyright (C) 2002-2003 Lee David Painter and Contributors.
005:         *
006:         *  Contributions made by:
007:         *
008:         *  Brett Smith
009:         *  Richard Pernavas
010:         *  Erwin Bolwidt
011:         *
012:         *  This program is free software; you can redistribute it and/or
013:         *  modify it under the terms of the GNU General Public License
014:         *  as published by the Free Software Foundation; either version 2
015:         *  of the License, or (at your option) any later version.
016:         *
017:         *  This program is distributed in the hope that it will be useful,
018:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
019:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
020:         *  GNU General Public License for more details.
021:         *
022:         *  You should have received a copy of the GNU General Public License
023:         *  along with this program; if not, write to the Free Software
024:         *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
025:         */
026:        package com.sshtools.common.ui;
027:
028:        import com.sshtools.j2ssh.configuration.ConfigurationLoader;
029:        import com.sshtools.j2ssh.io.IOUtil;
030:        import com.sshtools.j2ssh.util.ExtensionClassLoader;
031:
032:        import org.apache.commons.logging.Log;
033:        import org.apache.commons.logging.LogFactory;
034:
035:        import java.io.IOException;
036:        import java.io.InputStream;
037:
038:        import java.net.URL;
039:
040:        import java.util.Enumeration;
041:        import java.util.HashMap;
042:        import java.util.List;
043:        import java.util.Properties;
044:        import java.util.Vector;
045:
046:        /**
047:         *
048:         * <p>This class is responsible for dynamically loading all the installed
049:         * session providers. A session provider can be used with
050:         * <code>SessionProviderFrame</code> to integrate an ssh service such as
051:         * a terminal window or sftp window within another application.</p>
052:         *
053:         * <p>To install a session provider you should provide a special properties
054:         * file resource at the root of your source tree called 'session.provider'.</p>
055:         *
056:         * <blockquote><pre>
057:         * This properties file should have the following properties defined:
058:         *
059:         * provider.id= [The unique name of the provider e.g 'sshterm']
060:         * provider.name= [The descriptive name of the provider e.g. 'Terminal Session']
061:         * provider.class= [Fully qualified classname of the provider implementation]
062:         * provider.shortdesc= [A short description of the provider]
063:         * provider.smallicon= [The providers small icon, must be filename only and be
064:         * placed in the same package as the provider class implementation]
065:         * provider.largeicon= [The providers large icon, must be filename only and be
066:         * placed in the same package as the provider class implementation]
067:         * provider.mnemonic= [The mnemonic character]
068:         * provider.options= [The options panel implementation, must implement
069:         * com.sshtools.common.ui.OptionsTab]
070:         * property.page.1= [An number of property page panels, must implement
071:         * com.sshtools.common.ui.SshToolsConnectionTab]
072:         * property.page.2= [More property pages added like this]
073:         * provider.weight= [Weight setting, used to order providers]
074:         * </pre></blockquote>
075:         *
076:         * </p>
077:         * @author Lee David Painter
078:         * @version $Id: SessionProviderFactory.java,v 1.12 2003/09/22 15:57:57 martianx Exp $
079:         */
080:        public class SessionProviderFactory {
081:            private static Log log = LogFactory
082:                    .getLog(SessionProviderFactory.class);
083:            private static SessionProviderFactory instance;
084:            HashMap providers = new HashMap();
085:
086:            SessionProviderFactory() {
087:                ExtensionClassLoader classloader = ConfigurationLoader
088:                        .getExtensionClassLoader();
089:
090:                try {
091:                    Enumeration en = classloader
092:                            .getResources("session.provider");
093:                    URL url = null;
094:                    Properties properties;
095:                    InputStream in;
096:                    SessionProvider provider;
097:                    String name;
098:                    String id;
099:
100:                    while (en.hasMoreElements()) {
101:                        try {
102:                            url = (URL) en.nextElement();
103:                            in = url.openStream();
104:                            properties = new Properties();
105:                            properties.load(in);
106:                            IOUtil.closeStream(in);
107:
108:                            if (properties.containsKey("provider.class")
109:                                    && properties.containsKey("provider.name")) {
110:                                Class cls = classloader.loadClass(properties
111:                                        .getProperty("provider.class"));
112:                                String optionsClassName = properties
113:                                        .getProperty("provider.options");
114:                                Class optionsClass = ((optionsClassName == null) || optionsClassName
115:                                        .equals("")) ? null : classloader
116:                                        .loadClass(optionsClassName);
117:                                String pageclass;
118:                                int num = 1;
119:                                Vector pages = new Vector();
120:
121:                                do {
122:                                    pageclass = properties
123:                                            .getProperty("property.page."
124:                                                    + String.valueOf(num), null);
125:
126:                                    if (pageclass != null) {
127:                                        pages.add(classloader
128:                                                .loadClass(pageclass));
129:                                        num++;
130:                                    }
131:                                } while (pageclass != null);
132:
133:                                Class[] propertypages = new Class[pages.size()];
134:                                pages.toArray(propertypages);
135:                                name = properties.getProperty("provider.name");
136:
137:                                int weight = Integer.parseInt(properties
138:                                        .getProperty("provider.weight"));
139:                                id = properties
140:                                        .getProperty("provider.id", name);
141:                                provider = new SessionProvider(
142:                                        id,
143:                                        name,
144:                                        cls,
145:                                        properties
146:                                                .getProperty("provider.shortdesc"),
147:                                        properties
148:                                                .getProperty("provider.mnemonic"),
149:                                        properties
150:                                                .getProperty("provider.smallicon"),
151:                                        properties
152:                                                .getProperty("provider.largeicon"),
153:                                        optionsClass, propertypages, weight);
154:                                providers.put(id, provider);
155:                                log.info("Installed " + provider.getName()
156:                                        + " session provider");
157:                            }
158:                        } catch (ClassNotFoundException ex) {
159:                            log.warn("Session provider class not found", ex);
160:                        } catch (IOException ex) {
161:                            log.warn("Failed to read " + url.toExternalForm(),
162:                                    ex);
163:                        }
164:                    }
165:                } catch (IOException ex) {
166:                }
167:            }
168:
169:            /**
170:             * Get all the installed SessionProvider's.
171:             *
172:             * @return A list containing instances of <code>SessionProvider</code>
173:             */
174:            public List getSessionProviders() {
175:                return new Vector(providers.values());
176:            }
177:
178:            /**
179:             * <p>Get a <code>SessionProvider</code> by its id. The id is defined by the
180:             * provider.id property in the providers 'session.provider' resource file.</p>
181:             *
182:             * <p>Session providers that are currently defined within the SSHTools source
183:             * tree are:<br>
184:             * <blockquote><pre>
185:             * sshterm   - Terminal session provider
186:             * shift     - SFTP session provider
187:             * tunneling - Secure port forwarding provider
188:             * sshvnc    - VNC session provider
189:             * </pre></blockquote>
190:             *
191:             * @param id the id of the SessionProvider.
192:             * @return
193:             */
194:            public SessionProvider getProvider(String id) {
195:                return (SessionProvider) providers.get(id);
196:            }
197:
198:            /**
199:             * Get the one time instance of the factory.
200:             * @return
201:             */
202:            public static SessionProviderFactory getInstance() {
203:                return (instance == null) ? (instance = new SessionProviderFactory())
204:                        : instance;
205:            }
206:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.