scijava-common icon indicating copy to clipboard operation
scijava-common copied to clipboard

Better lazy resolution

Open ctrueden opened this issue 11 years ago • 3 comments

MERGE ONLY IN CONCERT WITH THE OTHER 3.0.0 BRANCHES.

This improves the ObjectIndex lazy object resolution feature to only resolve objects as needed based on the type. Previously, as soon as get(Class) or getAll() was called, all pending objects would be resolved. Now we call the new LazyObjects#getType() method to see if the type of the Collection is even worth bothering about.

See also issue #90.

ctrueden avatar Jul 01 '14 20:07 ctrueden

I have come to the conclusion that this approach is simply not good enough in all scenarios. We need to add an ObjectIndex#addLater(LazyObjects, Class) method signature that lets you explicitly specify the type of the objects which will be resolved. Otherwise, the behavior will never be good enough.

I will work on that as soon as I can...

ctrueden avatar Jul 02 '14 21:07 ctrueden

I reworked the branch to add a getType() method to LazyObjects which returns the type of the to-be-resolved objects. This information is then used to decide whether to resolve the objects when ObjectIndex#get(Class) is called.

It is working fine, but is a breaking change from the SJC 2.x.x API, so bumps the snapshot version to 3.0.0. It should be merged only in concert with other breaking SJC branches, particularly robust-io (which is not yet complete).

ctrueden avatar Jul 07 '14 01:07 ctrueden

While rebasing this branch, I noticed a problem with AbstractSingletonService as written. It now has a hard map of instances (due to 1b245c165d7ad40c8945070e5052005dc67d0f6b). I think we should reconsider this—perhaps the cache should be weak and lazy instead. And unit tests, unit tests.

ctrueden avatar May 12 '15 22:05 ctrueden