From 231c94ae0be37b163c04b3b76f59ad11e09e61d8 Mon Sep 17 00:00:00 2001 From: elias Date: Fri, 14 Jul 2006 08:31:27 +0000 Subject: Made the core classes and the linux plugin applet compatible. Removed dead code in DefaultControllerEnvironment git-svn-id: file:///home/sven/projects/JOGL/git-svn/svn-server-sync/jinput/trunk@153 e343933a-64c8-49c5-92b1-88f2ce3e89e8 --- .../games/input/DefaultControllerEnvironment.java | 130 ++++----------------- 1 file changed, 25 insertions(+), 105 deletions(-) (limited to 'coreAPI/src') diff --git a/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java b/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java index 9507bd2..544562a 100644 --- a/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java +++ b/coreAPI/src/java/net/java/games/input/DefaultControllerEnvironment.java @@ -57,20 +57,6 @@ import net.java.games.util.plugins.*; * @author Michael Martak */ class DefaultControllerEnvironment extends ControllerEnvironment { - static final boolean DEBUG =false; - /** - * The name of the properties file to find plugins. - */ - private final static String PROPERTY_FILENAME = - "controller.properties"; - - /** - * The name of the property for identifying a plugin (used - * as the value, the key being the class name). - */ - private final static String ID_PLUGIN = - "ControllerEnvironment"; - /** * Location of the LIB directory. */ @@ -81,16 +67,6 @@ class DefaultControllerEnvironment extends ControllerEnvironment { */ private ArrayList controllers; - /** - * Plug-in properties. - */ - private Properties properties = new Properties(); - - /** - * Plug-in class loader. - */ - private PluginClassLoader pluginLoader = new PluginClassLoader(); - private Collection loadedPlugins = new ArrayList(); /** @@ -120,6 +96,22 @@ class DefaultControllerEnvironment extends ControllerEnvironment { public DefaultControllerEnvironment() { } + private static String getPrivilegedProperty(final String property) { + return (String)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty(property); + } + }); + } + + private static String getPrivilegedProperty(final String property, final String default_value) { + return (String)AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty(property, default_value); + } + }); + } + /** * Returns a list of all controllers available to this environment, * or an empty array if there are no controllers in this environment. @@ -131,13 +123,13 @@ class DefaultControllerEnvironment extends ControllerEnvironment { AccessController.doPrivileged(new PrivilegedAction() { public Object run() { scanControllers(); - return DefaultControllerEnvironment.this; + return null; } }); //Check the properties for specified controller classes - String pluginClasses = System.getProperty("jinput.plugins", "") + " " + System.getProperty("net.java.games.input.plugins", ""); - if(!System.getProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !System.getProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) { - String osName = System.getProperty("os.name", "").trim(); + String pluginClasses = getPrivilegedProperty("jinput.plugins", "") + " " + getPrivilegedProperty("net.java.games.input.plugins", ""); + if(!getPrivilegedProperty("jinput.useDefaultPlugin", "true").toLowerCase().trim().equals("false") && !getPrivilegedProperty("net.java.games.input.useDefaultPlugin", "true").toLowerCase().trim().equals("false")) { + String osName = getPrivilegedProperty("os.name", "").trim(); if(osName.equals("Linux")) { pluginClasses = pluginClasses + " net.java.games.input.LinuxEnvironmentPlugin"; } else if(osName.equals("Mac OS X")) { @@ -180,53 +172,16 @@ class DefaultControllerEnvironment extends ControllerEnvironment { return ret; } - /** - * Scans for controllers, placing them in the controllers list. - */ - /* This is Mike's old plugin code. - private void scanControllers() { - // Load properties object. - try { - loadProperties(); - } catch (IOException e) { - // Could not find or read file, simply return. - return; - } - // Create a list of ControllerEnvironment classes. - // For each ControllerEnvironment, locate the class - // using the plugin class loader. - Iterator it = properties.keySet().iterator(); - while (it.hasNext()) { - Object key = it.next(); - assert key != null; - Object value = properties.get(key); - assert value != null; - if (value.equals(ID_PLUGIN)) { - try { - ControllerEnvironment plugin = - newPlugin(key.toString()); - addControllers(plugin.getControllers()); - } catch (Throwable t) { - System.err.println( - "Warning : could not load plugin " + - key.toString() + ", received exeption " + - t.toString()); - t.printStackTrace(System.err); - } - } - } - }*/ - /* This is jeff's new plugin code using Jeff's Plugin manager */ private void scanControllers() { - String pluginPathName = System.getProperty("jinput.controllerPluginPath"); + String pluginPathName = getPrivilegedProperty("jinput.controllerPluginPath"); if(pluginPathName == null) { pluginPathName = "controller"; } - scanControllersAt(System.getProperty("java.home") + + scanControllersAt(getPrivilegedProperty("java.home") + File.separator + "lib"+File.separator + pluginPathName); - scanControllersAt(System.getProperty("user.dir")+ + scanControllersAt(getPrivilegedProperty("user.dir")+ File.separator + pluginPathName); } @@ -240,13 +195,11 @@ class DefaultControllerEnvironment extends ControllerEnvironment { Class[] envClasses = plugins.getExtends(ControllerEnvironment.class); for(int i=0;i