ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen McConnell" <>
Subject RE: Resource.getURL()
Date Mon, 25 Sep 2006 07:23:32 GMT

Scott Stirling wrote:
> Where would these protocols appear from a user perspective? 
> In build scripts? If that's the case, then I'd definitely say 
> consider letting Ant handle them and convert them to standard 
> URLs through a registry mechanism perhaps like the custom 
> task registry.

Dominique Devienne wrote:
> I guess my position on these handlers depends on the ease to 
> install them to a running JVM, and the actual use cases 
> having them would solves. --DD

I've put together an example that demonstrates the hypothetical usage of a
custom URL protocol handler.  The example uses classic Ant to create a path
datatype containing the resources that contain the custom stream handler
class. The next step is to declare the stream handler to Ant using the
hypothetical <handler> datatype.  The <handler> datatype associates the
protocol name with the classpath and the protocol handler classname.  The
next step demonstrates the creation of a new <path> object using the custom
protocol.  In this case I'm declaring a hypothetical pathelement using a
'uri' attribute on the assumption that the protocol of the uri argument is
easily recognizable, and that the stream handler can be resolved by looking
up the named handler.  I'm subsequently referencing the path as an argument
to javac.

  <target name="demo">

    Create a path containing a jar file which holds the 
    custom URL stream handler.

    <path id="handler.path">
      <pathelement location="${user.home}/my-handler.jar"/>

    Create a hypothetical custom url stream handler declaration that
    declares a datatype under the id corresponding to the stream handler 
    protocol, declares the handler classname, and reference the path
    object within which the handler class can be loaded.

    <handler id="artifact" classpathref="handler.path" 

    Declare a path using a hypothetical path element object that takes
    a uri as an argument - the implementation of which could evaluate the 
    the uri scheme and use this to locate the stream handler to be used 
    as a URL constructor argument.  As such, a PathElement.getURL() would
    return an appropriate argument during classloader creation.

    <path id="example.path">
      <pathelement uri="artifact:jar:dpml/util/dpml-cli#1.0.0"/>

    Use the path in some scenario.

    <javac classpathref="example.path" 
      srcdir="target/build/main" destdir="target/classes/main"/>


To summarise - the hypothetical content in this example includes:

  a) the <handler> datatype used to hold a custom URL stream 
     handler class that would be referenced by things like 

  b) The uri attribute on PathElement to allow the declaration 
     of a path element established using a custom URL (which 
     conflicts with the current file-based restrictions within
     the Path implementation but is feasible given the existance
     of Resource.getURL() and underlying support for handler 

Hope this helps!

Cheers, Steve.

Stephen McConnell

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message