diff options
author | paulby <[email protected]> | 2004-11-03 00:20:45 +0000 |
---|---|---|
committer | paulby <[email protected]> | 2004-11-03 00:20:45 +0000 |
commit | 9fa6433d10c8454fae5e0d13c61b2fcea7d83b62 (patch) | |
tree | fd64ff2be4bdf5c2a60b5559014525bb714bf185 /src | |
parent | fd7a5d9bd062121732611b6e8a435b24566e64f5 (diff) |
Fix for issue #38, ConfiguredUniverse throws an exception when using Java Web Start
Issue number:
Obtained from:
Submitted by:
Reviewed by:
git-svn-id: https://svn.java.net/svn/j3d-core-utils~svn/trunk@29 9497e636-51bd-65ba-982d-a4982e1767a5
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java | 50 | ||||
-rw-r--r-- | src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java | 16 |
2 files changed, 65 insertions, 1 deletions
diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java index acbc984..739b6ee 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigContainer.java @@ -120,6 +120,8 @@ public class ConfigContainer { // The visibility status of Viewer AWT components. private boolean setVisible = false ; + + private ClassLoader classLoader = ClassLoader.getSystemClassLoader(); /** * The name of the file this ConfigContainer is currently loading. @@ -139,6 +141,19 @@ public class ConfigContainer { /** * Creates a new ConfigContainer and loads the configuration file at the + * specified URL. All ViewingPlatform instances are created with a single + * TransformGroup and all Viewer components are initially invisible. + * + * @param userConfig URL of the configuration file to load + * @param classLoader the class loader to use to load classes specified + * in the config file. + */ + public ConfigContainer(URL userConfig, ClassLoader classLoader) { + this(userConfig, false, 1, true, classLoader) ; + } + + /** + * Creates a new ConfigContainer and loads the configuration file at the * specified URL. Any ViewingPlatform instantiated by the configuration * file will be created with the specified number of transforms. Viewer * components may be set initially visible or invisible with the @@ -157,6 +172,28 @@ public class ConfigContainer { } /** + * Creates a new ConfigContainer and loads the configuration file at the + * specified URL. Any ViewingPlatform instantiated by the configuration + * file will be created with the specified number of transforms. Viewer + * components may be set initially visible or invisible with the + * <code>setVisible</code> flag. + * + * @param userConfig URL of the configuration file to load + * @param setVisible if true, <code>setVisible(true)</code> is called on + * all Viewers + * @param transformCount number of transforms to be included in any + * ViewingPlatform created; must be greater than 0 + * @param classLoader the class loader to use to load classes specified + * in the config file. + */ + public ConfigContainer(URL userConfig, + boolean setVisible, int transformCount, + ClassLoader classLoader) { + + this(userConfig, setVisible, transformCount, true, classLoader) ; + } + + /** * Package-scoped constructor for ConfigContainer. This provides an * additional flag, <code>attachBehaviors</code>, which indicates whether * or not ViewPlatformBehaviors should be attached to the ViewingPlatforms @@ -199,6 +236,18 @@ public class ConfigContainer { } /** + * Package scoped constructor that adds the ability to set the ClassLoader + * which will be used to load any app specific classes specified in the + * configuration file. By default SystemClassLoader is used. + */ + ConfigContainer(URL userConfig, boolean setVisible, + int transformCount, boolean attachBehaviors, + ClassLoader classLoader) { + this(userConfig, setVisible, transformCount, attachBehaviors); + this.classLoader = classLoader; + } + + /** * Open, parse, and load the contents of a configuration file. * * @param userConfig location of the configuration file @@ -382,6 +431,7 @@ public class ConfigContainer { configObject.configContainer = this ; // Initialize specific fields and return the ConfigObject. + configObject.setClassLoader(classLoader); configObject.initialize(cmd) ; return configObject ; } diff --git a/src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java b/src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java index 6783253..f47df94 100644 --- a/src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java +++ b/src/classes/share/com/sun/j3d/utils/universe/ConfigObject.java @@ -127,8 +127,18 @@ class ConfigObject { * List of alias Strings for this object if it's not an alias itself. */ List aliases = new ArrayList() ; + + protected ClassLoader classLoader; /** + * @param classLoader the ClassLoader to use when loading the implementation + * class for this object + */ + void setClassLoader( ClassLoader classLoader ) { + this.classLoader = classLoader; + } + + /** * The base initialize() implementation. This takes a ConfigCommand with * three arguments: the command name, the instance name, and the name of * the target class this ConfigObject is configuring. The command in the @@ -232,8 +242,12 @@ class ConfigObject { // Use the system class loader. If the Java 3D jar files are // installed directly in the JVM's lib/ext directory, then the // default class loader won't find user classes outside ext. + // + // From 1.3.2 we use the classLoader supplied to this object, + // normally this will be the system class loader, but for webstart + // apps the user can supply another class loader. return Class.forName(className, true, - ClassLoader.getSystemClassLoader()) ; + classLoader) ; } catch (ClassNotFoundException e) { throw new IllegalArgumentException |