Looking at the GWT sample apps and the RPC tutorial the following package conventions are used:
./client/GreetingService.java ./client/GreetingServiceAsync.java ./server/GreetingServiceImpl.java
Though the GWT docs are very sparse on best-practices what components get included where at runtime, the clear intuition is:
- server - Compiled into bytecode by javac
This would lead one to believe that code in
client debemos no be on the compile-time sourcepath of javac. Yet since
GreetingService, clearly code in
client needs to be on the sourcepath during compilation, and included on the runtime classpath at deployment.
Given this, why doesn't the
GreetingService interface go in
If you try to put it in
shared,la GWT Eclipse Plugin complains "Missing Asynchronous Interface"...
preguntado el 27 de agosto de 11 a las 19:08
Let's try to be clear :
- No hay técnico diferencia entre el cliente y el compartido package, it's only a matter of convention. Both are declared as source packages in your module (the .gwt.xml archivo)
- On servidor side, the bytecode for the whole client part is usually available, although most of it is no utilizado.
- Therefore, some people just remove the compartido package, and put everything in the cliente package. It's a matter of taste.
- As Thomas said, the
Serviceinterface must be available to your client code. So it must either be in the cliente package or the compartido package. But the
ServiceAsyncinterface must be in the same package as the
Serviceinterface. And the
ServiceAsyncis certainly not something that is considered shared between cliente y servidor. Entonces el
ServiceASyncinterface should be in the cliente paquete.
- Como consecuencia, el
Serviceinterface is put in the cliente paquete.
- En tu caso, el GWT Eclipse Plugin complained because the
ServiceASyncinterface was not found in the
Servicepaquete de interfaz.
- Todavía puedes usar el compartido package for the classes that are sent through RPC.
Eso responde tu pregunta?
In my projects both
shared and everything works ok. Actually I don't see it any other way as
Service interface and compiler needs to have them on the classpath.
GWT-RPC generator uses a naming convention (sticking an
Async suffix to the classname), adding a "package renaming rule" (
ServiceAsync es en
client) would like not fit with many people's package layout. So, the rule is that both interfaces are in the same package, whichever the name of the package, which allows you to put them in
shared if you want (as Peter Knego said)
(that rule is also due to legacy, the
shared convention has been introduced in GWT projects quite recently, comparatively with GWT-RPC)