On Tue, Jun 23, 2009 at 10:21 AM, Paul Lindner <plind...@linkedin.com>wrote:

> We now have Guice 2.0, nice things..
>
> http://code.google.com/p/google-guice/wiki/Guice20
> This allows some nice things like the following code snippet.  Does anyone
> want to come up with what changes we'd like to see in the way shindig uses
> Guice and especially how we interact with integrators...


multibindings and provider methods would improve a lot of things.

For the case below, multibindings would be much better -- different modules
could contribute their own handlers.


>
>
>
> @@ -66,14 +68,17 @@ public class SocialApiTestsGuiceModule extends
> AbstractModule {
>
>
> bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.json")).to(
>         BeanJsonConverter.class);
>
> -    bind(new TypeLiteral<Set<Object>>(){}).annotatedWith(
> -        Names.named("org.apache.shindig.social.handlers"))
> -        .toInstance(ImmutableSet.<Object>of(ActivityHandler.class,
> AppDataHandler.class,
> -            PersonHandler.class, MessageHandler.class));
> -
>     bind(String.class).annotatedWith(
>         Names.named("shindig.containers.default"))
>         .toInstance("res://containers/default/container.js");
>     bind(ContainerConfig.class).to(JsonContainerConfig.class);
>   }
> +
> +  @Provides
> +  @Singleton
> +  @Named("org.apache.shindig.social.handlers")
> +  Set<Object> getHandlers() {
> +    return ImmutableSet.<Object>of(ActivityHandler.class,
> AppDataHandler.class, PersonHandler.class, MessageHandler.class);
> +  }
> +
>  }
>

Reply via email to