Maybe this will give you some ideas: http://stuffthathappens.com/blog/2009/09/14/guice-with-gwt/
Cheers Alen On Oct 29, 9:00 pm, Budband <[email protected]> wrote: > Any other examples of Guice + GWT RPC would be great. > > On Oct 29, 1:48 pm, Budband <[email protected]> wrote: > > > I am new to Guice and wanted to use it on the Serverside. I am using > > GWT plugin with Eclipse, which nicely creates a GWT project i.e. with > > greeting service. Can anybody provide the changes I need to do to > > make that a GUICE enabled project? I know that I need to inject the > > GuiceModule to this code later ! > > > What is wrong on the following changes: [The code cann't reach the > > welcome html page] > > _______ > > web.xml > > ___________________________________________________________ > > <web-app> > > > <!-- Servlets --> > > <servlet> > > <servlet-name>greetServlet</servlet-name> > > <servlet-class>com.mycompany.server.MyDispatcher</servlet-class> > > </servlet> > > > <servlet-mapping> > > <servlet-name>greetServlet</servlet-name> > > <url-pattern>greet</url-pattern> > > </servlet-mapping> > > > <!-- Default page to serve --> > > <welcome-file-list> > > <welcome-file>GuiceWeb.html</welcome-file> > > </welcome-file-list> > > > </web-app> > > _________________ > > MyDispatcher.java > > __________________________________________________________________________ > > public class MyDispathcer extends RemoteServiceServlet { > > > @Override > > public String processCall(String payload) throws > > SerializationException { > > RPCRequest request = RPC.decodeRequest(payload); > > > java.lang.reflect.Method method = request.getMethod(); // > > request.getMethod(); > > > System.out.println(method.getName()); > > > // Object targetInjectedInstance = > > injector.getInstance(method > > // .getDeclaringClass()); > > > Object targetInjectedInstance = new GreetingServiceImpl(); > > return RPC.invokeAndEncodeResponse(targetInjectedInstance, > > method, > > request.getParameters()); > > > } > > > } > > > _______________ > > GreetingService - [no changes here:] > > _____________________________________________________________________ > > @RemoteServiceRelativePath("greet") > > public interface GreetingService extends RemoteService { > > String greetServer(String name); > > > } > > > _________________ > > GreetingServiceImpl [no changes here:] > > ______________________________ > > public class GreetingServiceImpl extends RemoteServiceServlet > > implements > > GreetingService { > > > public String greetServer(String input) { > > String serverInfo = getServletContext().getServerInfo(); > > String userAgent = > > getThreadLocalRequest().getHeader("User-Agent"); > > return "Hello, " + input + "!<br><br>I am running " + > > serverInfo > > + ".<br><br>It looks like you are > > using:<br>" + userAgent; > > } > > > } > > > Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/google-guice?hl=en -~----------~----~----~----~------~----~------~--~---
