Return-Path: Delivered-To: apmail-cocoon-dev-archive@www.apache.org Received: (qmail 20919 invoked from network); 29 Dec 2004 15:11:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 29 Dec 2004 15:11:47 -0000 Received: (qmail 16062 invoked by uid 500); 29 Dec 2004 15:11:37 -0000 Delivered-To: apmail-cocoon-dev-archive@cocoon.apache.org Received: (qmail 15990 invoked by uid 500); 29 Dec 2004 15:11:37 -0000 Mailing-List: contact dev-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: dev@cocoon.apache.org Delivered-To: mailing list dev@cocoon.apache.org Received: (qmail 15956 invoked by uid 99); 29 Dec 2004 15:11:36 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from minotaur.apache.org (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Wed, 29 Dec 2004 07:11:36 -0800 Received: (qmail 20848 invoked from network); 29 Dec 2004 15:11:34 -0000 Received: from localhost.hyperreal.org (HELO ?127.0.0.1?) (127.0.0.1) by localhost.hyperreal.org with SMTP; 29 Dec 2004 15:11:34 -0000 Message-ID: <41D2C997.6050607@apache.org> Date: Wed, 29 Dec 2004 16:13:27 +0100 From: Carsten Ziegeler User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: dev@cocoon.apache.org Subject: Re: SourceResolver for custom Source (and SourceFactory) References: In-Reply-To: X-Enigmail-Version: 0.89.5.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: localhost.hyperreal.org 1.6.2 0/1000/N X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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