Hello, 2008/11/8 Richard S. Hall <[EMAIL PROTECTED]>
> > > Todor Boev wrote: > >> Richard S. Hall wrote: >> >> When a thread enters the POJO, it creates a copy of any services the >>> thread uses until the thread exits the POJO (even if the thread calls out >>> from the POJO and re-enters it). When the thread makes a request for a >>> service it always gets the same copy, so the thread never sees a different >>> value. >>> >>> Of course, it is possible that its copy has departed and stopped working, >>> so it may throw exceptions, but that is the nature of OSGi programming, so >>> that is to be expected. >>> >> >> Couple of more questions :) >> >> 1) I have wondered for some time now why did you go with this >> thread-local-like caching? >> > > It was the only way that we could think of to make synchronization > transparent. Exactly, the Thread local is used to hide synchronization issues. When a thread access to a service, a copy of these services is stored inside the thread local. Then, if the thread re-access to the same service dependency in the same "method stream", iPOJO reinjects the same service objects. So, it avoid the most part of synchronized blocks when accessing services as iPOJO ensures that the same service objects are re-used. Of course, as Rick explained, if a service departs and "invalidates" itself, accessing to the service object can throw errors. > > > >> 2) Is the caching implemented by the "requires" handler? I have some plans >> to implement my flavor of service tracking handler where I believe this >> caching will not be required. >> > > Not sure, Clement will have to answer that. The caching is implemented by the Dependency Handler. However, dependency management is made inside a helper class managing the iPOJO dependency model. The handler just manages the injection and the caching, the dynamism management is mostly managed in the helper class. So, to provide a new type of service dependency, you can rely on this class (extend it) and manage your own behavior. Clement > > > -> richard > > > >> Todor >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > >