Source Code Cross Referenced for Plugin.java in  » Swing-Library » OpenJX » org » openjx » conf » 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 » Swing Library » OpenJX » org.openjx.conf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2007 Jared Alexander Spigner
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
017:         *
018:         * jspigner@openjx.org
019:         *
020:         * Plugin.java
021:         *
022:         * Created on June 8, 2007, 12:12 AM
023:         *
024:         */
025:
026:        package org.openjx.conf;
027:
028:        import java.io.BufferedInputStream;
029:        import java.io.IOException;
030:
031:        import java.net.MalformedURLException;
032:        import java.net.URL;
033:
034:        import java.util.Enumeration;
035:        import java.util.Properties;
036:
037:        import javax.swing.JOptionPane;
038:
039:        import org.openjx.display.JXMessageBox;
040:
041:        import org.openjx.core.VirtualMachine;
042:
043:        /**
044:         * This class is used to hold data about a given plugin.
045:         *
046:         * @author Jared Spigner
047:         */
048:        public class Plugin {
049:            /** This is the url of the plugin. */
050:            private String pluginURL;
051:
052:            /** This is the complete url to the jar file which contains the plugin. */
053:            private String pluginJar;
054:
055:            /** This is the name of the plugin. */
056:            private String pluginName;
057:
058:            /** This is the name of the plugin schema. */
059:            private String pluginSchema;
060:
061:            /** 
062:             * True if this plugin is a control, false if it is simply an addition to
063:             * the classpath.
064:             */
065:            private boolean pluginControl;
066:
067:            /** 
068:             * This is the constructor for the Plugin class.  It creates a new 
069:             * instance of Plugin. 
070:             */
071:            public Plugin() {
072:                this .setPluginJar("");
073:                this .setPluginURL("");
074:                this .setPluginName("");
075:                this .setPluginSchema("");
076:                this .setPluginControl(false);
077:            }
078:
079:            /** 
080:             * This is the constructor for the Plugin class.  It creates a new 
081:             * instance of Plugin. 
082:             *
083:             * @param jar is the jar we want to set.
084:             * @param name is the name of the plugin.
085:             */
086:            public Plugin(String jar, String name) {
087:                this .setPluginJar(jar);
088:                this .setPluginURL(jar.substring(0, jar.length()
089:                        - (name.length() + 4)));
090:                this .setPluginName(name);
091:            }
092:
093:            /**
094:             * This method configures the plugin, by searching for a configuration file
095:             * and applying the attributes.
096:             *
097:             * @param vm is a reference to the Virtual Machine.
098:             *
099:             * @return true on success, else false on failure.
100:             */
101:            public boolean configurePlugin(VirtualMachine vm) {
102:                BufferedInputStream bis = null;
103:
104:                try {
105:                    /** This means it is just a classpath enhancement. */
106:                    if (getClass().getResourceAsStream(
107:                            "/" + this .getPluginName() + ".properties") == null)
108:                        return true;
109:
110:                    Properties prop = new Properties();
111:                    prop.load(getClass().getResourceAsStream(
112:                            "/" + this .getPluginName() + ".properties"));
113:
114:                    String value = prop.getProperty("schema", "");
115:
116:                    if (value.equals("")) {
117:                        this .setPluginControl(false);
118:                        return true;
119:                    }
120:
121:                    this .setPluginControl(true);
122:
123:                    this .setPluginSchema(value);
124:                } catch (IOException e) {
125:                    new JXMessageBox(JOptionPane.ERROR_MESSAGE,
126:                            "Configure Plugin Failure", "" + e, vm.getViewer());
127:                    return false;
128:                }
129:
130:                return true;
131:            }
132:
133:            /**
134:             * This method gets the plugin control value.
135:             *
136:             * @return true if it is a control, else false.
137:             */
138:            public boolean getPluginControl() {
139:                return this .pluginControl;
140:            }
141:
142:            /**
143:             * This method gets the plugin jar file.
144:             *
145:             * @return the complete url to the plugin jar file.
146:             */
147:            public String getPluginJar() {
148:                return this .pluginJar;
149:            }
150:
151:            /**
152:             * This method gets the plugin name.
153:             *
154:             * @return the plugin name.
155:             */
156:            public String getPluginName() {
157:                return this .pluginName;
158:            }
159:
160:            /**
161:             * This method gets the plugin schema.
162:             *
163:             * @return the plugin schema.
164:             */
165:            public String getPluginSchema() {
166:                return this .pluginSchema;
167:            }
168:
169:            /**
170:             * This method gets the plugin url.
171:             *
172:             * @return the plugin url.
173:             */
174:            public String getPluginURL() {
175:                return this .pluginURL;
176:            }
177:
178:            /**
179:             * This method installs this plugin into the classpath of the OpenJX
180:             * application.
181:             *
182:             * @param vm is a reference to the Virtual Machine.
183:             *
184:             * @return true on success, else false on failure.
185:             */
186:            public boolean installPlugin(VirtualMachine vm) {
187:                try {
188:                    vm.jxPluginLoader.addURL(new URL(this .getPluginJar()), vm
189:                            .getViewer());
190:                } catch (MalformedURLException e) {
191:                    new JXMessageBox(JOptionPane.ERROR_MESSAGE,
192:                            "Plugin Failure", "" + e, vm.getViewer());
193:                    return false;
194:                }
195:
196:                return true;
197:            }
198:
199:            /**
200:             * This method sets the plugin control state.
201:             *
202:             * @param state of the plugin control (true/control, false/no control).
203:             */
204:            public void setPluginControl(boolean state) {
205:                this .pluginControl = state;
206:            }
207:
208:            /**
209:             * This method sets the plugin jar file.
210:             *
211:             * @param jar is the complete url to the plugin jar file.
212:             */
213:            public void setPluginJar(String jar) {
214:                this .pluginJar = jar;
215:            }
216:
217:            /**
218:             * This method sets the plugin name.
219:             *
220:             * @param name is the name of the plugin.
221:             */
222:            public void setPluginName(String name) {
223:                this .pluginName = name;
224:            }
225:
226:            /**
227:             * This method sets the plugin schema.
228:             *
229:             * @param schema is the name of the schema.
230:             */
231:            public void setPluginSchema(String schema) {
232:                this .pluginSchema = schema;
233:            }
234:
235:            /**
236:             * This method sets the plugin url.
237:             *
238:             * @param url is the url of the plugin.
239:             */
240:            public void setPluginURL(String url) {
241:                this.pluginURL = url;
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.