public class ClassFileServer extends ClassServer
| Modifier and Type | Field and Description |
|---|---|
private java.lang.String |
classpath
path to the default package.
|
| Constructor and Description |
|---|
ClassFileServer(int port,
java.lang.String classpath)
Constructs a ClassFileServer.
|
ClassFileServer(int port,
java.lang.String classpath,
java.util.function.Consumer<java.lang.String> infoMsgStrategy,
java.util.function.Consumer<java.lang.String> errMsgStrategy)
Constructs a ClassFileServer.
|
| Modifier and Type | Method and Description |
|---|---|
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)
This method is for testing purposes only.
|
run, showErrorMsg, showInfoMsg, stoppublic ClassFileServer(int port,
java.lang.String classpath)
throws java.io.IOException
port - The port to use for the serverclasspath - The classpath where the server locates classesjava.io.IOException - if cannot listen on specified portpublic ClassFileServer(int port,
java.lang.String classpath,
java.util.function.Consumer<java.lang.String> infoMsgStrategy,
java.util.function.Consumer<java.lang.String> errMsgStrategy)
throws java.io.IOException
port - The port to use for the serverclasspath - The classpath where the server locates classesinfoMsgStrategy - Strategy to display an info message.errMsgStrategy - Strategy to display an error message.java.io.IOException - If there is an error creating the server.public byte[] getBytes(java.lang.String path)
throws java.io.IOException,
java.lang.ClassNotFoundException
getBytes in class ClassServerpath - fully qualified classname of the desired classjava.lang.ClassNotFoundException - if the class corresponding
to path could not be loaded.java.io.IOException - if error occurs reading the classpublic static void main(java.lang.String[] args)
java ClassFileServer <port> <classpath>
java -Djava.rmi.server.codebase=http://zaphod:2001/ RMIServer
new ClassFileServer(port, classpath);
args - args[0] = port number, args[1] = classpath