Re: Re: enhancement request for Ant event builder task

Thorsten Möller <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <001b01c37c76$a113f250$33d71e8d@Thoro>
Jacob Kjome <[email protected]> wrote:

> I've never actually bothered to use the "template" attribute of the
> <build-events> tag.
And I even think you didn't used another template at all, because of your
Barracuda leadership ;-)

>  What have you used as a sample value for the "template"
> attribute?  Is it a fully qualified path to the file from the root of
> the classloader such as?...
On my tests I used a relative path, ergo not starting with "/" and it
worked. If you view the implementation of Class.getResourceAsStream() method
(Java 1.4.1):

public InputStream getResourceAsStream(String name) {
    name = resolveName(name);
    ClassLoader cl = getClassLoader0();
    if (cl==null) {
        // A system class.
        return ClassLoader.getSystemResourceAsStream(name);
    }
    return cl.getResourceAsStream(name);
}

... as you see, there is a simple delegation to the classloader.
Additionally the Java doc says:
* <p> This method delegates the call to its class loader, after making
* these changes to the resource name: if the resource name starts with
* "/", it is unchanged; otherwise, the package name is prepended to the
* resource name after converting "." to "/". If this object was loaded by
* the bootstrap loader, the call is delegated to
* <code>ClassLoader.getSystemResourceAsStream</code>.

So:

getClass().getResourceAsStream(cs.template)
getClass().getClassLoader().getResourceAsStream(cs.template)

... is pretty the same.


> Oh, and try to make sure you use spaces instead of tabs with
> a 4 spaces indentation.
Sorry, I always use tabs for indentation and was too lazy to alter the IDE
configuration only for this.


Thorsten
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.