You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bill Lear <ra...@zopyra.com> on 2003/04/22 17:25:02 UTC

PrivateAsset

I am trying to convert code which uses a pre- 2.4 PrivateAsset class.
So far, none of the documentation has been much help, and there are no
uses of Abstract, Context, External, or Private asset classes in the
examples directories.

I am trying to convert this usage:

    PrivateAsset asset = new PrivateAsset(URL);

where URL is a String.

The API for PrivateAsset contains no information on the arguments for
the constructor PrivateAsset(ClasspathResourceLocation
resourceLocation, ILocation location), so I track down the first of
the two, and it has a constructor
ClasspathResourceLocation(IResourceResolver resolver, String path)
that also does not have documentation about the arguments.

So I look at the first, finding that it has only one implementing
class, DefaultResourceResolver.  Looking at that, it appears I can
build one using the no-arg constructor, so the first argument of
ClasspathResourceLocation is taken care of (hopefully).  The second
argument I guess is some sort of root path, or perhaps the URL, but
I'm not sure.  I guess it is the URL and continue on ...

Not sure what ILocation is/does, I look at it's doc.  The doc says
"TODO Add Type comment", which is not too inspiring, so I look at the
implementing class, Location.

This class offers no documentation whatsoever, with three different
constructors, so I choose the simplest.  It takes an IResourceLocation
object, which the doc says "Describes the location of a resource", but
since the first argument for the PrivateAsset constructor is a
ClassPathResourceLocation, I'm puzzled.

The two concrete classes which implement the IResourceLocation
interface are ClassPathResourceLocation and ContextResourceLocation.

So, now I have to guess again, and decide to just set this argument to
null to see if it compiles, and I end up with:


    PrivateAsset asset = new PrivateAsset(
        new ClasspathResourceLocation(new DefaultResourceResolver(), URL),
        null);

which happens to compile just fine, although I really have no idea
whether it is gibberish, close to right, or spot-on.

I do notice that the developer doc says "That is, the path name
provided is used as the basis for a search that takes into account the
desired locale", so perhaps what I really want is this:

    PrivateAsset asset = new PrivateAsset(
        new ClasspathResourceLocation(new DefaultResourceResolver(), URL),
        new ClasspathResourceLocation(new DefaultResourceResolver(), "/"))

But, I'm just not sure.

I really do think the doc needs some thorough revising in this regard
before 3.0 goes out the door.

Could anyone offer help to straighten this out for me, please?

Thanks.


Bill

Re: PrivateAsset

Posted by Geoff Longman <gl...@intelligentworks.com>.
Oops, the type comment is my fault.

I wan't sure what to put in there, Locations refer to the location a
particular bit is found in a source file? However, that might not be
complete as there is an IResourceLocation in there too. Howard?

Geoff

----- Original Message -----
From: "Bill Lear" <ra...@zopyra.com>
To: <ta...@jakarta.apache.org>
Sent: Tuesday, April 22, 2003 11:25 AM
Subject: PrivateAsset


> I am trying to convert code which uses a pre- 2.4 PrivateAsset class.
> So far, none of the documentation has been much help, and there are no
> uses of Abstract, Context, External, or Private asset classes in the
> examples directories.
>
> I am trying to convert this usage:
>
>     PrivateAsset asset = new PrivateAsset(URL);
>
> where URL is a String.
>
> The API for PrivateAsset contains no information on the arguments for
> the constructor PrivateAsset(ClasspathResourceLocation
> resourceLocation, ILocation location), so I track down the first of
> the two, and it has a constructor
> ClasspathResourceLocation(IResourceResolver resolver, String path)
> that also does not have documentation about the arguments.
>
> So I look at the first, finding that it has only one implementing
> class, DefaultResourceResolver.  Looking at that, it appears I can
> build one using the no-arg constructor, so the first argument of
> ClasspathResourceLocation is taken care of (hopefully).  The second
> argument I guess is some sort of root path, or perhaps the URL, but
> I'm not sure.  I guess it is the URL and continue on ...
>
> Not sure what ILocation is/does, I look at it's doc.  The doc says
> "TODO Add Type comment", which is not too inspiring, so I look at the
> implementing class, Location.
>
> This class offers no documentation whatsoever, with three different
> constructors, so I choose the simplest.  It takes an IResourceLocation
> object, which the doc says "Describes the location of a resource", but
> since the first argument for the PrivateAsset constructor is a
> ClassPathResourceLocation, I'm puzzled.
>
> The two concrete classes which implement the IResourceLocation
> interface are ClassPathResourceLocation and ContextResourceLocation.
>
> So, now I have to guess again, and decide to just set this argument to
> null to see if it compiles, and I end up with:
>
>
>     PrivateAsset asset = new PrivateAsset(
>         new ClasspathResourceLocation(new DefaultResourceResolver(), URL),
>         null);
>
> which happens to compile just fine, although I really have no idea
> whether it is gibberish, close to right, or spot-on.
>
> I do notice that the developer doc says "That is, the path name
> provided is used as the basis for a search that takes into account the
> desired locale", so perhaps what I really want is this:
>
>     PrivateAsset asset = new PrivateAsset(
>         new ClasspathResourceLocation(new DefaultResourceResolver(), URL),
>         new ClasspathResourceLocation(new DefaultResourceResolver(), "/"))
>
> But, I'm just not sure.
>
> I really do think the doc needs some thorough revising in this regard
> before 3.0 goes out the door.
>
> Could anyone offer help to straighten this out for me, please?
>
> Thanks.
>
>
> Bill
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>


