Exactly - you haven't used the Gateways before. Why? IMO, the Gateways (mostly Java and DotNet) were a bit cumbersome to deal with. With ELS, we have default servers that can be easily managed and discovered, they require little or no configuration to get started (some ELS's do require some configuration if the language platform support is not discoverable by IRIS), and the interface is simple and direct.
One quick example, using Python, is to use the os module to get the current working directory:
USER>set python = $system.external.getPythonGateway()
USER>write python.invoke("os","getcwd")
/opt/intersystems/iris/xdbc/mgrAll that is required is a gateway connection to an external server, your code needs to be visible to that external server, either by direct placement into the default path for that language platform or by explicitly adding it by calling addToPath(), and public interfaces in your external code. By "external", I mean code that isn't written inside of the IRIS Server - ObjectScript.
When your external code writes to the "system output" device, that output is redirected to the IRIS current device. In my above example, the renderTable() function simply constructs a formatted string using the AsciiTable library (got it from GitHub) and writes it using System.out.println(formattedstring). I simply copied the output that was displayed in my IRIS session terminal window and pasted it in the original post. No extra work involved.
If your external code returns an object then you can indeed make use of that object as if it were a local IRIS Object - because it is. It is actually a network proxy object that communicates with the original external language object. That communication can actually be full duplex - your external code can talk to IRIS and IRIS can talk to your external code.
One really simple example that I think is quite profound is using JDBC in IRIS. This isn't JDBC Gateway - that still exists and it is what it is. I am talking about using a Java JAR file that contains a JDBC driver and you want to use it. I'll try a simple demo here. I have MariaDB installed on my system so I'll just use it to query a table I have defined there.
First - using mariaDB from the command line interface:
~ % mysql -u myusername -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.5.8-MariaDB Homebrew
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases
-> ;
+--------------------+
| Database |
+--------------------+
| SAMPLES |
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.010 sec)
MariaDB [(none)]> use SAMPLES
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [SAMPLES]> show tables;
+-------------------+
| Tables_in_SAMPLES |
+-------------------+
| person |
+-------------------+
1 row in set (0.000 sec)
MariaDB [SAMPLES]> select * from person limit 5
-> ;
+-----------------------+-------------+------------+-----------------------+------------+------------+----------+
| name | ssn | dob | home_street | home_city | home_state | home_zip |
+-----------------------+-------------+------------+-----------------------+------------+------------+----------+
| Basile,Molly M. | 452-57-8033 | 1994-06-02 | 1153 First Street | Xavier | SD | 98033 |
| Cooke,Howard F. | 131-62-3894 | 2017-12-09 | 5172 Washington Place | Zanesville | NE | 44980 |
| Donaldson,Phil R. | 480-79-5019 | 1990-01-23 | 4429 Elm Street | Miami | WA | 67638 |
| Eisenstien,Michael D. | 655-11-6334 | 1948-08-14 | 4676 Elm Avenue | Reston | KY | 52729 |
| Faust,Mo E. | 772-42-3921 | 2018-01-10 | 826 Maple Avenue | Youngstown | OH | 37180 |
+-----------------------+-------------+------------+-----------------------+------------+------------+----------+
5 rows in set (0.016 sec)
MariaDB [SAMPLES]>Next, I'll follow up with an example of doing this from within IRIS.
- Log in to post comments