You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Carsten Ziegeler <cz...@s-und-n.de> on 2003/10/10 12:35:02 UTC

Question about the compileScript method in the JavaScriptInterpreter

The compileScript method in the JavaScriptInterpreter looks like this:

>    public Script compileScript(Context cx,
>                                Environment environment,
>                                String fileName) throws Exception {
>        Source src = environment.resolveURI(fileName);

I'm wondering why here the environment is needed for resolving the source.
A usual source resolver should do the trick as well, no?
If we would use the source resolver we could release the source
cleanly and we avoid the hacky dependency that the environment
accidentally implements source resolver as well.

What do you think?

Carsten 


RE: Question about the compileScript method in the JavaScriptInterpreter

Posted by Carsten Ziegeler <cz...@s-und-n.de>.
Sylvain Wallez wrote:
> 
> Actually, the whole flow stuff abuses the use or Environment, when it 
> simply needs the object model. On my todo list is some refactoring to 
> remove all uses of environment in the flow, unless someone else 
> volunteers for it.
> 
> In the meantime, we can simply replace uses of the Environment by the 
> real SourceResolver where needed.
> 
Ok.

> BTW, regarding the forthcoming refactoring of Environment: is this 
> "accidental" implementation of SourceResolver really needed?
> 
No, not anymore. It was in 2.0.x but starting with 2.1 I think it's
only for compatibility.

Carsten

Re: Question about the compileScript method in the JavaScriptInterpreter

Posted by Sylvain Wallez <sy...@anyware-tech.com>.
Carsten Ziegeler wrote:

>The compileScript method in the JavaScriptInterpreter looks like this:
>  
>
>>   public Script compileScript(Context cx,
>>                               Environment environment,
>>                               String fileName) throws Exception {
>>       Source src = environment.resolveURI(fileName);
>>    
>>
>
>I'm wondering why here the environment is needed for resolving the source. A usual source resolver should do the trick as well, no? If we would use the source resolver we could release the source cleanly and we avoid the hacky dependency that the environment accidentally implements source resolver as well.
>  
>

Actually, the whole flow stuff abuses the use or Environment, when it 
simply needs the object model. On my todo list is some refactoring to 
remove all uses of environment in the flow, unless someone else 
volunteers for it.

In the meantime, we can simply replace uses of the Environment by the 
real SourceResolver where needed.

BTW, regarding the forthcoming refactoring of Environment: is this 
"accidental" implementation of SourceResolver really needed?

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }
Orixo, the opensource XML business alliance  -  http://www.orixo.com