cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carsten Ziegeler <cziege...@apache.org>
Subject Re: SourceResolver for custom Source (and SourceFactory)
Date Wed, 29 Dec 2004 15:13:27 GMT
Tuomo L wrote:
> Hi,
> 
> I'm writing a custom Source and SourceFactory for Cocoon, which takes 
> uris in this form: mysource:context://foo/bar.zip:mydir/myfile.gif.
> 
> The part between the two ":"'s is a "sub-uri", which I need to resolve. 
> How can I do this, so that any Cocoon URI works, for example: 
> cocoon://foo.bar and html://foo.bar ? The Source stuff seems to be 
> changed lately, so what is the right way to go?
> 
Just implement a SourceFactory with your own Source - you can lookup
the SourceResolver in your implementation and use the resolver to
resolve any Cocoon uri. So in your example above, you have a factory
for your mysource: protocol and inside the factory you use the
resolver to resolve the context: protocol.

There is only one subtle trick with using a resolver inside a
source factory: you can't lookup this component inside the service()
method. If you do so, you end up in an initialization loop.
You have to do a lazy look up of the resolver: the first time you
really need it.

HTH
Carsten

Mime
View raw message