External Language Server in 2021.1
Now that IRIS 2021.1 is available as a preview version, I would like to demonstrate a "new" feature. The Java Gateway has been around for a while now but in 2021.1 it has new skills. External Language Servers are available for Java, DotNet, and Python. Here is a quick - very quick - demo of using the External Java Server. Please don't focus solely on what this demo is doing but rather on what is happening in this demo. First, I acquire a gateway connection oref. This gateway connection is connected to the External Java Server - one of the External Language Servers.
set java = $system.external.getJavaGateway()
Next, I need to add my jar file to the class path:
do java.addToPath("~/projects/external/java/iris-external/target/iris-external-1.0-SNAPSHOT.jar")
I have a method in my external.test.Horizons class that queries the Sample.Person table in some IRIS instance.
public static ExternalResult getPersons(int rowcount) throws SQLException { return new ExternalResult(getPersonsResults(rowcount)); } private static ResultSet getPersonsResults(int rowcount) throws SQLException { Properties properties = new Properties(); properties.put("user", "_SYSTEM"); properties.put("password", "SYS"); Connection connection = DriverManager.getConnection(IRIS_URL, properties); Statement statement = connection.createStatement(); ResultSet result = statement.executeQuery("select top " + rowcount + " name, dob, ssn, home_street, home_city, home_state, home_zip from sample.person order by name"); return result; }
Simply invoke this method using the ELS invoke method:
set persons = java.invoke("external.test.Horizons","getPersons",10)
In my example, persons is holding a reference to an instance of my external.test.ExternalResult Java class. This class is a wrapper around a JDBC Result Set. I've implemented a renderTable() method that displays the contents of the ResultSet using an AsciiTable library:
do persons.renderTable()
And the output:
┌──────────────────┬──────────┬───────────┬──────────────────────┬──────────┬──────────┬────────┐ │Name │DOB │SSN │Home_Street │Home_City │Home_State│Home_Zip│ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Adam,Barb X. │1990-08-15│568-33-3285│4907 Clinton Court │Boston │ID │67314 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Adam,Milhouse K. │1989-07-05│797-35-8746│9623 Franklin Blvd │Youngstown│AR │31403 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Adams,Mo Z. │1962-02-15│263-25-6173│5449 Washington Street│Washington│WA │32342 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Ahmed,Al S. │1985-01-22│623-94-2440│8103 Main Court │Oak Creek │TN │96256 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Ahmed,Barb R. │1956-12-13│373-71-8424│9509 Clinton Avenue │Newton │CT │56929 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Ahmed,Charlotte P.│1947-05-09│944-70-3491│1610 Second Place │Oak Creek │VT │54476 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Ahmed,Debby W. │2005-05-20│611-75-3175│150 First Court │Ukiah │HI │93961 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Ahmed,Yan V. │1949-07-22│552-24-3419│3684 Madison Drive │Denver │OH │12175 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Allen,Geoffrey D. │1963-09-21│956-84-9269│6628 Madison Place │Vail │MT │86032 │ ├──────────────────┼──────────┼───────────┼──────────────────────┼──────────┼──────────┼────────┤ │Allen,Howard B. │1943-01-09│834-27-9607│6899 Clinton Court │Vail │GA │69486 │ └──────────────────┴──────────┴───────────┴──────────────────────┴──────────┴──────────┴────────┘
DotNet and Python External Language Servers work similarly.