One other thing I should point out - the scenario I was worried about (a
c'tor calling another service) isn't the only problem with the current
design.  If a c'tor is slow (or worse hangs) the current code will not
allow *any* other services (in the scope) to run.  The approach below at
least allows other services to be invoked.
-Dug


Glen - got kicked off of irc but I think the problem would be solved by
something like this:
String lockObject = null ;
Object service = null ;
sync (session) {
  Hashtable  locks = session.get("AxisLocks");
  if ( locks == null )  session.set("AxisLocks", locks = new Hashtable() );
  if ( (lockObject = locks.get(serviceName)) == null )
    locks.put(serviceName, lockObject = new String(serviceName));  //
String can be anything
}
sync(lockObject) {
  service = session.get(serviceName);
  if ( service == null ) session.set(serviceName,
service=getNewService(...));
}

The first sync would only allow one thread to modify the locks hashtable at
a time - which is ok since the updates to the table would not be recursive
at all.  And the second sync would prevent multiple hits to the exact same
c'tor within the desired scope - rather than _any_ c'tor in the scope like
it is now.  So, this would lift the restriction that a c'tor can't call a
web service on the same server, but it won't allow the c'tor for a service
to invoke the same service - which I think would be ok - for now  :-).
Whatcha think?
-Dug


Reply via email to