craigmcc 01/08/19 14:25:18 Modified: workflow/src/java/org/apache/commons/workflow Context.java workflow/src/java/org/apache/commons/workflow/base BaseContext.java workflow/src/test/org/apache/commons/workflow/base BaseContextTestCase.java Log: When adding additional scopes, register them in LOCAL_SCOPE under the same name. This allows for a single unified namespace to be presented to expression languages that can get and put corresponding values. Revision Changes Path 1.4 +13 -6 jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Context.java Index: Context.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Context.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Context.java 2001/08/18 21:06:50 1.3 +++ Context.java 2001/08/19 21:25:18 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Context.java,v 1.3 2001/08/18 21:06:50 craigmcc Exp $ - * $Revision: 1.3 $ - * $Date: 2001/08/18 21:06:50 $ + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/Context.java,v 1.4 2001/08/19 21:25:18 craigmcc Exp $ + * $Revision: 1.4 $ + * $Date: 2001/08/19 21:25:18 $ * * ==================================================================== * @@ -87,7 +87,7 @@ * the Step implementations that are executed to maintain the stack's * integrity.</p> * - * @version $Revision: 1.3 $ $Date: 2001/08/18 21:06:50 $ + * @version $Revision: 1.4 $ $Date: 2001/08/19 21:25:18 $ * @author Craig R. McClanahan */ @@ -221,9 +221,16 @@ /** - * Register a Scope implementation under the specified identifier. + * <p>Register a Scope implementation under the specified identifier. * It is not legal to replace the LOCAL_SCOPE implementation that is - * provided by the Context implementation. + * provided by the Context implementation.</p> + * + * <p>In addition to registering the new Scope such that it can be + * accessed dirctly via calls like <code>Context.get(String,int)</code>, + * the Scope <code>impl</code> object will also be added to the LOCAL + * Scope under the same name. This makes possible a single unified + * namespace of all accessible objects that can be navigated by + * expression languages.</p> * * @param scope Scope identifier to register under * @param name Scope name to register under 1.4 +15 -6 jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java Index: BaseContext.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- BaseContext.java 2001/08/18 21:06:50 1.3 +++ BaseContext.java 2001/08/19 21:25:18 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v 1.3 2001/08/18 21:06:50 craigmcc Exp $ - * $Revision: 1.3 $ - * $Date: 2001/08/18 21:06:50 $ + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/java/org/apache/commons/workflow/base/BaseContext.java,v 1.4 2001/08/19 21:25:18 craigmcc Exp $ + * $Revision: 1.4 $ + * $Date: 2001/08/19 21:25:18 $ * * ==================================================================== * @@ -83,7 +83,7 @@ * class. If it is used in a multiple thread environment, callers must * take suitable precations.</p> * - * @version $Revision: 1.3 $ $Date: 2001/08/18 21:06:50 $ + * @version $Revision: 1.4 $ $Date: 2001/08/19 21:25:18 $ * @author Craig R. McClanahan */ @@ -327,10 +327,17 @@ /** - * Register a Scope implementation under the specified identifier. + * <p>Register a Scope implementation under the specified identifier. * It is not legal to replace the LOCAL_SCOPE implementation that is - * provided by the Context implementation. + * provided by the Context implementation.</p> * + * <p>In addition to registering the new Scope such that it can be + * accessed dirctly via calls like <code>Context.get(String,int)</code>, + * the Scope <code>impl</code> object will also be added to the LOCAL + * Scope under the same name. This makes possible a single unified + * namespace of all accessible objects that can be navigated by + * expression languages.</p> + * * @param scope Scope identifier to register under * @param name Scope name to register under * @param impl Scope implementation to be registered (or null to @@ -343,9 +350,11 @@ if (scope == LOCAL_SCOPE) throw new IllegalArgumentException("Cannot replace local scope"); if (impl == null) { + getScope(LOCAL_SCOPE).remove(name); names[scope] = null; scopes[scope] = null; } else { + getScope(LOCAL_SCOPE).put(name, impl); names[scope] = name; scopes[scope] = impl; } 1.3 +6 -4 jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseContextTestCase.java Index: BaseContextTestCase.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseContextTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- BaseContextTestCase.java 2001/08/17 20:37:00 1.2 +++ BaseContextTestCase.java 2001/08/19 21:25:18 1.3 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseContextTestCase.java,v 1.2 2001/08/17 20:37:00 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2001/08/17 20:37:00 $ + * $Header: /home/cvs/jakarta-commons-sandbox/workflow/src/test/org/apache/commons/workflow/base/BaseContextTestCase.java,v 1.3 2001/08/19 21:25:18 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/08/19 21:25:18 $ * * ==================================================================== * @@ -76,7 +76,7 @@ * functions that are not dependent upon an associated Activity.</p> * * @author Craig R. McClanahan - * @version $Revision: 1.2 $ $Date: 2001/08/17 20:37:00 $ + * @version $Revision: 1.3 $ $Date: 2001/08/19 21:25:18 $ */ public class BaseContextTestCase extends TestCase { @@ -165,6 +165,8 @@ context.getScope(Context.LOCAL_SCOPE + 1)); assertEquals("Should match 'extra' scope by name", scope, context.getScope("extra")); + assertEquals("Should find 'extra' scope in 'local' scope", scope, + context.get("extra", Context.LOCAL_SCOPE)); commonDirectScope(Context.LOCAL_SCOPE + 1); }