mercredi 8 avril 2015

Liferay Spring MVC passing parameter from controller to jsp in new thread

The ping command is running in new thread, trying to check if server runs. If it runs, the thread should send a render parameter of a page which status I want to monitor via AJAX . Well this is the concept of what I want to achieve. In the method, I want to run only a block of code in new thread. I've tried to implement something like this and I know that thread in example is running, but don't know how to set rander parameter when the condition is true. Adding some code implemented inside of the method, I tried to run for closer look.



Thread t;
t = new Thread() {
@Override
public void run() {
synchronized (response) {
try {
response.wait();
for (int i = 0; i < 60; i++) {
String out = DBTools.execCommand("ping -c1 " + nodeip);
if (!out.contains("Destination Host Unreachable")) {
this.notifyAll();
response.setRenderParameter("action", "show-message-wake");
break;
}
Thread.sleep(30000);
}
this.join();
} catch (Exception ex) {
java.util.logging.Logger.getLogger(Soco2HostController.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
};
t.start();


I know this block of code is wrong, well it doesn't work, but how can I achieve something like I mentioned before. To set the render parameter in new thread if the condition is true. Thank you.


Aucun commentaire:

Enregistrer un commentaire