Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Setting up the servlets etc. for RPC on Guice 2

    Hi,

    As I mentioned briefly in another thread, I wanted to share the set-up I used to get the servlets and filters configured in a Guice 2 webapp. Here goes:

    Code:
                /** Sets up filters and servlets for Smart GWT RPC. */
                private void configureSmartGWTRPC() {
                    //since we cannot annotate third party lib, bind them here in singleton scope
                    this.bind(IDACall.class).in(Scopes.SINGLETON);
                    this.bind(FileDownload.class).in(Scopes.SINGLETON);
                    this.bind(DataSourceLoader.class).in(Scopes.SINGLETON);
                    this.bind(Init.class).in(Scopes.SINGLETON);
                    this.bind(CompressionFilter.class).in(Scopes.SINGLETON);
    
                    //set up URLs to be served by Smart GWT servlets
                    serve("/sc/init").with(Init.class);//URL not used, but simulates load-on-startup (Guice uses order from here)
                    serve("/sc/IDACall*").with(IDACall.class);//had to remove "/" before * compared to sample project to avoid a 404 message
                    serve("/sc/DataSourceLoader").with(DataSourceLoader.class);
                    serve("/sc/skins/*").with(FileDownload.class);
                    serve("/sc/system/modules/*").with(FileDownload.class);
                    serve("/sc/system/development/*").with(FileDownload.class);
                    serve("/sc/system/reference/skin/*").with(FileDownload.class);
    
                    //add the filter that behaves more or less like mod_deflate
                    filter("/sc/*").through(CompressionFilter.class);
                }
    Hope someone finds this useful.

    Sondre

    PS. This is replacing any web.xml config for SmartGWT, only the Guice context listener to set up the module + the guice filter will be there.
    Last edited by sondresb; 2 Jul 2010, 02:23.
Working...
X