RE: PrivateAsset

Posted by "Howard M. Lewis Ship" <hl...@attbi.com>.
All the asset classes are driven by the specifications:  <context-asset>,
<external-asset> and <private-asset>.  I don't know why you would be
concerned with using them in code.  At most, you might code against the
IAsset interface.

I'll take a peek at those classes; there just was a bit of a shuffle with
Geoff's code (he turned all the specification classes into interfaces).

The location property is used to relate an IAsset instance back to a file
location: a file and a line (and maybe even a column).  Most objects in
Tapestry have such a property, it is used in line-precise exception
reporting.

The idea is that when you read a specification file and create specification
objects from it, the objects as "tagged" with locations.  When you create
runtime objects (such as PrivateAsset or ExpressionBinding) from the
specification objects, the runtime objects carry the location forward.

Also, sometimes it appears that documentation is missing, because classes
inherit javadoc from their super-classes and interfaces and there's no need
(in fact, there's a disincentive) to document in both locations.

If an exception is thrown by a runtime object, the location is there in the
exception; now you know that link 18 of Home.html has an error on it that
caused a runtime exception.  Magic.

--
Howard M. Lewis Ship
Creator, Tapestry: Java Web Components
http://jakarta.apache.org/tapestry



> -----Original Message-----
> From: Bill Lear [mailto:rael@zopyra.com] 
> Sent: Tuesday, April 22, 2003 11:25 AM
> To: tapestry-user@jakarta.apache.org
> Subject: PrivateAsset
> 
> 
> I am trying to convert code which uses a pre- 2.4 
> PrivateAsset class. So far, none of the documentation has 
> been much help, and there are no uses of Abstract, Context, 
> External, or Private asset classes in the examples directories.
> 
> I am trying to convert this usage:
> 
>     PrivateAsset asset = new PrivateAsset(URL);
> 
> where URL is a String.
> 
> The API for PrivateAsset contains no information on the 
> arguments for the constructor PrivateAsset(ClasspathResourceLocation
> resourceLocation, ILocation location), so I track down the 
> first of the two, and it has a constructor 
> ClasspathResourceLocation(IResourceResolver resolver, String 
> path) that also does not have documentation about the arguments.
> 
> So I look at the first, finding that it has only one 
> implementing class, DefaultResourceResolver.  Looking at 
> that, it appears I can build one using the no-arg 
> constructor, so the first argument of 
> ClasspathResourceLocation is taken care of (hopefully).  The 
> second argument I guess is some sort of root path, or perhaps 
> the URL, but I'm not sure.  I guess it is the URL and continue on ...
> 
> Not sure what ILocation is/does, I look at it's doc.  The doc 
> says "TODO Add Type comment", which is not too inspiring, so 
> I look at the implementing class, Location.
> 
> This class offers no documentation whatsoever, with three 
> different constructors, so I choose the simplest.  It takes 
> an IResourceLocation object, which the doc says "Describes 
> the location of a resource", but since the first argument for 
> the PrivateAsset constructor is a ClassPathResourceLocation, 
> I'm puzzled.
> 
> The two concrete classes which implement the 
> IResourceLocation interface are ClassPathResourceLocation and 
> ContextResourceLocation.
> 
> So, now I have to guess again, and decide to just set this 
> argument to null to see if it compiles, and I end up with:
> 
> 
>     PrivateAsset asset = new PrivateAsset(
>         new ClasspathResourceLocation(new 
> DefaultResourceResolver(), URL),
>         null);
> 
> which happens to compile just fine, although I really have no 
> idea whether it is gibberish, close to right, or spot-on.
> 
> I do notice that the developer doc says "That is, the path 
> name provided is used as the basis for a search that takes 
> into account the desired locale", so perhaps what I really 
> want is this:
> 
>     PrivateAsset asset = new PrivateAsset(
>         new ClasspathResourceLocation(new 
> DefaultResourceResolver(), URL),
>         new ClasspathResourceLocation(new 
> DefaultResourceResolver(), "/"))
> 
> But, I'm just not sure.
> 
> I really do think the doc needs some thorough revising in 
> this regard before 3.0 goes out the door.
> 
> Could anyone offer help to straighten this out for me, please?
> 
> Thanks.
> 
> 
> Bill
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
>