forked from LupusNobilis/java-org.hwo
Kleine Änderungen
parent
a6cac2bff9
commit
7ac9268057
|
@ -54,9 +54,11 @@ public class InteractiveObjectHelper {
|
||||||
|
|
||||||
public static void showEditor(Object o)
|
public static void showEditor(Object o)
|
||||||
{
|
{
|
||||||
|
if (o != null){
|
||||||
IInteractiveObjectEditor editor = getEditor(o);
|
IInteractiveObjectEditor editor = getEditor(o);
|
||||||
editor.setInteractiveObject(o);
|
editor.setInteractiveObject(o);
|
||||||
editor.setVisible(true);
|
editor.setVisible(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,25 +12,60 @@ import java.net.InetAddress;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class SimpleRPCServer extends Thread{
|
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 Hashtable<String, Object> registeredObjects;
|
||||||
private ServerSocket serverSocket;
|
private ServerSocket serverSocket;
|
||||||
|
|
||||||
private boolean exit;
|
private boolean exit;
|
||||||
|
|
||||||
public SimpleRPCServer(InetAddress listenAddress,int port) throws IOException
|
public SimpleRPCServer(InetAddress listenAddress,int port) throws IOException
|
||||||
{
|
{
|
||||||
this.registeredObjects = new Hashtable<String, Object>();
|
this.registeredObjects = new Hashtable<String, Object>();
|
||||||
this.serverSocket = new ServerSocket(port, 5, listenAddress);
|
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
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (!exit){
|
while (!exit){
|
||||||
try {
|
try {
|
||||||
handleOneRequest();
|
Socket socket = serverSocket.accept();
|
||||||
|
if (socket != null){
|
||||||
|
ClientConnection client = new ClientConnection(socket);
|
||||||
|
client.start();
|
||||||
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -47,9 +82,7 @@ public class SimpleRPCServer extends Thread{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleOneRequest() throws IOException{
|
public void handleOneRequest(Socket socket) throws IOException{
|
||||||
Socket socket = serverSocket.accept();
|
|
||||||
|
|
||||||
DataInputStream dis = new DataInputStream(socket.getInputStream());
|
DataInputStream dis = new DataInputStream(socket.getInputStream());
|
||||||
int len = dis.readInt();
|
int len = dis.readInt();
|
||||||
byte[] request = new byte[ len ];
|
byte[] request = new byte[ len ];
|
||||||
|
@ -106,7 +139,6 @@ public class SimpleRPCServer extends Thread{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new byte[0];
|
return new byte[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue