• R/O
  • SSH
  • HTTPS

chaplet: 提交


Commit MetaInfo

修訂32 (tree)
時間2007-06-29 08:00:29
作者koe

Log Message

plugin.xmlからのプラグインのロードを実装。選択的に使用できるものとする。

Change Summary

差異

--- chaplet/trunk/resource/plugin.xml (nonexistent)
+++ chaplet/trunk/resource/plugin.xml (revision 32)
@@ -0,0 +1,43 @@
1+<?xml version="1.0" encoding="UTF-8"?>
2+<java version="1.6.0_01" class="java.beans.XMLDecoder">
3+ <array class="jp.sf.chaplet.PluginProfile" length="2">
4+ <void index="0">
5+ <object class="jp.sf.chaplet.PluginProfile">
6+ <void property="clientName">
7+ <string>jp.sf.chaplet.dx.client.DxClientPlugin</string>
8+ </void>
9+ <void property="pluginId">
10+ <string>jp.sf.chaplet.dx</string>
11+ </void>
12+ <void property="primary">
13+ <boolean>true</boolean>
14+ </void>
15+ <void property="serverName">
16+ <string>jp.sf.chaplet.dx.server.DxServerPlugin</string>
17+ </void>
18+ <void property="version">
19+ <string>1.0</string>
20+ </void>
21+ </object>
22+ </void>
23+ <void index="1">
24+ <object class="jp.sf.chaplet.PluginProfile">
25+ <void property="clientName">
26+ <string>jp.sf.chaplet.nova.client.NovaClientPlugin</string>
27+ </void>
28+ <void property="pluginId">
29+ <string>jp.sf.chaplet.nova</string>
30+ </void>
31+ <void property="primary">
32+ <boolean>true</boolean>
33+ </void>
34+ <void property="serverName">
35+ <string>jp.sf.chaplet.nova.server.NovaServerPlugin</string>
36+ </void>
37+ <void property="version">
38+ <string>1.0</string>
39+ </void>
40+ </object>
41+ </void>
42+ </array>
43+</java>
--- chaplet/trunk/src/conf/jp/sf/chaplet/conf/PluginConfEncoder.java (nonexistent)
+++ chaplet/trunk/src/conf/jp/sf/chaplet/conf/PluginConfEncoder.java (revision 32)
@@ -0,0 +1,24 @@
1+/**
2+ *
3+ */
4+package jp.sf.chaplet.conf;
5+
6+import java.beans.XMLEncoder;
7+
8+import jp.sf.chaplet.PluginProfile;
9+
10+/**
11+ * PluginConfEncoder<br>
12+ * @version $Id$
13+ */
14+public class PluginConfEncoder {
15+ public static void main(String[] args) {
16+ PluginProfile[] profiles = new PluginProfile[2];
17+ profiles[0] = new PluginProfile("jp.sf.chaplet.dx", "1.0", "jp.sf.chaplet.dx.client.DxClientPlugin", "jp.sf.chaplet.dx.server.DxServerPlugin", true);
18+ profiles[1] = new PluginProfile("jp.sf.chaplet.nova", "1.0", "jp.sf.chaplet.nova.client.NovaClientPlugin", "jp.sf.chaplet.nova.server.NovaServerPlugin", true);
19+ XMLEncoder encoder = new XMLEncoder(System.out);
20+ encoder.writeObject(profiles);
21+ encoder.flush();
22+ encoder.close();
23+ }
24+}
Added: svn:keywords
## -0,0 +1 ##
+" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/core/jp/sf/chaplet/PluginProfile.java (nonexistent)
+++ chaplet/trunk/src/core/jp/sf/chaplet/PluginProfile.java (revision 32)
@@ -0,0 +1,74 @@
1+/**
2+ *
3+ */
4+package jp.sf.chaplet;
5+
6+/**
7+ * PluginProfile<br>
8+ *
9+ * @version $Id$
10+ */
11+public class PluginProfile {
12+ private String pluginId;
13+
14+ private String version;
15+
16+ private String clientName;
17+
18+ private String serverName;
19+
20+ private boolean primary;
21+
22+ public PluginProfile() {
23+ }
24+
25+ public PluginProfile(String pluginId, String version, String clientName, String serverName,
26+ boolean primary) {
27+ super();
28+ this.pluginId = pluginId;
29+ this.version = version;
30+ this.clientName = clientName;
31+ this.serverName = serverName;
32+ this.primary = primary;
33+ }
34+
35+ public String getClientName() {
36+ return clientName;
37+ }
38+
39+ public void setClientName(String clientName) {
40+ this.clientName = clientName;
41+ }
42+
43+ public String getPluginId() {
44+ return pluginId;
45+ }
46+
47+ public void setPluginId(String pluginId) {
48+ this.pluginId = pluginId;
49+ }
50+
51+ public String getServerName() {
52+ return serverName;
53+ }
54+
55+ public void setServerName(String serverName) {
56+ this.serverName = serverName;
57+ }
58+
59+ public String getVersion() {
60+ return version;
61+ }
62+
63+ public void setVersion(String version) {
64+ this.version = version;
65+ }
66+
67+ public boolean isPrimary() {
68+ return primary;
69+ }
70+
71+ public void setPrimary(boolean primary) {
72+ this.primary = primary;
73+ }
74+}
Added: svn:keywords
## -0,0 +1 ##
+" Date Revision Author HeadURL Id "
\ No newline at end of property
--- chaplet/trunk/src/core/jp/sf/chaplet/ConfigLoader.java (revision 31)
+++ chaplet/trunk/src/core/jp/sf/chaplet/ConfigLoader.java (revision 32)
@@ -5,6 +5,7 @@
55 */
66 package jp.sf.chaplet;
77
8+import java.beans.XMLDecoder;
89 import java.io.File;
910 import java.io.FileInputStream;
1011 import java.io.FileNotFoundException;
@@ -199,6 +200,11 @@
199200
200201 ArrayList<Plugin> loadPlugins(){
201202 ArrayList<Plugin> list = new ArrayList<Plugin>();
203+ if(loadPluginsFromXml(list) == true){
204+ // plugin.xmlからの読み取りに成功したらそれで終了。
205+ return list;
206+ }
207+
202208 // システムプロパティjava.ext.dirsに、プラグインjarがあるとする
203209 String dirName = System.getProperty("java.ext.dirs", System.getProperty("user.dir"));
204210 // java.ext.dirsに複数のパスが指定されている場合、先頭のものを使用する
@@ -235,6 +241,20 @@
235241 }
236242 return list;
237243 }
244+
245+ private boolean loadPluginsFromXml(ArrayList<Plugin> list){
246+ InputStream in = getClass().getResourceAsStream("/plugin.xml");
247+ if(in == null){
248+ return false;
249+ }
250+ XMLDecoder decoder = new XMLDecoder(in);
251+ PluginProfile[] profiles = (PluginProfile[]) decoder.readObject();
252+ for (PluginProfile profile : profiles) {
253+ Plugin plugin = new Plugin(profile.getPluginId(), profile.getVersion(), profile.getServerName(), profile.getClientName(), profile.isPrimary());
254+ list.add(plugin);
255+ }
256+ return true;
257+ }
238258
239259 /**
240260 * プラグインオブジェクトをインスタンス化する。
Show on old repository browser