0% found this document useful (0 votes)
23 views16 pages

GWT RPC Implementation Guide

This document discusses Google Web Toolkit (GWT) Remote Procedure Calls (RPC) and how they allow for communication between the client-side and server-side code in a GWT application. It provides an overview of the key classes and interfaces used in GWT RPC, shows a diagram of how RPC calls are made, and includes code examples of defining and making RPC calls. It also discusses additional topics like deploying the RPC servlet, mapping servlets, and more information resources.

Uploaded by

mahe_com_scribd
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views16 pages

GWT RPC Implementation Guide

This document discusses Google Web Toolkit (GWT) Remote Procedure Calls (RPC) and how they allow for communication between the client-side and server-side code in a GWT application. It provides an overview of the key classes and interfaces used in GWT RPC, shows a diagram of how RPC calls are made, and includes code examples of defining and making RPC calls. It also discusses additional topics like deploying the RPC servlet, mapping servlets, and more information resources.

Uploaded by

mahe_com_scribd
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd

GWT - RPC

The Objects

[Link]

[Link]

[Link]

[Link]
RPC plumbing diagram
RPC plumbing diagram

package [Link];
import [Link];
public interface MyAddService extends RemoteService {
public int add(int a, int b);
}
RPC plumbing diagram

package [Link];
import [Link];
import [Link];
public class MyAddServiceImpl
extends RemoteServiceServlet implements MyAddService{
public int add(int a, int b) {
int z = a + b;
return z;
}
}
RPC plumbing diagram

package [Link];
import [Link];
public interface MyAddServiceAsync {
public void add(int a, int b, AsyncCallback callback);
}
Deploy service
 Tomcat -> add Servlet
 Hosted mode -> modify module XML

<module>
<inherits name='[Link]'/>
<entry-point class='[Link]'/>
<servlet path="/addService"
class="[Link]“/>
</module>
Actually making a call
[Link](
new ClickListener() {
public void onClick(Widget sender) {
AddServiceAsync addService = (AddServiceAsync) [Link]([Link]);
ServiceDefTarget endpoint = (ServiceDefTarget) addService;
String moduleRelativeURL = [Link]() + "myAddService“;
[Link](moduleRelativeURL);

instantiate service interface


set service implementation url
Actually making a call
[Link](
new ClickListener() {
public void onClick(Widget sender) {
AddServiceAsync addService = (AddServiceAsync) [Link]([Link]);
ServiceDefTarget endpoint = (ServiceDefTarget) addService;
String moduleRelativeURL = [Link]() + "myAddService“;
[Link](moduleRelativeURL);
AsyncCallback callback = new AsyncCallback(){
public void onSuccess(Object result){
[Link]([Link]());
}
public void onFailure(Throwable caught) {
[Link]([Link]());
}

create an asynchronous callback


to handle the result
Actually making a call
[Link](
new ClickListener() {
public void onClick(Widget sender) {
AddServiceAsync addService = (AddServiceAsync) [Link]([Link]);
ServiceDefTarget endpoint = (ServiceDefTarget) addService;
String moduleRelativeURL = [Link]() + "myAddService“;
[Link](moduleRelativeURL);
AsyncCallback callback = new AsyncCallback(){
public void onSuccess(Object result){
[Link]([Link]());
}
public void onFailure(Throwable caught) {
[Link]([Link]());
}
};
[Link]([Link]([Link]()),
[Link]([Link]()),
callback);
}

);
}
actually make the call
Actually making a call
[Link](
new ClickListener() {
public void onClick(Widget sender) {
AddServiceAsync addService = (AddServiceAsync) [Link]([Link]);
ServiceDefTarget endpoint = (ServiceDefTarget) addService;
String moduleRelativeURL = [Link]() + "myAddService“;
[Link](moduleRelativeURL);
AsyncCallback callback = new AsyncCallback(){
public void onSuccess(Object result){
[Link]([Link]());
}
public void onFailure(Throwable caught) {
[Link]([Link]());
}
};
[Link]([Link]([Link]()),
[Link]([Link]()),
callback);
}
}
);
code executed on client side
code executed on server side
More info

[Link]
[Link]
Service Implementation Path

This can be done in two ways –


1. Using RemoteServiceRelativePath annotation
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
}

2. Using ServiceDefTarget
ServiceDefTarget endPoint = (ServiceDefTarget) greetingService;
[Link]([Link]() + “greet”);

Reference: Common Pitfalls section of


[Link]
Servlet Mapping


GWT modules may declare one or more <servlet> tags. These define Java Servlets
that implement the server-side component of a GWT-enabled web application.

Prior to GWT 1.6, these GWT module servlet tags controlled the set of servlets were
actually instantiated during hosted mode. But as of GWT 1.6, this is no longer true.
Instead, the web application's WEB-INF/[Link] configuration file controls what
servlets are instantiated. A GWT module specifies only what servlets are expected.

During hosted mode startup, the set of expected servlets (from GWT module
<servlet> tags) is validated against the set of actual servlets (from the WEB-
INF/[Link]) and a warning is issued for each expected servlet which does not
match an actual servlet.

Reference: gwt-2.0.3/doc/helpInfo/[Link]
… and explore more by practice

Thanking You
Mahesh Babu M

You might also like