Thanks Carsten!
I got my source working now, but it's awfully slow. The source gets a specially modified zip-file from any cocoon source (context used) and after working on it, extracts a file from this zipped package. The slow section seems to be the unzipping part. Also, no caching seems to happen by Cocoon. A web page that called this source 10 times took 20 seconds to load on a fairly fast machine. The zip file is only 84Kb!
Any optimization tips? Didn't think Java's zip-utilities are so slow...
-Tuomo
On Wed, 29 Dec 2004, Carsten Ziegeler wrote:
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
