psl.worklets.http
Class ClassFileServer

java.lang.Object
  |
  +--psl.worklets.http.ClassServer
        |
        +--psl.worklets.http.ClassFileServer
All Implemented Interfaces:
java.lang.Runnable

public class ClassFileServer
extends ClassServer

The ClassFileServer implements a ClassServer that reads class files from the file system. See the doc for the "Main" method for how to run this server.


Field Summary
private  java.util.Vector aliases
           
private  java.lang.String default_codebase
           
private static int DefaultServerPort
           
private  java.lang.String toString
           
 
Fields inherited from class psl.worklets.http.ClassServer
port, server
 
Constructor Summary
ClassFileServer(int port, java.lang.String codebase)
          Constructs a ClassFileServer.
ClassFileServer(int port, java.lang.String codebase, psl.worklets.WVM_SSLSocketFactory wvm_sf)
           
ClassFileServer(java.lang.String protocol, java.lang.String host, int port, java.lang.String codebase, psl.worklets.WVM_SSLSocketFactory wvm_sf)
           
 
Method Summary
private  byte[] classExtract(java.io.File f)
           
private  java.io.File findFile(java.lang.String rootPath, java.lang.String path)
           
 java.util.Vector getAliases()
           
 byte[] getBytes(java.lang.String path)
          Returns an array of bytes containing the bytecodes for the class represented by the argument path.
 int getWebPort()
           
private  byte[] jarExtract(java.io.File f, java.lang.String path)
           
static void main(java.lang.String[] args)
          Main method to create the class server that reads class files.
 java.lang.String toString()
           
 
Methods inherited from class psl.worklets.http.ClassServer
containsKey, get, put, run, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

default_codebase

private java.lang.String default_codebase

aliases

private java.util.Vector aliases

DefaultServerPort

private static final int DefaultServerPort
See Also:
Constant Field Values

toString

private final java.lang.String toString
Constructor Detail

ClassFileServer

public ClassFileServer(int port,
                       java.lang.String codebase)
                throws java.io.IOException
Constructs a ClassFileServer.

Parameters:
port - the port to connect to this ClassFileServer

ClassFileServer

public ClassFileServer(int port,
                       java.lang.String codebase,
                       psl.worklets.WVM_SSLSocketFactory wvm_sf)
                throws java.io.IOException

ClassFileServer

public ClassFileServer(java.lang.String protocol,
                       java.lang.String host,
                       int port,
                       java.lang.String codebase,
                       psl.worklets.WVM_SSLSocketFactory wvm_sf)
                throws java.io.IOException
Method Detail

getWebPort

public int getWebPort()

getAliases

public java.util.Vector getAliases()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getBytes

public byte[] getBytes(java.lang.String path)
                throws java.io.IOException,
                       java.lang.ClassNotFoundException
Returns an array of bytes containing the bytecodes for the class represented by the argument path. The path is a dot separated class name with the ".class" extension removed.

Specified by:
getBytes in class ClassServer
Returns:
the bytecodes for the class
Throws:
java.lang.ClassNotFoundException - if the class corresponding to path could not be loaded.
java.io.IOException - if error occurs reading the class

classExtract

private byte[] classExtract(java.io.File f)
                     throws java.io.IOException
java.io.IOException

jarExtract

private byte[] jarExtract(java.io.File f,
                          java.lang.String path)
                   throws java.io.IOException,
                          java.util.zip.ZipException
java.io.IOException
java.util.zip.ZipException

findFile

private java.io.File findFile(java.lang.String rootPath,
                              java.lang.String path)

main

public static void main(java.lang.String[] args)
Main method to create the class server that reads class files. This takes two command line arguments, the port on which the server accepts requests and the root of the classpath. To start up the server:

java ClassFileServer

The codebase of an RMI server using this webserver would simply contain a URL with the host and port of the web server (if the webserver's classpath is the same as the RMI server's classpath):

java -Djava.rmi.server.codebase=http://zaphod:2001/ RMIServer

You can create your own class server inside your RMI server application instead of running one separately. In your server main simply create a ClassFileServer:

new ClassFileServer(port, classpath);