Package javax.script

Examples of javax.script.SimpleNamespace

    // Create compiler
    compiler = createCompiler();

    GenericScriptContext context = new GenericScriptContext();
    Namespace globalNamespace = new SimpleNamespace();
      context.setNamespace(globalNamespace, ScriptContext.GLOBAL_SCOPE);
    Namespace localNamespace = new SimpleNamespace();
      context.setNamespace(localNamespace, ScriptContext.ENGINE_SCOPE);
    this.context = context;

    // Bank model
    BankCAContainer bankModel = new BankCAContainer();
    this.bankModel = bankModel;
    // Set a model
    globalNamespace.put( "bankModel", bankModel );
    // Set the root of the model as attribute
    bank = bankModel.getBank();
    localNamespace.put("bank", bankModel.getBank());

    // Tree model
    TreeModelContainer treeModel = new TreeModelContainer("root", 4);
    this.treeModel = treeModel;
    globalNamespace.put( "treeModel", treeModel );
    tree = treeModel.getNode();
    localNamespace.put("tree", treeModel.getNode() );

    // Set attributes
    localNamespace.put(attr1Name, attr1);
    localNamespace.put(attr2Name, attr2);
    localNamespace.put(attr3Name, attr3);
View Full Code Here

    assertEquals(new Double(10), engine.get("x"));
  public void testSetNamespace() {
    SimpleNamespace ns = new SimpleNamespace();
    ns.put("x", new Integer(11));
    engine.setNamespace(ns, ScriptContext.ENGINE_SCOPE);
    try {
      Object retValue = engine.eval("x;");
      assertEquals(new Integer(11), retValue);
    }catch (Exception ex) {
View Full Code Here


Related Classes of javax.script.SimpleNamespace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact