Question

After discovering the Lookup library in the Netbeans Platform (7.3), I wondered : (how) are objects removed from lookup ? Is there any garbage-collecting or something ?

I noticed that each time something is adding an object to the Lookup, the object was never "released" from the Lookup, which is pretty logical since its aim is to keep objects.

After browsing a while (Geertjan's blog, DZone, NB API docs etc., not just a "oh I don't find it in Google!"), I did not find how to remove an element from the lookup, eg. a message that would be sent through Lookup and deleted once used by all listeners.

This introduces these questions to me : how to ensure a given "listening order", and how to know the object has been "read" by all listeners ?

I feel I'm thinking wrong about how to use it.

Every idea, link or tip is welcome !

EDIT

I was thinking about this question tonight, and I saw how to reformulate it another way :

Is it possible to use the Lookup manager not only as a service catalogue/index, but also as a messaging service ? The docs around the net did not gave me the answer.

As I would use it (thats's why I wrote "I feel I'm thinking wrong about how to use it."), I would put messages into the Lookup to fire actions elsewhere, but it implies the messages be read only once by each listener, and to be destroyed after that.

The main question is about transferring data through the Lookup and not only storing it.

I found this short article about lookup data transfer, but it sounds wrong to me, since objects seems never being released from the lookup.

Was it helpful?

Solution

I would do it the other way round. I would register the listeners as #ServiceProvider. The part that generates you Object would request all listeners from the global lookup and call them.

Another way could be the usage of InstanceContent. But this could cause a too loose contract.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top