[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Does ScopeKey need to maintain a sorted (in ScopeLevel.l

smarlow@redhat.com do-not-reply at jboss.com
Tue Aug 4 11:32:13 EDT 2009


Internally, I started a second unordered collection in ScopeKey but haven't switched over the cases that need the ordered collection yet (for obvious reasons :).

Looking at the cases for ordered access to ScopeKey.scopes, I see the following methods that seem to need sorted access to ScopeKey.scopes collection.

1.  The getParent() which returns a collection of Scopes (in sorted order).  The parent seems to be all Scopes except the highest ScopeLevel entry (last value in ScopeKey.scopes collection).  In my search for meaning, I will assert that the child value must always be the one with the highest ScopeLevel.  I haven't yet come across any processing for the child only, so maybe there really isn't a "child" concept embedded into the code.  If this was a Lisp list, I might almost mistake getParent as returning some sort of "cdr" (except from the tail instead of list head).

2.  isParent(ScopeKey key), returns true if the passed key's Scopes match the "this" Scopes (ignoring the last entry, which I will again call the child for no good reason).

3.  getScopes() returns immutable collection of the Scopes (in sorted order).  One caller to getScopes(), that might need a sorted result is in DefaultScopeBuilder.initMetaDataRetrieval which builds a collection of metadata in the lowest to highest ScopeLevel order.  AbstractScopeInfo also depends on a sorted result from getScopes().  FuzzyMetaDataRepositoryVisitor also depends on getScopes returning a sorted result.  

There could be other dependencies (on a sorted result) that I missed as well.

It doesn't seem very difficult to eliminate the get/is Parent depenency on a sorted scopes collection as we always know the "maxScopeLevel" which identifies the "child" entry (I'm still not sure if it is correct to refer to the last entry as the "child" ;).  Given an unordered collection, getParent, returns all entries minus the "maxScopeLevel" and the same can be used for isParent checking.

This leaves getScopes(), I'll wait to hear responses to this post before drilling further into getScopes().  



View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4247911#4247911

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4247911



More information about the jboss-dev-forums mailing list