Hi,
I was just hoping that WAIB would adopt guice for registering the servlets.
Something like :
public class GuiceRpcProvider extends ServletModule {
...
@Override
protected void configureServlets() {
// TODO - Use Singleton annotations
bind(AttachmentServlet.class).in(Singleton.class);
bind(AuthenticationServlet.class).in(Singleton.class);
bind(SignOutServlet.class).in(Singleton.class);
bind(UserRegistrationServlet.class).in(Singleton.class);
bind(FetchServlet.class).in(Singleton.class);
bind(SearchServlet.class).in(Singleton.class);
bind(DataApiServlet.class).in(Singleton.class);
bind(DataApiOAuthServlet.class).in(Singleton.class);
bind(RobotRegistrationServlet.class).in(Singleton.class);
bind(ActiveApiServlet.class).in(Singleton.class);
bind(WaveClientServlet.class).in(Singleton.class);
addServlet("/attachment/*", AttachmentServlet.class);
addServlet(SessionManager.SIGN_IN_URL,
AuthenticationServlet.class);
addServlet("/auth/signout", SignOutServlet.class);
addServlet("/auth/register", UserRegistrationServlet.class);
addServlet("/fetch/*", FetchServlet.class);
addServlet("/search/*", SearchServlet.class);
addServlet("/robot/dataapi", DataApiServlet.class);
addServlet(DataApiOAuthServlet.DATA_API_OAUTH_PATH + "/*",
DataApiOAuthServlet.class);
addServlet("/robot/dataapi/rpc", DataApiServlet.class);
addServlet("/robot/register/*", RobotRegistrationServlet.class);
addServlet("/robot/rpc", ActiveApiServlet.class);
/* TODO - Create ProxyServlet Class
String gadgetServerHostname
=injector.getInstance(Key.get(String.class,
Names.named(CoreSettings.GADGET_SERVER_HOSTNAME)));
ProxyServlet.Transparent proxyServlet =
new ProxyServlet.Transparent("/gadgets", "http",
gadgetServerHostname, injector
.getInstance(Key.get(int.class,
Names.named(CoreSettings.GADGET_SERVER_PORT))),
"/gadgets");
ServletHolder proxyServletHolder =
server.addServlet("/gadgets/*", proxyServlet);
proxyServletHolder.setInitParameter("HostHeader",
gadgetServerHostname); */
addServlet("/", WaveClientServlet.class);
serveWebSocket();
initializeFrontend();
}
}
Then in ServerRpcProvider we could register the GuiceServletConfig and
the GuiceFilter and start the internal server if needed (perhaps using a
setting in server.config)
We'd also need to wrap or patch the SocketIO servlet (since it doesn't
inherit from HttpServlet) but there is patch for that here :
http://code.google.com/p/socketio-java/issues/detail?id=5
Allowing a web.xml config would really simplify integrating WIAB into
other projects as well :
ServletModule rpcProvider = new GuiceRpcProvider() {
@Override
protected void configureServlets() {
serve("/hello").with(HelloWorldServlet.class);
super.configureServlets();
}
};
On 28-03-2011 15:28, Anthony Watkins wrote:
Hi Nelson,
I think Guice could be used as an effective way to register servlets. Guice
was discussed by a few members back in September, but it was decided then
that servlet registration process could be easier to follow with a refactor
that I don't believe was ever integrated:
http://codereview.waveprotocol.org/110002/show (see ServletCollection).
As a frame of reference, here is an example of how servlet registration is
done through Guice in Splash. Note that this was contributed by Dhanji who
is one of the commiters (and I believe original authors) of the Guice
framework. That's not to say that it has to be done this way, but it is
probably a pretty good reference.
http://code.google.com/p/google-wave-splash/source/browse/trunk/src/com/google/wave/splash/web/WebServletModule.java(see
configureServlets)
R,
Anthony
On Mon, Mar 28, 2011 at 7:39 AM, Yuri Z<[email protected]> wrote:
I think that using GuiceServletContextListener instead of manual servlet
registration would be a good move.
2011/3/28 Nelson Silva<[email protected]>
Hi all,
Just wondering if it would be possible to use GWT's hosted Jetty to start
WAIB's servlets and websocket server.
I've been using remote debug but being able to launch this from the IDE
would be great.
Could we use a GuiceServletContextListener to register the servlets
instead
of relying on ServerMain ?
This would still allow us to have a programatic configuration (only a
guicefilter in the web.xml) but could decouple from the internal Jetty
server.