org.scopemvc.util
Class ResourceLoader

java.lang.Object
  |
  +--org.scopemvc.util.ResourceLoader

public class ResourceLoader
extends java.lang.Object

Utility class for loading resources.
This class fixes an issue where the Scope library wants to load a resource belonging to a client jar, but cannot find it because of the resource is not accessible from the scope classloader.
The solution is to give access from Scope to the client classloader, i.e the classloader used to load the client jars containing the application resources.
User code needs to set the client classloader with ResourceLoader.setClientClassLoader before Scope can load the client resources.

Version:
$Revision: 1.4 $ $Date: 2002/09/05 15:41:46 $
Author:
setClientClassLoader(java.lang.ClassLoader)

Method Summary
static java.lang.ClassLoader getClientClassLoader()
          Gets the client class loader.
static java.lang.ClassLoader getClientLoader()
          Gets the client loader
static javax.swing.Icon getIcon(java.lang.String iconPath)
          Gets the icon
static java.awt.Image getImage(java.lang.String imagePath)
          Gets the image
static java.util.ResourceBundle getProperties(java.lang.String inPropertiesName)
          Try to return a ResourceBundle loaded from the named resource, or null if can't load.
static java.net.URL getResource(java.lang.String resourcePath)
          Gets the resource
static void setClientClassLoader(java.lang.ClassLoader cl)
          Sets the client class loader used to load the resources.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClientLoader

public static java.lang.ClassLoader getClientLoader()
Gets the client loader

Returns:
The clientLoader value

getIcon

public static javax.swing.Icon getIcon(java.lang.String iconPath)
Gets the icon

Parameters:
iconPath - Description of the Parameter
Returns:
The icon value, or null if it was not found

getImage

public static java.awt.Image getImage(java.lang.String imagePath)
Gets the image

Parameters:
imagePath - Description of the Parameter
Returns:
The image value, or null if it was not found

getResource

public static java.net.URL getResource(java.lang.String resourcePath)
Gets the resource

Parameters:
resourcePath - Description of the Parameter
Returns:
The resource value

getProperties

public static java.util.ResourceBundle getProperties(java.lang.String inPropertiesName)
Try to return a ResourceBundle loaded from the named resource, or null if can't load.

Parameters:
inPropertiesName - TODO: Describe the Parameter
Returns:
The properties value

getClientClassLoader

public static java.lang.ClassLoader getClientClassLoader()
Gets the client class loader.

Returns:
The clientClassLoader value

setClientClassLoader

public static void setClientClassLoader(java.lang.ClassLoader cl)
Sets the client class loader used to load the resources.
This class loader should be the one used to load the jars of your application containing the resources.
Typical code looks like:
    class MyLauncher {
      public static void main(String[] args) {
        ResourceLoader.setClientClassLoader(MyLauncher.class.getClassLoader());
        // starts Scope application
        MyController controller = new MyController();
        controller.startUp();
      }
    }
 

Parameters:
cl - The new clientClassLoader value


Copyright © 2000-2002 The Scope Team. All Rights Reserved.