appli.http
Class HttpFileServer
java.lang.Object
appli.http.HttpServer
appli.http.HttpFileServer
- All Implemented Interfaces:
- java.lang.Runnable
- public class HttpFileServer
- extends HttpServer
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.
- Version:
- 1.0 Mar 2003 add a configuration file with a redirection instruction
- Author:
- Sun Microsystems (see Copyright), Marc Wenger/CDS
Constructor Summary |
HttpFileServer(int port,
java.lang.String root,
java.lang.String conf)
Constructs a ClassFileServer. |
Method Summary |
byte[] |
getBytes(java.lang.String path)
Returns an array of bytes containing the bytecodes for
the class represented by the argument path.
|
static void |
main(java.lang.String[] args)
Main method to create the class server that reads
class files. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
rootpath
private java.lang.String rootpath
confpath
private java.lang.String confpath
redirTable
private java.util.HashMap redirTable
DefaultServerPort
private static int DefaultServerPort
HttpFileServer
public HttpFileServer(int port,
java.lang.String root,
java.lang.String conf)
throws java.io.IOException
- Constructs a ClassFileServer.
- Parameters:
port
- port number to use for this serverroot
- root path of the objects (classes or files) available to
the serverconf
- configuration file
- Throws:
java.io.IOException
- if problems reading the configuration file
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 HttpServer
- Parameters:
path
- pathname of the object to read
- Returns:
- the bytecodes for the class, or the data in the file
- Throws:
java.lang.ClassNotFoundException
- if the class corresponding
to path could not be loaded.
java.io.IOException
- if a read error occurs
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);
- Parameters:
args
- command line parameters: port rootpath conf_filepath