Update

Geoff Longman <[email protected]> Wed, 8 Feb 2006 03:14:05 -0500
Newsgroups gmane.comp.ide.eclipse.spindle.devel
Message-ID <[email protected]>
This evening I added more tests for the test implementation of
IResource/ICoreResource.

I was trying to figure out how changes in the classpath could be
handled in a nice way. So, I added a removeFile() method which removes
a sub-root from the parent.

But that didn't give me exactly what I needed as the ResourceImpl has
references to the child root and not the parent root.

If I unhook the child from the parent then any resources attached to
the child are now broken as come calls get delegated up to the parent.
And, since the resource is hooked to the now orphan child and
resources hang around for a looong time in come cases, the child could
never be garbage collected.

Since CGLIB is in the classpath already, I'm using Proxy to, well,
build proxies. The parent holds proxies to it's children and the
resources hold a reference to the proxy as well. So, when the child is
removed, the parent sets the proxy target to itself and removes the
proxy from its list of children. The child root is now free for gc.

When a resource delgates a call to the proxy the call goes to the
directly to the parent and the resource is hooked to a different child
root. Eventually there will be no more resources with references to
the proxy and it will get garbage collected.

Why am I putting so much effort into a test fixture? Once reason is
the tests need a pretty much full features implementation of
IResourceRoot/ICoreResource. I already have some tests that depend on
the Eclipse impementation and I think I can cut those test free of
Eclipse now.

The second reason is the new implementation looks to be a lot cleaner
and perhaps better performing than the existing Eclipse impl - perhaps
I will base the new Eclipse stuff on the work I have just done.

Plus, it's a good example to look at for anybody wanting to see how
the crap works.

/spindle-core/src/test/net/sf/spindle/core/resources

its all in there.

Cheers,

Geoff

--
The Spindle guy.          http://spindle.sf.net
Get help with Spindle:   
http://lists.sourceforge.net/mailman/listinfo/spindle-user
Blog:                     http://jroller.com/page/glongman
Feature Updates:          http://spindle.sf.net/updates


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642