Is there any interest in this? I have a base scope, servlet request scope and a System scope written, but I don't know to go much further if there is no interest, and the questions below have some impact as well.

Any thoughts? anybody? :-)

~Robert

Robert McIntosh wrote:

Here is a first crack at the interface. I'm assuming that there will be parent/child scopes here, which the last few methods deal with. I also thought about having a few other 'collection' type methods, but don't know what everyone else would think, such as contains( object ), values(), isEmpty(), keySet(), etc.

Back to the JellyContext, what about finding variables in nested scopes? For example, say we have one JellyContext (no parent), and it has the following scopes:

- default scope
- customScope1
- HttpApplication which contains as a child a HttpSession scope

A client does a findVariable() call on the context. We can assume that the context would search the default, customScope1 and the HttpApplication scope, but what about the session scope?. If the leaf, or last scope in a parent/child graph, is bound and not the top parent, this is no problem, since the child parent can do a getParent().findVariable() type of call. This doesn't mention if we have nested Contexts as well.

I can think of three options:
1. we don't have nested scopes and the search is easy. Each context has its own list of scopes and it can ask its parent.
2. we allow walking down the scope graph as well as up, via a getChildScope() or something like that. Maybe have that as a protected method on a BaseScope or something, and the context or the scope itself can check for that.
3. ???


~Robert

Robert McIntosh wrote:

I don't have a use case for events either, but I thought I would throw it out there for discussion. I agree that the Scope interface be very simple and the context should have a default scope, which can be overridden by the user.

~Robert

bob mcwhirter wrote:

2. Have/keep the scope listeners and events?



I personally see Scope as a way to keep me from having to keep writing subclasses of JellyContext when I want the context to be backed by my own data structure.

Talking with Strachan I think we're pondering
   context.setDefaultScope( myScope );

In that vein, making Scope very simple be best for my particular
use-case.

public interface Scope
{
   void setVariable(String name, Object value);
   Object getVariable(String name);
}

If the JellyContext wants to check for ListenableScope and fire events,
that's cool, but it'd also be overblown for all of my use-cases.

-bob


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]





---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

------------------------------------------------------------------------

/*
* $Header: $
* $Revision: $
* $Date: $
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
* * $Id: $
*/
package org.apache.commons.jelly;


import java.util.Map;


/**
* An interface defining a scope which contains the variables * used by Jelly scripts.
* * @author Robert McIntosh
* @version $Revision: $
*/
public interface JellyScope {
/**
* Sets a variable into the scope
* * @param name The name to assign to the variable
* @param value The object to assign
*/
public void setVariable( String name, Object value );
/**
* Gets a value from the scope
* * @param name The name of the variable to get
* @return The value of the variable
*/
public Object getVariable( String name );
/**
* Removes the variable from the scope
* * @param name The name of the variable to remove
*/
public void removeVariable( String name );
/**
* Determines whether or not the variable
* is in this scope or its parent
* * @param name The variable name to check
* @return true or false
*/
public boolean containsVariable( String name );
/**
* Adds all of the contexts from the supplied scope
* to this scope
* * @param scope The scope to add from
*/
public void addAll( JellyScope scope );
/**
* Gets a Map of the variables in this scope
* * @return A Map of the current variables
*/
public Map getVariables();
/**
* Gets a Map containing all the variables from * this scope as well as the parent scope
* * @return All variables from this scope and its parent
*/
public Map getAllVariables();
/**
* Sets the parent scope
* * @param parent The parent JellyScope
*/
public void setParent( JellyScope parent );
/**
* Gets the parent scope
* * @return The parent scope
*/
public JellyScope getParent();


}



------------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to