如何使用 Java 互操作直接访问全局变量?

How can I access globals directly with Java interop?

所有 the documentation I see 都在谈论对象持久性。这很好,但我需要能够直接访问全局变量(比如 ^SE("Whosebug","q",34241364,"md"))。

如何做到这一点?

是的,可以使用 Globals API,它可用于 Java eXTreme 库 (cacheextreme.jar)。参见 documentation。结束示例:

import com.intersys.globals.*;

class FetchNodes {
  public static void main(String[] args) {
    Connection myConn = ConnectionContext.getConnection();
    try {
      myConn.connect("User", "_SYSTEM", "SYS");
      NodeReference nodeRef = myConn.createNodeReference("myGlobal");
      // Read both existing nodes
      System.out.println("Value of ^myGlobal is " + nodeRef.getString());
      System.out.println("Value of ^myGlobal(\"sub1\") is " + nodeRef.getString("sub1"));
      nodeRef.kill();   // delete entire array
      nodeRef.close();
      myConn.close();
    }
    catch (GlobalsException e) { System.out.println(e.getMessage()); }
  } // end Main()
} // end class FetchNodes