Me again, with yet another question.

For the value encoder, I want to
include which session object should be used (e.g. the one with the red
marker, or the one with the blue marker). Now there appears to be no way to
figure this out, except iterating over all session objects and calling
session.contains(object).

Well, I can iterate over all session objects,
but session is a shadowed property of the per-thread manager, which may not
have been realized. Realizing every session is not something we want to do,
so I'm looking for a good way to determine if a session has been realized.
Obviously, I checked out the ServiceActivityScoreboard service.

Now there
are two issues with the scoreboard. I could file issues on them in JIRA but
I'm not sure if the concept is right.
1. I would like to see
ServiceActivity have getMarkers() or a similar construct. Howard's comment
in a different thread about Tapestry moving towards Guice in the sense of
using serviceinterface+markers instead of service id's especially rubbed my
thoughts on this.
2. It appears the ServiceActivity does not track
perthread services as I would expect. The following test case will fail on
the last assertion.

 private Status
getServiceActivityStatus(ServiceActivityScoreboard sb, String serviceId) {

// todo: instead of serviceId, get serviceInterface+markers
 for
(ServiceActivity sa : sb.getServiceActivity()) {
 if
(sa.getServiceId().equals(serviceId)) return sa.getStatus();
 }
 return
null;
 }

 @Test
 public void temporary_test() {
 Registry r =
buildRegistry(HibernateCoreModule.class, RedModule.class,
BlueModule.class);

 r.performRegistryStartup();

 final ObjectLocator
locator = r;
 final ServiceActivityScoreboard sb =
locator.getService(ServiceActivityScoreboard.class);


assertTrue(getServiceActivityStatus(sb, "SessionRed") == Status.DEFINED);


Thread t1 = new Thread(new Runnable() {
 public void run() {
 Session red =
locator.getService(Session.class, Red.class);


assertTrue(getServiceActivityStatus(sb, "SessionRed") == Status.VIRTUAL);


Book myBook = new Book();
 myBook.setAuthor("Robert Jordan");

myBook.setTitle("The Gathering Storm");

 red.persist(myBook);


assertTrue(getServiceActivityStatus(sb, "SessionRed") == Status.REAL);
 }

});

 t1.start();
 try {
 t1.join();
 } catch (InterruptedException ex) {

fail("Interrupted");
 }

 // We are back in the thread that does not have
session red realized
 // In this thread, it should be DEFINED

assertTrue(getServiceActivityStatus(sb, "SessionRed") == Status.DEFINED);

}

I think modifying the service activity stuff to do this right (as in,
right as I see it) should be an easy change. Is my reasoning
correct?

Thanks.

Reply via email to