Thiago,

I assume you were talking about the second part with the
contributeUserEventHub service contribution method?  The first snippet
of code works fine.

I had considered putting SessionTracker (the interface) in the
parameter list for the contribution method, but the consequences of
that is the SessionTracker interface must extend the UserEventListener
interface (the UserEventHub listener interface) to make the call to
addUserEventListener work without casting.

That means that SessionTracker clients have unnecessary methods in
their "API" that have to be documented not to be called by clients. I
didn't really want to do that.

I appreciate knowing that autobuild always makes a new instance,
though; that clarifies a few things.

Thanks again,
Les Baker

On Tue, Nov 29, 2011 at 3:09 PM, Thiago H. de Paula Figueiredo
<thiag...@gmail.com> wrote:
> On Tue, 29 Nov 2011 18:04:33 -0200, robert baker <les.baker1...@gmail.com>
> wrote:
>
>> Hi all,
>
>
> Hi!
>
>>    public static SessionTracker buildSessionTracker(
>>            @Autobuild SessionTrackerImpl sessionTrackerImpl,
>>            UserEventHub eventHub) {
>>
>>        eventHub.addUserEventListener(sessionTrackerImpl);
>>
>>        return sessionTrackerImpl;
>>    }
>>    public static void bind(ServiceBinder binder)
>>    {
>>        binder.bind(SessionTracker.class, SessionTrackerImpl.class);
>>        binder.bind(UserEventHub.class, UserEventHubImpl.class);
>>    }
>
>
> You shouldn't use @Autobuild for objects which are already configured as
> services, as @Autobuild will always instantiate a new instance. Without this
> annotation, this parameter will get the SessionTracker object from the
> Registry (i.e. the service registered in Tapestry-IoC).
>
> Try
> public static SessionTracker buildSessionTracker(SessionTracker
> sessionTracker,UserEventHub eventHub) (without @Autobuild)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to