Over a million developers have joined DZone.

Using Google Guice with Atmosphere

· Java Zone

Learn more about how the Java language, tools and frameworks have been the foundation of countless enterprise systems, brought to you in partnership with Salesforce.

Starting with Atmosphere 0.5, you can now use Google Guice to configure Atmosphere. Google Guice support is enabled by referencing the Guice filter GuiceFilter and an application specific ServletContextListener that extends from GuiceServletContextListener in the web.xml. For example, the web.xml may be as follows:


<filter-name>Guice Filter</filter-name>

<filter-name>Guice Filter</filter-name>


and the application specific servlet context listener may be as follows:

public class GuiceChatConfig extends GuiceServletContextListener {

protected Injector getInjector() {
return Guice.createInjector(new GuiceChatModule());


public class GuiceChatModule  extends ServletModule{

protected void configureServlets(){
Map params = new HashMap();
params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "org.atmosphere.samples.guice");
serve("/chat*").with(AtmosphereGuiceServlet.class, params);

That's it. You can download the previously Atmosphere-Jersey sample, this time Guice enabled from here. For any questions or to download Atmosphere, go to our main site and use our Nabble forum (no subscription needed) or follow us on Twitter and tweet your questions there!

From http://weblogs.java.net/blog/jfarcand

Discover how the Force.com Web Services Connector (WSC) is a code-generation tool and runtime library for use with Force.com Web services, brought to you in partnership with Salesforce.


The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}