try {
sc = new ServerSocket(connectionPort);
socket = sc.accept();
watchdog.interrupt();
} catch (IOException ex) {
throw new JemmyException("Can't establish connection with client", ex);
}
System.out.println("Connection established!");
try {
inputStream = new ObjectInputStream(socket.getInputStream());
outputStream = new ObjectOutputStream(socket.getOutputStream());
while(true) {
String command = (String)inputStream.readObject();
// System.out.println("Got command: " + command);
if ("exit".equals(command)) {
System.exit(0);
}
if ("getProperty".equals(command)) {
String property = (String)inputStream.readObject();
outputStream.writeObject(Environment.getEnvironment().getProperty(property));
outputStream.writeObject("OK");
}
if ("makeAnOperation".equals(command)) {
String method = (String)inputStream.readObject();
Object[] params = (Object[])inputStream.readObject();
Class[] paramClasses = (Class[])inputStream.readObject();
Object result = makeAnOperationLocally(method, params,
paramClasses);
if (result instanceof BufferedImage) {
outputStream.writeObject("image");
BufferedImage image = BufferedImage.class.cast(result);
new PNGEncoder(outputStream, PNGEncoder.COLOR_MODE)
.encode(image, false);
//ImageIO.write(image, "png", outputStream);
} else {
outputStream.writeObject("OK");
outputStream.writeObject(result);
}
// System.out.println("Command executed");
}
}
} catch (ClassNotFoundException ex) {
throw new JemmyException("Socket communication with other " +
"JVM failed", ex);
} catch (IOException ex) {
Logger.getLogger(RobotExecutor.class.getName())
.log(Level.SEVERE, null, ex);
} finally {