RMIIncomingThread.java: New file.
2004-03-20 Norbert Frese <postfach@nfrese.net> * gnu/java/rmi/server/RMIIncomingThread.java: New file. * gcc/libjava/gnu/java/rmi/server/UnicastConnection.java: Create a new RMIObjectOuputStream/RMIObjectInputStream for every rmi-message. (getObjectInputStream): Return object reference, throw IOException if null. (startObjectInputStream): Create new RMIObjectInputStream on top of 'din'. (getObjectOutputStream): Return object reference, throw IOException if null. (startObjectOutputStream): Create new RMIObjectOutputStream on top of 'dout'. * gcc/libjava/gnu/java/rmi/server/UnicastConnectionManager.java: (UnicastConnectionManager): Throw RemoteException if port is not available. (getInstance): Throw RemoteException. (run): Lookup client host and attach it to new RMIIncomingThread for later retrieval. * gcc/libjava/gnu/java/rmi/server/UnicastRef.java: Start a new RMIObjectInputStream/RMIObjectOutputStream for every rmi-message. Collect Exceptions which are returned by a rmi-call and fix void returns. * gcc/libjava/gnu/java/rmi/server/UnicastRemoteCall.java: Start a new RMIObjectInputStream/RMIObjectOutputStream for every rmi-message. * gcc/libjava/gnu/java/rmi/server/UnicastServer.java: (dispatch): Answer ping messages which are sent by other java implementions. (incomingMessageCall): Start a new RMIObjectInputStream/RMIObjectOutputStream for every rmi-message and fix void return problems. * gcc/libjava/gnu/java/rmi/server/UnicastServerRef.java (UnicastServerRef): Throw RemoteException. (exportObject): Find the class up the class hierarchy which has a _Stub generated by rmic. In some situations it is necessary to export a subclass of the class which has the _Stub. For instance when the class with has the _Stub is abstract. (findStubSkelClass): New method which looks for the class which has the _Stub. (getClientHost): Implementated. * gcc/libjava/java/rmi/server/RemoteServer.java (getClientHost): Implementated. * gcc/libjava/Makefile.am (rmi_java_source_files): Added gnu/java/rmi/server/RMIIncomingThread.java. * Makefile.in: Regenerated. From-SVN: r79755
This commit is contained in:
parent
079f946dad
commit
f903e73b80
11 changed files with 247 additions and 34 deletions
|
@ -59,6 +59,7 @@ import java.util.Hashtable;
|
|||
import java.util.Iterator;
|
||||
|
||||
import gnu.java.rmi.server.UnicastConnection;
|
||||
import gnu.java.rmi.server.RMIIncomingThread;
|
||||
|
||||
public class UnicastConnectionManager
|
||||
implements Runnable, ProtocolConstants {
|
||||
|
@ -173,20 +174,16 @@ private UnicastConnectionManager(String host, int port, RMIClientSocketFactory c
|
|||
/**
|
||||
* Server UnicastConnectionManager constructor
|
||||
*/
|
||||
private UnicastConnectionManager(int port, RMIServerSocketFactory ssf) {
|
||||
private UnicastConnectionManager(int port, RMIServerSocketFactory ssf) throws RemoteException {
|
||||
|
||||
try {
|
||||
ssock = ssf.createServerSocket(port);
|
||||
serverPort = ssock.getLocalPort();
|
||||
}
|
||||
catch (IOException _) {
|
||||
try {
|
||||
ssock = ssf.createServerSocket(0);
|
||||
serverPort = ssock.getLocalPort();
|
||||
}
|
||||
catch (IOException __) {
|
||||
ssock = null;
|
||||
serverPort = 0;
|
||||
}
|
||||
catch (IOException ioex) {
|
||||
ssock = null;
|
||||
serverPort = 0;
|
||||
throw new java.rmi.server.ExportException("can not create Server Socket on port " + port,ioex);
|
||||
}
|
||||
serverName = localhost;
|
||||
serverFactory = ssf;
|
||||
|
@ -230,7 +227,7 @@ public static synchronized UnicastConnectionManager getInstance(String host, int
|
|||
* Return a server connection manager which will accept connection on the
|
||||
* given port.
|
||||
*/
|
||||
public static synchronized UnicastConnectionManager getInstance(int port, RMIServerSocketFactory ssf) {
|
||||
public static synchronized UnicastConnectionManager getInstance(int port, RMIServerSocketFactory ssf) throws RemoteException {
|
||||
//System.out.println("getInstance: " + port + "," + ssf);
|
||||
if (ssf == null) {
|
||||
ssf = defaultSocketFactory;
|
||||
|
@ -376,9 +373,17 @@ public void run() {
|
|||
try {
|
||||
//System.out.println("Waiting for connection on " + serverPort);
|
||||
UnicastConnection conn = getServerConnection();
|
||||
|
||||
// get address of remote host for the RMIIncomingThread object
|
||||
String remoteHost = null;
|
||||
if (conn.sock != null) {
|
||||
remoteHost = conn.sock.getInetAddress().getHostAddress();
|
||||
}
|
||||
|
||||
// use a thread pool to improve performance
|
||||
//ConnectionRunnerPool.dispatchConnection(conn);
|
||||
(new Thread(conn)).start();
|
||||
(new RMIIncomingThread(conn, remoteHost)).start();
|
||||
// (new Thread(conn)).start();
|
||||
}
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue