Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JanosVM v0.5.1 Java API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.utah.janosvm.resources
Class ClassPathResource

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

public 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

Unfortunately, the current implementation leaves much to be desired. The internals provide many functions for adding and removing paths from the global class path and the per-team paths, however, these haven't been exported to the java level. Also, there is currently no way to reflect on the set of paths available. I imagine these functions would be useful in real applications, but there hasn't been a need in our simple test cases...

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

Constructor Summary
`ClassPathResource()`

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`

Constructor Detail

### ClassPathResource

    public ClassPathResource()

Method Detail

### loadFile

    public static byte[] loadFile(java.lang.String name)
                           throws java.io.IOException

  Load the file with the given name from the class path. The file may be anything (not just a .class file). Note that 'null' is returned if the file is not found, an exception is not thrown.
  Returns:
    The contents of the file as a byte array or null if it wasn't found.

### addPath

    public static void addPath(java.lang.String path)
                        throws java.io.IOException

  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)

  Hide a path from the global class path.
  Parameters:
    `path` - The path string to hide from the global class path.
  Throws:
    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)

  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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JanosVM v0.5.1 Java API
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

This documentation is Copyright (C) 2000-2001 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 Jun 1, 2001