i changed mounting so that if the path does not start with a / or the mount package name is an empty string an IllegalArgumentException will be thrown.

The problem with prepending the / to the path automatically is that in the case of public final void mountPath(String path, IMountEncoder encoder) the encoder is already created and probably has an internal reference to the path it was created with (for encoding/decoding the urls) so that if we change the path in our mounting map and not in the encoder things might get out of sync.

-Igor


On 12/11/05, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
i think mountPackage(String path, Class clazz) looks funny. where is the package you are trying to mount? i think it is up to the user to provide a package with a valid name, if the package has an empty string for the name it will be mounted as / . we can also pirnt out a warning in the log. i will factor in mount path into the encoder so that we do not have to keep it in two places.

-Igor





On 12/11/05, Johan Compagner <[EMAIL PROTECTED] > wrote:
This method has to be rewritten:

public final void mountPackage(String path, Package packageToMount)
    {
        if (!path.startsWith("/"))
        {
            path = "/" + path;
        }

        mountPath(path, new PackagePathMountEncoder(path, packageToMount));
    }

to not use the Package object (so that users don't have to do MyClass.class.getPackage())

Because getPackage() doesn't have to return the package it can also return null (and we know that because we already had these problems in wicket!!)

So my fix would be to also give the class object in that method:

public final void mountPackage(String path, Class classForThePackage)
    {
        if (!path.startsWith("/"))
        {
            path = "/" + path;
        }

        mountPath(path, new PackagePathMountEncoder(path, classForThePackage));
    }


and then we can look inside our code if the Package object is there or else extract it as a string from the classname.

johan


Reply via email to