Hello, Seems I have been chewing on the service dynamics issue forever. Just as I though I got a workable concept about tracking and releasing services I stumble on a contradicting concept. The problem is this:
According to my understanding it is not acceptable importer behavior to ever call service objects that are unregistered. Achieving this requires the service to be tracked and every piece of code that calls the service be synchronized with the tracking code. I'll name this the "dedicated lock approach": private Object lock; private Hello service; void set(Hello service) { synchronized (lock) { this.service = service; } } Hello get() { synchronized (lock) { if (service == null) { throw new ServiceUnavailableException(); } return service; } } void usefulMethod() { synchronized (lock) { get().greet("World"); } } Some say we should never call out from the bundle while holding a lock but I think we are safe if we use a dedicated private lock for every tracked service. In any case I can't think of any other way to be safe at all times. Lately however I have been encountering the "local-cache" approach, which seems to state we don't need to be that paranoid. E.g. void usefulMethod() { Hello service = get(); /* At this spot right here the service can go down! */ service.greet("World"); } Here we risk calling a service in an undetermined state. Do we expect every exporter to invalidate his objects to keep us safe? E.g. the exporter must keep a "closed" flag around, mark the service as invalid in a thread-safe manner, and start tossing exceptions at callers from that point on. iPojo follows the local cache approach - right Richard? Peaberry follows the dedicated lock approach - right Stuart? I'd be grateful if you help me compare these import modes. That is if I got it right who uses what :) Cheers, Todor --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@felix.apache.org For additional commands, e-mail: users-h...@felix.apache.org