org.objectweb.proactive.core.rmi
Class ClassServer

java.lang.Object
  |
  +--org.objectweb.proactive.core.rmi.ClassServer
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
ClassFileServer

public abstract class ClassServer
extends java.lang.Object
implements java.lang.Runnable

ClassServer is an abstract class that provides the basic functionality of a mini-webserver, specialized to load class files only. A ClassServer must be extended and the concrete subclass should define the getBytes method which is responsible for retrieving the bytecodes for a class.

The ClassServer creates a thread that listens on a socket and accepts HTTP GET requests. The HTTP response contains the bytecodes for the class that requested in the GET header.

For loading remote classes, an RMI application can use a concrete subclass of this server in place of an HTTP server.

See Also:
ClassFileServer

Field Summary
protected static int DEFAULT_SERVER_BASE_PORT
           
protected static int DEFAULT_SERVER_PORT_INCREMENT
           
protected  java.lang.String hostname
           
protected static org.apache.log4j.Logger logger
           
protected static int MAX_RETRY
           
protected  int port
           
 
Constructor Summary
protected ClassServer()
          Constructs a ClassServer that listens on a random port.
protected ClassServer(int port)
          Constructs a ClassServer that listens on port and obtains a class's bytecodes using the method getBytes.
 
Method Summary
protected abstract  byte[] getBytes(java.lang.String path)
          Returns an array of bytes containing the bytecodes for the class represented by the argument path.
 java.lang.String getHostname()
           
 int getServerSocketPort()
           
 void run()
          The "listen" thread that accepts a connection to the server, parses the header to obtain the class file name and sends back the bytecodes for the class (or error if the class is not found or the response was malformed).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.log4j.Logger logger

DEFAULT_SERVER_BASE_PORT

protected static int DEFAULT_SERVER_BASE_PORT

DEFAULT_SERVER_PORT_INCREMENT

protected static int DEFAULT_SERVER_PORT_INCREMENT

MAX_RETRY

protected static int MAX_RETRY

port

protected int port

hostname

protected java.lang.String hostname
Constructor Detail

ClassServer

protected ClassServer()
               throws java.io.IOException
Constructs a ClassServer that listens on a random port. The port number used is the first one found free starting from a default base port. obtains a class's bytecodes using the method getBytes.

Throws:
java.io.IOException - if the ClassServer could not listen on any port.

ClassServer

protected ClassServer(int port)
               throws java.io.IOException
Constructs a ClassServer that listens on port and obtains a class's bytecodes using the method getBytes.

Parameters:
port - the port number
Throws:
java.io.IOException - if the ClassServer could not listen on port.
Method Detail

getServerSocketPort

public int getServerSocketPort()

getHostname

public java.lang.String getHostname()

run

public void run()
The "listen" thread that accepts a connection to the server, parses the header to obtain the class file name and sends back the bytecodes for the class (or error if the class is not found or the response was malformed).

Specified by:
run in interface java.lang.Runnable

getBytes

protected abstract 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.

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


Copyright © April 2004 INRIA All Rights Reserved.