Hi,

Am Freitag, den 18.04.2008, 13:59 +0200 schrieb Carsten Ziegeler:
> Felix Meschberger wrote:
> > Hi,
> > 
> > So, I think we have some kind of a consensus and here is issue SLING-387
> > [1] covering this change.
> > 
> Looks good to me so far. But :) how are we handling the different search 
> path locations? Given that we search in /A and /V, is first /A searched 
> for possible script and only if there is none, /V is searched? Or is the 
> script search alternating between /A and /V?

We must search both locations "at the same" time. I could imagine
something like:

 (1) find best match in /A (aka /apps)
 (2) find better match /V (aka /libs), otherwise use result of (1)

or more code-like:

   match = NIL;
   foreach (String path in resourceResolver.getSearchPath()) {
       newMatch = findMatch(path);
       if (match == NIL or newMatch isBetterThan match) {
           match = newMatch;
       }
   }

This would then be extended by adding another (outer) loop for resource
super type search:

   match = NIL;
   type = resource.getType();
   default = "sling/servlet/default";
   for (;;) {
       // selection
       match = innerLoop(type); // see above
       if (match != NIL) {
           break;
       }
       // endselection
       if (type == default) {
           break;
       }
       type = getResourceSuperType(type);
       if (type == NIL) {
         type = default;
       }
   }

This outer loop only scans the resource super types and default type if
there is no match in earlier loops.

Alternatively we could have the outer loop also behave like the inner
loop: go up the resource super type chain and finally the default type
all the time and only at the end we have the best match. The code for
the selection bracket would then be:

       // selection
       newMatch = innerLoop(type); // see above
       if (match == NIL or newMatch isBetterThan match) {
           match = newMatch;
       }
       // endselection

Not sure, whether this makes sense, though.

Probably about time for a prototype implementation ?

> I think this is missing in the description.

It is.

Regards
Felix

Reply via email to