You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by MORITA Hajime <om...@dodgson.org> on 2004/01/13 02:15:15 UTC

[jelly] JellyContext.newJellyContext side-effect

Hello.

I've tried jelly in my in-house tool. It works well.

While Embedding jelly into my tool, 
I noticed that JellyContext.newJellyContext() puts a value to its parameter. 

    public JellyContext newJellyContext(Map newVariables) {
        // XXXX: should allow this new context to
        // XXXX: inherit parent contexts? 
        // XXXX: Or at least publish the parent scope
        // XXXX: as a Map in this new variable scope?
        newVariables.put("parentScope", variables); /*** here ***/
        JellyContext answer = createChildContext();
        answer.setVariables(newVariables);
        return answer;
    }

I prefer keep it remain instead of effect it
like :

    public JellyContext newJellyContext(Map newVariables) {
        JellyContext answer = createChildContext();
		answer.setVariable("parentScope", variables);
        answer.setVariables(newVariables);
        return answer;
    }

Because I often pass the unmodifieable map to the method, 
then cause an exception :

	    /* throws UnsupportedOperationException. */
        jellyCtx.newJellyContext( Collections.EMPTY_MAP ); 


I can't find problems that the modification might cause.
Do you have any ideas?

Thank you in advance.

--
MORITA Hajime <om...@dodgson.org>


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org