Binding a Broadcaster with Guice

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Binding a Broadcaster with Guice

Christopher Piggott
Hi,

In a jersey-guice-atmosphere application, in the module's
configureServlets(), I'm trying to do this:

                bind(Broadcaster.class).annotatedWith(HomeAutomationBroadcaster.class).
                                toInstance(new DefaultBroadcaster("home"));

but it dumps out with a null pointer exception in that constructor.
It blows up in DefaultBroadcaster method setID() right here:

        Broadcaster b =
BroadcasterFactory.getDefault().lookup(this.getClass(), id);

Apparently, binding the broadcaster, so that I can have it injected
into my resources (which are @RequestScoped) and elsewhere, is not
possible.

What's the correct way to do this?

--Chris
Reply | Threaded
Open this post in threaded view
|

[[atmosphere-users]] Re: Binding a Broadcaster with Guice

Jeanfrancois Arcand-4
Salut,

sound like a missing feature. Can you file a bug here::

http://java.net/jira/secure/CreateIssue!default.jspa

Thanks!

- Jeanfrancois

On 11-09-10 9:20 AM, Christopher Piggott wrote:

> Hi,
>
> In a jersey-guice-atmosphere application, in the module's
> configureServlets(), I'm trying to do this:
>
> bind(Broadcaster.class).annotatedWith(HomeAutomationBroadcaster.class).
> toInstance(new DefaultBroadcaster("home"));
>
> but it dumps out with a null pointer exception in that constructor.
> It blows up in DefaultBroadcaster method setID() right here:
>
>          Broadcaster b =
> BroadcasterFactory.getDefault().lookup(this.getClass(), id);
>
> Apparently, binding the broadcaster, so that I can have it injected
> into my resources (which are @RequestScoped) and elsewhere, is not
> possible.
>
> What's the correct way to do this?
>
> --Chris