Kleine Änderungen

thobaben_serialize
root 2015-05-05 16:11:47 +02:00
parent a6cac2bff9
commit 7ac9268057
2 changed files with 43 additions and 9 deletions

View File

@ -54,9 +54,11 @@ public class InteractiveObjectHelper {
public static void showEditor(Object o)
{
IInteractiveObjectEditor editor = getEditor(o);
editor.setInteractiveObject(o);
editor.setVisible(true);
if (o != null){
IInteractiveObjectEditor editor = getEditor(o);
editor.setInteractiveObject(o);
editor.setVisible(true);
}
}
}

View File

@ -12,25 +12,60 @@ import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.List;
public class SimpleRPCServer extends Thread{
class ClientConnection extends Thread {
private Socket socket;
public ClientConnection(Socket socket){
this.socket = socket;
}
@Override
public void run() {
try {
addClientConnection(this);
handleOneRequest(socket);
removeClientConnection(this);
} catch (IOException e) {
e.printStackTrace();
}
}
}
private List<ClientConnection> clientConnections;
private Hashtable<String, Object> registeredObjects;
private ServerSocket serverSocket;
private boolean exit;
public SimpleRPCServer(InetAddress listenAddress,int port) throws IOException
{
this.registeredObjects = new Hashtable<String, Object>();
this.serverSocket = new ServerSocket(port, 5, listenAddress);
this.clientConnections = new LinkedList<SimpleRPCServer.ClientConnection>();
}
synchronized void addClientConnection(ClientConnection clientConnection){
this.clientConnections.add(clientConnection);
}
synchronized void removeClientConnection(ClientConnection clientConnection){
this.clientConnections.remove(clientConnection);
}
@Override
public void run() {
while (!exit){
try {
handleOneRequest();
Socket socket = serverSocket.accept();
if (socket != null){
ClientConnection client = new ClientConnection(socket);
client.start();
}
} catch (IOException e) {
e.printStackTrace();
}
@ -47,9 +82,7 @@ public class SimpleRPCServer extends Thread{
}
}
public void handleOneRequest() throws IOException{
Socket socket = serverSocket.accept();
public void handleOneRequest(Socket socket) throws IOException{
DataInputStream dis = new DataInputStream(socket.getInputStream());
int len = dis.readInt();
byte[] request = new byte[ len ];
@ -106,7 +139,6 @@ public class SimpleRPCServer extends Thread{
e.printStackTrace();
}
return new byte[0];
}