JanosVM v0.6.0 Java API Documentation: Class ClassPathResource
JanosVM v0.6.0 Java API

edu.utah.janosvm.resources
Class ClassPathResource

java.lang.Object
  |
  +--edu.utah.janosvm.resources.ClassPathResource

public final class ClassPathResource
extends java.lang.Object

Provides access methods to the current team's class path.

The class path in a typical VM is used to specify where to find the class files on the local file system, however, in the JanosVM we're trying to simulate multiple JVMs so a single class path for all of the teams might be insufficient. For example, a user might want to have access to a standard and debugging build of their classes or a more paranoid user might want a team to have no class path to make sure it can't gain access to anything outside of its sandbox. Whatever the case may be, per-team class paths help maintain the illusion of multiple JVMs running in a single instance of the JanosVM.

The current implementation of the resource simply takes the class path as determined at startup and uses it as the global path from which each team can select a subset of paths. Then when a team is created you can create a ClassPathSpec with an array of strings containing the paths that the team should have access too or just use the default of everything in the global path.

To Do

The internals provide many functions for adding and removing paths from the per-team paths, however, these haven't been exported to the java level.

Author:
Tim Stack, Utah Janos Team
See Also:
ClassPathSpec

Method Summary
static void addPath(java.lang.String path)
          Add a class path to the globally available set.
static java.lang.String[] getPaths()
           
static void hidePath(java.lang.String path)
          Hide a path from the global class path.
static byte[] loadFile(java.lang.String name)
          Load the file with the given name from the class path.
static void removePath(java.lang.String path)
          Remove a path from the global class path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

loadFile

public static byte[] loadFile(java.lang.String name)
                       throws java.io.IOException,
                              DeadTeamException
Load the file with the given name from the class path. The file may be anything (not just a .class file).
Returns:
The contents of the file as a byte array or null if it wasn't found.
Throws:
Throws - an IOException if the file couldn't be found or there was a problem while loading.
Throws - a DeadTeamException if the current team was unable to visit the kernel to add the path.

addPath

public static void addPath(java.lang.String path)
                    throws java.io.IOException,
                           DeadTeamException
Add a class path to the globally available set.
Parameters:
path - The path string to add to the global class path.
Throws:
Throws - an IOException if the resource is unable to open the path.
Throws - a DeadTeamException if the current team was unable to visit the kernel to add the path.

hidePath

public static void hidePath(java.lang.String path)
                     throws java.io.IOException,
                            DeadTeamException
Hide a path from the global class path.
Parameters:
path - The path string to hide from the global class path.
Throws:
Throws - an IOException if the resource is unable to open the path.
Throws - a DeadTeamException if the current team was unable to visit the kernel to hide the path.

removePath

public static void removePath(java.lang.String path)
                       throws DeadTeamException
Remove a path from the global class path.
Parameters:
path - The path string to remove from the global class path.
Throws:
Throws - a DeadTeamException if the current team was unable to visit the kernel to remove the path.

getPaths

public static java.lang.String[] getPaths()
Returns:
An array containing the current set of global class paths.

JanosVM v0.6.0 Java API

This documentation is Copyright (C) 2000-2002 The University of Utah. All Rights Reserved. See the documentation license for distribution terms and restrictions.
Documentation, software, and mailing lists for the JanosVM can be found at the Janos Project web page: http://www.cs.utah.edu/flux/janos/
Generated on Mar 17, 2002