You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Peter Beshai <pe...@gmail.com> on 2007/03/21 01:10:23 UTC

T5 Custom AssetFactory

I am trying to create my own AssetFactory to read assets from a filesystem,
but I'm getting an exception.

My AppModule ~has the following:

public AssetFactory buildMyAssetFactory(@InjectService("ResourceCache")
            ResourceCache resourceCache) {
        return new MyAssetFactory(resourceCache);
    }

    public void contributeAssetSource(MappedConfiguration<String,
AssetFactory> configuration,
            @InjectService("MyAssetFactory") AssetFactory myAssetFactory)
    {
        configuration.add("myassets", myAssetFactory);
    }

My page has:
@Inject("myassets:path to file")
private Asset _myFile;

public Asset getMyFile() { return _myFile; }


The factory is currently a clone of the ClasspathAssetFactory (while I
figure things out), except the path it returns is prefixed with
"fromMyAssets" for testing purposes.

The exception I get when I try to load the page is :

java.lang.RuntimeException
Unable to locate asset 'classpath:path to file' (the file does not exist).

Stack trace

        *
org.apache.tapestry.internal.services.AssetSourceImpl.findRelativeAsset(
AssetSourceImpl.java:101)
        * org.apache.tapestry.internal.services.AssetSourceImpl.findAsset(
AssetSourceImpl.java:92)
        * component <init> ...

I am not sure why it reads classpath:path to file instead of myassets:path
to file or what approach I should take to solve this issue. Any help is
appreciated :-)
-- 
Peter Beshai

Computer Science Student
University of Waterloo

Re: T5 Custom AssetFactory

Posted by Howard Lewis Ship <hl...@gmail.com>.
Something looks very odd there, I can't imagine where "classpath:"
would come from.  Are you sure it isn't
"classpath:myassets:path.to.file"?  That I think I could explain.

Just make sure you are using the prefix consistently.

Also, remember that for AppModule changes, you do need to restart for
changes to be picked up.  Only components (including pages) get the
special reload logic.

On 3/20/07, Peter Beshai <pe...@gmail.com> wrote:
> I am trying to create my own AssetFactory to read assets from a filesystem,
> but I'm getting an exception.
>
> My AppModule ~has the following:
>
> public AssetFactory buildMyAssetFactory(@InjectService("ResourceCache")
>             ResourceCache resourceCache) {
>         return new MyAssetFactory(resourceCache);
>     }
>
>     public void contributeAssetSource(MappedConfiguration<String,
> AssetFactory> configuration,
>             @InjectService("MyAssetFactory") AssetFactory myAssetFactory)
>     {
>         configuration.add("myassets", myAssetFactory);
>     }
>
> My page has:
> @Inject("myassets:path to file")
> private Asset _myFile;
>
> public Asset getMyFile() { return _myFile; }
>
>
> The factory is currently a clone of the ClasspathAssetFactory (while I
> figure things out), except the path it returns is prefixed with
> "fromMyAssets" for testing purposes.
>
> The exception I get when I try to load the page is :
>
> java.lang.RuntimeException
> Unable to locate asset 'classpath:path to file' (the file does not exist).
>
> Stack trace
>
>         *
> org.apache.tapestry.internal.services.AssetSourceImpl.findRelativeAsset(
> AssetSourceImpl.java:101)
>         * org.apache.tapestry.internal.services.AssetSourceImpl.findAsset(
> AssetSourceImpl.java:92)
>         * component <init> ...
>
> I am not sure why it reads classpath:path to file instead of myassets:path
> to file or what approach I should take to solve this issue. Any help is
> appreciated :-)
> --
> Peter Beshai
>
> Computer Science Student
> University of Waterloo
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org