Using the Java Gateway in a Production - InterSystems Documentation
Using the Java Gateway in a Production - InterSystems Documentation
Using the Java Gateway in a Production - InterSystems Documentation
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Sample Code<br />
Do ##class(EnsLib.<strong>Java</strong><strong>Gateway</strong>.InterfaceEnabler).ImportPersonJBoss(PersonEJBJar,<br />
j2eeJarFile,port,host)<br />
Where PersonEJBJar po<strong>in</strong>ts to <strong>the</strong> PersonEJB.jar file (as generated by <strong>the</strong> <strong>InterSystems</strong> EJB Boss projection) and<br />
j2eeJarFile po<strong>in</strong>ts to <strong>the</strong> J2EE jar file on your system, for example:<br />
c:/myj2ee/j2ee.jar<br />
• To import SonicMQ ConnectionFactory (Queue and Topic), allow<strong>in</strong>g connectivity to <strong>the</strong> SonicMQ JMS Server, enter<br />
<strong>the</strong> follow<strong>in</strong>g command (all on one l<strong>in</strong>e):<br />
Do ##class(EnsLib.<strong>Java</strong><strong>Gateway</strong>.InterfaceEnabler).ImportSonicJMS(sonicBrokerJar,<br />
sonicContextJar,port,host)<br />
Where sonicBrokerJar po<strong>in</strong>ts to <strong>the</strong> Sonic broker.jar file, for example:<br />
C:/Program Files/SonicSoftware/SonicMQ/lib/broker.jar<br />
And sonicContextJar po<strong>in</strong>ts to <strong>the</strong> Sonic mfcontext.jar file, for example:<br />
C:/Program Files/SonicSoftware/SonicMQ/lib/mfcontext.jar<br />
• To import all J2EE <strong>in</strong>terfaces (EJB, JCA, JTA, <strong>Java</strong> XML, JTA, etc.), enter <strong>the</strong> follow<strong>in</strong>g command (all on one l<strong>in</strong>e):<br />
Do ##class(EnsLib.<strong>Java</strong><strong>Gateway</strong>.InterfaceEnabler).ImportJ2EE(j2eeJarFile,<br />
port,host)<br />
Where j2eeJarFile po<strong>in</strong>ts to <strong>the</strong> J2EE jar file on your system, for example:<br />
c:/myj2ee/j2ee.jar<br />
In addition to <strong>the</strong>se Import methods, <strong>the</strong> EnsLib.<strong>Java</strong><strong>Gateway</strong>.InterfaceEnabler class provides a convenience method that,<br />
given a jar file or a directory name, displays all available classes <strong>in</strong> that jar file or directory:<br />
Do ##class(EnsLib.<strong>Java</strong><strong>Gateway</strong>.InterfaceEnabler).Browse(jarName,port,host)<br />
3.2 Runn<strong>in</strong>g Pla<strong>in</strong> <strong>Java</strong> Examples<br />
The Test method shows how to use <strong>the</strong> sample basic classes delivered with Ensemble. To run it, first set up <strong>the</strong> example,<br />
us<strong>in</strong>g ImportJGSamples if you need to import. Then enter:<br />
Do ##class(EnsLib.<strong>Java</strong><strong>Gateway</strong>.Test).Test(port,host)<br />
The TestArrays method shows how to use arrays. To run it, first set up <strong>the</strong> example, us<strong>in</strong>g ImportJGSamples if you need<br />
to import. Then enter:<br />
Do ##class(EnsLib.<strong>Java</strong><strong>Gateway</strong>.Test).TestArrays(port,host)<br />
3.3 Runn<strong>in</strong>g JDBC <strong>Gateway</strong> Examples<br />
The follow<strong>in</strong>g example establishes a connection with Caché JDBC driver, <strong>the</strong>n executes some standard JDBC code. To<br />
run it, first set up <strong>the</strong> example, us<strong>in</strong>g ImportJDBC if you need to import. Then enter:<br />
Do ##class(EnsLib.<strong>Java</strong><strong>Gateway</strong>.Test).JDBC(port,host,jdbcPort,jdbcHost)<br />
20 <strong>Us<strong>in</strong>g</strong> <strong>the</strong> <strong>Java</strong> <strong>Gateway</strong>