org.huihoo.jfox.ejb.server.webserver
Class ClassFileServer
java.lang.Object
|
+--org.huihoo.jfox.ejb.server.webserver.ClassServer
|
+--org.huihoo.jfox.ejb.server.webserver.ClassFileServer
- All Implemented Interfaces:
- java.lang.Runnable
- public class ClassFileServer
- extends ClassServer
|
Method Summary |
void |
create()
|
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. |
void |
start()
|
| Methods inherited from class org.huihoo.jfox.ejb.server.webserver.ClassServer |
run |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ClassFileServer
public ClassFileServer()
ClassFileServer
public ClassFileServer(int port,
java.lang.String classpath)
throws java.io.IOException
- Constructs a ClassFileServer.
- Parameters:
classpath - the classpath where the server locates classes
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
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);
create
public void create()
throws java.lang.Exception
java.lang.Exception
start
public void start()
throws java.lang.Exception
java.lang.Exception