package de.remote.agents.clients.app;
-import java.net.URL;
+import java.util.Timer;
+import java.util.TimerTask;
import org.apache.log4j.Logger;
-import com.googlecode.jsonrpc4j.JsonRpcHttpClient;
-
-import de.remote.agents.SnakeEyes;
-import de.remote.agents.SnakeEyesImpl;
+import de.remote.agents.services.CurrentDateService;
public class ClientsMainTest {
private static final Logger logger = Logger.getLogger(ClientsMainTest.class);
public static void main(final String[] args) throws Throwable {
- final JsonRpcHttpClient client = new JsonRpcHttpClient(new URL(
- "http://127.0.0.1:8080/spring-mainapp/UserService.json"));
-
- final SnakeEyes user = client.invoke("createUser", new Object[] {
- "Shana M. O'Hara", "Snake Eyes" }, SnakeEyesImpl.class);
-
- logger.info("Canon: " + user.getCanon());
- logger.info("Name: " + user.getName());
+ // final JsonRpcHttpClient client = new JsonRpcHttpClient(new URL(
+ // "http://127.0.0.1:8080/spring-mainapp/UserService.json"));
+ //
+ // final SnakeEyes user = client.invoke("createUser", new Object[] {
+ // "Shana M. O'Hara", "Snake Eyes" }, SnakeEyesImpl.class);
+ //
+ // logger.info("Canon: " + user.getCanon());
+ // logger.info("Name: " + user.getName());
// I need a way to set the return type parameter, otherwise I am not
// logger.info("Canon: " + snakeEyes.getCanon());
// logger.info("Name: " + snakeEyes.getName());
+ // I need a way to set the return type parameter, otherwise I am not
+ // going to be able to use this JSON-RPC plugin :(
+
+ logger.info("Starting application");
+ SpringContextLocator.getInstance();
+
+ final CurrentDateService remoteCurrentDate = (CurrentDateService) SpringContextLocator
+ .getInstance().getBean("remoteCurrentDateService");
+
+
+ final RemoteGUIExample window = new RemoteGUIExample();
+ final Runnable task = new Runnable() {
+
+ @Override
+ public void run() {
+ window.open();
+ }
+
+ };
+
+ final Thread GUIThread = new Thread(task, "GUI-Thread");
+ // GUIThread.setUncaughtExceptionHandler(new DriverHWUncaughtExceptionHandler());
+ GUIThread.start();
+
+ final Timer t = new Timer("Timer-Thread", false);
+ t.scheduleAtFixedRate(new TimerTask() {
+ @Override
+ public void run() {
+ final String remoteDate = remoteCurrentDate.getCurrentDate();
+ window.updateTextBox(remoteDate);
+ }
+ }, 1000, 1000);
+
}
+ // private class DriverHWUncaughtExceptionHandler implements UncaughtExceptionHandler {
+ //
+ // @Override
+ // public void uncaughtException(final Thread t, final Throwable e) {
+ // logger.warn(
+ // "Exception not expected while running thread " + t.getName(), e);
+ // }
+ // }
+
}
--- /dev/null
+package de.remote.agents.clients.app;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class RemoteGUIExample {
+
+ private Shell shell;
+ private Text textBox;
+ private Display display;
+
+
+ /**
+ * @wbp.parser.entryPoint
+ */
+ public void open() {
+ this.display = Display.getDefault();
+ this.createContents();
+ this.shell.open();
+ this.shell.layout();
+ while (!this.shell.isDisposed()) {
+ if (!this.display.readAndDispatch()) {
+ this.display.sleep();
+ }
+ }
+ }
+
+ public void updateTextBox(final String text) {
+ this.display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ if (!RemoteGUIExample.this.textBox.isDisposed())
+ RemoteGUIExample.this.textBox.setText(text);
+ }
+ });
+ }
+
+
+ private void createContents() {
+ this.shell = new Shell();
+ this.shell.setSize(450, 300);
+ this.shell.setText("Remote GUI");
+
+ this.textBox = new Text(this.shell, SWT.BORDER);
+ this.textBox.setBounds(111, 95, 181, 58);
+
+ final Label lblRemoteDate = new Label(this.shell, SWT.NONE);
+ lblRemoteDate.setBounds(111, 63, 113, 26);
+ lblRemoteDate.setText("Remote Date:");
+ }
+
+}