I have doubt on the below code..
@RemoteServiceRelativePath("stockPrices")
public interface StockPriceService extends RemoteService {
StockPrice[] getPrices(String[] symbols);
}
Could any one explain me what is the use of 开发者_StackOverflow中文版@RemoteServiceRelativePath("stockPrices")
and what name we need to give in "stockPrices" .. is it mandatory??
thanks in advance!!!
Check out documentation for RemoteServiceRelativePath annotation, it explains pretty well what this annotation does. In your case, your service must be located at GWT.getModuleBaseURL() + "stockPrices"
... that means that if your GWT app is at /mygwtapp
, then your service must be at /mygwtapp/stockPrices
. It's up to you to install some service at this URL, usually by defining servlet implementing the service interface.
You can use any other path instead of "stockPrices"
, just make sure there is real service behind this path on the server.
Your remote services need some remote path (entry point), either by using @RemoteServiceRelativePath
annotation, or by setting it through ServiceDefTarget interface. If service has no entry point, it cannot be called. (Remember: this path is URL on the server)
For example, instead of using @RemoteServiceRelativePath
, you can define your service without this annotation, and then when you instantiate async service proxy, you explicitly set path:
StockPriceServiceAsync stockService = GWT.create(StockPriceService.class);
((ServiceDefTarget) stockService).setServiceEntryPoint("/services/stock.service");
精彩评论