Hi all,

I set up a service, UserEventHub, to send notifications of logon and
logoff application wide in our app.  Right now, one listener is wired
up to it, SessionTrackerImpl, an implementation class of another
service in my app, SessionTracker. (SessionTrackerImpl also implements
UserEventListener, the listener interface for the UserEventHub).  I
used a technique I saw in TapestryModule to wire the listener up;
here's what my AppModule.java looks like with regard to those two
services:


public class AppModule
{
    public static void bind(ServiceBinder binder)
    {
        binder.bind(UserEventHub.class, UserEventHubImpl.class);
    }

    public static SessionTracker buildSessionTracker(
            @Autobuild SessionTrackerImpl sessionTrackerImpl,
            UserEventHub eventHub) {

        eventHub.addUserEventListener(sessionTrackerImpl);

        return sessionTrackerImpl;
    }

    // and so forth...
}


This works just fine.

However, let's say I wanted to have the ability to control the order
that objects get added, for example, as I add more objects to the hub,
I may want some listeners to get a log on notification before others
(say, for sake of argument, they were doing initialization where the
order of it was critical).  It seems like Tapestry IoC's configuration
facility would be the right solution for this.  Here's what I did:

public class AppModule
{
    public static void bind(ServiceBinder binder)
    {
        binder.bind(SessionTracker.class, SessionTrackerImpl.class);
        binder.bind(UserEventHub.class, UserEventHubImpl.class);
    }

    @Contribute(UserEventHub.class)
    public static void contributeUserEventHub(
            OrderedConfiguration<UserEventListener> configuration,
            @Autobuild SessionTrackerImpl sessionTrackerImpl) {

        configuration.add("SessionTracker", sessionTrackerImpl);
    }
}


Now the service acts like it's getting built twice (which was causing
subtle, hair-tearing bugs).  I can kinda see how that is happening
(autobuilt parameter and the bind call), but how can I setup
contributions to UserEventHub that are also services themselves (that
need to be visible as such)?  Or is this even the right way to go
about this?

Does this make any sense?  Thanks so much in advance for any help provided.

Thanks,
Les Baker

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

Reply via email to