I’s just about JAOO-time. JAOO is being organized by EOS, the company I’m working for, so there’s no excuse for not attending. Of course, there’s no excuse no matter what, as the conference is stuffed with goodies. Of special interest for me is the tracks on Emerging Web Technologies , Relation Databases, Back to the Future, and Rich Client Development. Experience, however, has told me that I’ll probably end up in other tracks/sessions. Luckily, that’s usually a good way of meeting new subjects and people.
So, if you’re attending, which you should, stop by and say hello.
I recently had to implement an anonymous chat client using a Jabber backend in GWT. No problem, I just implemented a RemoteServiceServlet with the necessary methods, and then a GWT client which polls the service for data.
Next, I got a request about adding the same functionality to an Eclipse RCP based application. I now had the choice of either implementing the service again using REST, WebServices, or something entirely different, but it would be much easier if I just called the GWT service directly, which leads me to the real purpose of this post: Using a proxy pattern, I've created the necessary mechanisms to make this posssible.
It works like this:
You create a service implementation. Copy any interfaces, exception classes, and shared classes to the client project, and add gwt-java.jar to the classpath. Access the remote service like this:
CODE:
-
import dk.contix.gwt.java.GWTJava;
-
import dk.contix.gwt.java.example.ExampleService;
-
-
public class Test {
-
public void callService() {
-
ExampleService service = (ExampleService) GWTJava.create(
-
ExampleService.class,
-
"http://localhost:8080/example/exampleService");
-
service.voidTest();
-
}
-
-
}
Of course, you are bound by the same restrictions as when using the service from Javascript: Only classes which implement IsSerializable can be serialized, they must have empty constructors, and so on. But besides that, this is more or less what you need to do.
One of the most annoying "features" in Eclipse is the mini tabs, also called Property Pages, which are used by the WTP XML editor and others. Why? Because if you use Ctrl-PageUp/Down to switch tabs, as I do, then you can only switch between the property pages once you've hit an editor which has property pages. This forces you to either use the mouse to select another editor, or to use Ctrl-F6. That's just plain wrong.
Luckily, someone has reported this as a bug, so I'm hoping it will be fixed at some point.