Sylvain Wallez wrote:

Carsten Ziegeler wrote:

Daniel Fagerstrom wrote:
The current behaviour is flawed as we already know from e.g. the case with the I18N transformer where dynamic resolution is used when static is what would have been expected. With lazy loading things get even worse as resolution during the setup phase also can become dynamic.

It is time that we solve this problem once and for all.

Yeah, sure, I totally agree. But providing two different source
resolvers creates imho more confusion than it really helps.

And actually 3 resolvers, as we also have the one in setup() of sitemap components :-)

See my long answer to Carsten.

Here's another suggestion that doesn't need a new component.

First of all, when a component is setup (i.e. Avalon lifecycle interfaces), the relative path must *always* be the one where the component is declared, whatever the current environment is. This solves the issues with lazy loading and poolable components that are created on demand.

Yes.

Outside of the component setup, we have the current behaviour where the relative path depends on the current sitemap.

First, I don't think state dependent resolution is especially easy to understand. Second, how can the source resolver know anything about the state of the component that use it?

Now if a component needs to access some resources relative to the place where it was declared, then it *must* resolve that URI during its setup phase.

Example:

class FooTransfomer extends... {
   ServiceManager manager;
   String baseURI;
   SourceResolver resolver;

   public void service(ServiceManager sm) {
       this.manager = sm;
       this.resolver = (SourceResolver)sm.lookup(SourceResolver.ROLE);
       this.baseURI = resolver.resolve("").getURI();
       // yeah, we must also release the source...
   }

   public void doSomething(String sitemapURI, String configURI) {
       // Access data relative to the current sitamep
       Source sitemapSrc = resolver.resolveURI(sitemapURI);

// Access data relative to the place where the component was defined
       Source configSrc = resolver.resolveURI(configURI, baseURI, null);
       ....
   }
}

To me it doesn't seem like a simplification compared to what I proposed. Furthermore as mentioned above, it is not obvious how the source resolver could know anything about the state of the component that use it.

...

/Daniel

Reply via email to