cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject Re: [c2] bugs in xsp engine
Date Fri, 13 Apr 2001 12:43:54 GMT
Sylvain Wallez wrote:
> 
> Davanum Srinivas a écrit :
> >
> > Donald,
> >
> > As of right now, the code is sub-sub-sub-optimal as it loads each of the specified
Logicsheets in
> > the XSP and also recursively loads all Logicsheet's referenced in those first set
of LogicSheet's.
> > But now we know it can be done....Any thoughts on optimization? all the code is
in addLogicSheet
> > function of AbstractMarkupLanguage.java

When I posted my general algorithm, it was with two assumptions:

1) The Logicsheet application order is set up BEFORE any processing takes place--hense the
declarations
   in "cocoon.xconf" so the XSP engine has that information.
2) Each logicsheet would be applied once and only once.

The order of application is important in Logicsheets, as well as the number of times it is
applied.
I wonder if we can use an Ordered set with a Comparator that checks for dependancies.  When
the
logicsheets are set up, each Logicsheet will have a list of logicsheets it depends on.  That
way the
Comparator has something to work with, and the set of Logicsheets applied make sense.

A Comparator has an int return value (-1 is "<", 0 is "==", and 1 is ">"), and two Object
parameters.

It would be put together something like this:

class LogicSheetComparator implements Comparator {
    private static final int LT = -1;
    private static final int GT = 1;
    private static final int EQ = 0;

    public int compare(Object one, Object two) {
        LogicSheet first = null;
        LogicSheet second = null;

        if (one instanceof LogicSheet) {
            first = (LogicSheet) one;
        }

        if (two instanceof LogicSheet) {
            second = (LogicSheet) two;
        }

        if (first == null || second == null) {
            if (second != null) return LT;
            if (first != null) return GT;
            return EQ;
        }

        if (first.dependsOn(second)) return GT;
        if (second.dependsOn(first)) return LT;
        return EQ;
    }
}

Apply this Comparator to a OrderedSet, and add the LogicSheets to the set.  The Comparator
will take care of the ordering, and everything will only be applied once (we are using a
Set).

---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message