aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/net
diff options
context:
space:
mode:
authorjeffpk <[email protected]>2003-06-26 00:06:25 +0000
committerjeffpk <[email protected]>2003-06-26 00:06:25 +0000
commit7c855cd9e9fc34c5387ea121653fac1a1461d388 (patch)
treeb9136c62dea0302c6fdcd3fd93759f6566e82e5e /src/java/net
parent875c9f608e147e91840e8722e7a60c91cdbe84b7 (diff)
Improved plugin scanning so that if you attempt to create a Plugins instance with a
non-existant plugins directory path, it throws an IO exception. git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jutils/trunk@9 052365b4-98e0-4bc5-a281-465471b020e0
Diffstat (limited to 'src/java/net')
-rw-r--r--src/java/net/java/games/util/plugins/Plugins.java10
-rw-r--r--src/java/net/java/games/util/plugins/test/PluginTest.java9
2 files changed, 15 insertions, 4 deletions
diff --git a/src/java/net/java/games/util/plugins/Plugins.java b/src/java/net/java/games/util/plugins/Plugins.java
index 7a7e5f4..87e6146 100644
--- a/src/java/net/java/games/util/plugins/Plugins.java
+++ b/src/java/net/java/games/util/plugins/Plugins.java
@@ -69,12 +69,16 @@ public class Plugins {
* @param pluginRoot The root od the directory tree to scan for Jars
* containing plugins.
*/
- public Plugins(File pluginRoot) {
- scanPlugins(pluginRoot);
+ public Plugins(File pluginRoot) throws IOException {
+ scanPlugins(pluginRoot);
}
- private void scanPlugins(File dir) {
+ private void scanPlugins(File dir) throws IOException {
File[] files = dir.listFiles();
+ if (files == null) {
+ throw new FileNotFoundException("Plugin directory "+dir.getName()+
+ " not found.");
+ }
for(int i=0;i<files.length;i++){
File f = files[i];
if (f.getName().endsWith(".jar")) { // process JAR file
diff --git a/src/java/net/java/games/util/plugins/test/PluginTest.java b/src/java/net/java/games/util/plugins/test/PluginTest.java
index a5ea39d..af7ef82 100644
--- a/src/java/net/java/games/util/plugins/test/PluginTest.java
+++ b/src/java/net/java/games/util/plugins/test/PluginTest.java
@@ -82,11 +82,18 @@ class ListUpdater implements Runnable{
public class PluginTest {
static final boolean DEBUG = false;
- Plugins plugins = new Plugins(new File("test_plugins"));
+
+ Plugins plugins;
JList plist;
Class[] piList; // holder for current list of plugins
/** Creates a new instance of PluginTest */
public PluginTest() {
+ try {
+ plugins = new Plugins(new File("test_plugins"));
+ } catch (IOException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
JFrame f = new JFrame("PluginTest");
plist = new JList(new DefaultListModel());
plist.setCellRenderer(new ClassRenderer());