cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carsten Ziegeler" <>
Subject RE: SourceResolving in non-sitemap components
Date Wed, 12 Jun 2002 13:07:34 GMT
Stuart Roebuck wrote:
> I'm trying to get my head round SourceResolving and would be grateful 
> for clarification.
> There appear to be at a number of SourceResolver classes:
> > 	org.apache.excalibur.source.SourceResolver
This is the real source resolver.

> >  	org.apache.avalon.excalibur.source.SourceResolver
Forget this one, it has removed. Basically it was the same
as the first one, but then the excalibur team decided to
remove "avalon" from the package names for new components.

> >  	org.apache.cocoon.environment.SourceResolver
This is a convenience source resolver which is passed to the sitemap
components. It inherits from org.apache.excalibur.source.SourceResolver
and adds a usefull toSAX() method especiall for Cocoon.

org.apache.excalibur.source.SourceResolver is a real component,
so you can look it up everywhere you have a ComponentManager.
You can use this component to get Source objects by calling
resolveURI() and you have to release() them later on.

> I want to use a SourceResolver in one Component but in two different 
> kinds of context.
> In the first case, I would like to use a SourceResolver during 
> Configuration to obtain a ModifiableSource relative to the root context, 
> and then refer to it from time to time.  I think that I need something 
> like this...
> >        this.resolver = (SourceResolver) 
> > this.manager.lookup(SourceResolver.ROLE);
> > 		Source source = 
> this.resolver.resolveURI("context://path/to/file");
> > 		// Do something with source
> >
> > 		// After a while... (when source may have changed)
> > 		if (source instanceof ModifiableSource) {
> > 			( (ModifiableSource) source).refresh()
> > 			}
> > 		// Do something else with source
> >
> > 		// Finally (not sure if this is required)
> > 		this.resolver.release(source);
Yes, exactly with the exception that the ModifiableSource interface
is deprecated. You have to use the discardValidity() method of
the Source interface instead.
> In the second case I would like to be able to use a SourceResolver to 
> obtain a Source relative to current context when this component is 
> called from within another sitemap component.  In these cases a 
> SourceResolver is already passed to the Action or Generator, so I can 
> pass this on to my component for use.
Yes, exactly.


Carsten Ziegeler     Chief Architect     Open Source Group, S&N AG
             Cocoon Consulting, Training and Projects

To unsubscribe, e-mail:
For additional commands, email:

View raw message