GWT API on Gears

0 views
Skip to first unread message

Peter

unread,
Nov 10, 2009, 12:08:24 PM11/10/09
to Google Web Toolkit
I would like to know if it would be possible to call Java method
within a worker in a workerpool. For example given the class and
method

package com.mycomp;

public class MyClass implements EntryPoint, WorkerPoolMessageHandler {
public void mymethod() {
...
}}

Is it possible to define the following JSNI method

private native String javamethod() /*-{
var workerCode = 'google.gears.workerPool.onmessage = function
(a,b,message) { google.gears.workerPool.sendMessage(update(),
message.sender); };';

function update() {
this.@com.mycomp.MyClass::mymethod();
return "Done";
};
workerCode += String(update);
return workerCode;
}-*/;

and use the following code to define a worker?

WorkerPool wp = Factory.getInstance().createWorkerPool();
wp.setMessageHandler(this);
int workerId = wp.createWorker(javamethod());
wp.sendMessage("update", workerid);

Thanks for the help.
Reply all
Reply to author
Forward
0 new messages