|
Thanks, Bill. I'll keep your tips in mind. I was wondering...some of my Javabeans simply read DB2 files and write a text file (e.g., xml, csv, fixed-width format) to a PC folder. I could code a Java program that instantiates and calls the Javabean methods, then simply have an RPG program call the Java program. Would I get better performance by calling a Java program from an RPG program rather than having the RPG program use the Javabean methods directly via prototyping? Thanks, Kelly -----Original Message----- From: William Fly [mailto:billfly@xxxxxxxxxxxxxx] Sent: Monday, January 12, 2004 9:43 AM To: kcookson@xxxxxxxxxxxx Subject: Fw: Re: RPGIV: RPG and Java Kelly, I have written an RPG ILE portal program to a Java XML translator. I learned quite a bit getting it to work. First of all, the initial call from the RPG to the Java is pretty slow, because the Java Virtual Machine is beining loaded into that job. After the JVM is initialized, everything moves swiftly. Also, it take extra calls into Java to pass and return Java Strings. I would highly recommend passing in RPG character (varying) fields which Java can handle as byte arrays. Also, returning a byte array will return an RPG character field with the varying keyword. That way you do not create extra Java String objects that are difficult to get rid of and can cause a tremendous amount of garbage collection and you Java program to slow down over time. Using the byte arrays seems to keep the execution of the Java program very consistent over time. Assuming your Java program is not a static method, you will need to call the Java program's constructor which returns a Java object. That Java object must be return on every method call as the first parameter, but do not define that parameter in the prototype. Example: d xml s o class(*java : SboXmlXlator) d constructor pr o extproc(*java : SboXmlXlator : d *constructor) d xml2Fixed pr 32767a varying d extproc(*java : SboXmlXlator : d 'xml2Fixed') d 32767a varying const d 32767a varying const d 32767a varying const xml = constructor(); response = xml2Fixed(xml : object : tag : request); // notice 1st parameter is // object returned from // constructor, not in prototype. Also, you must set your classpath with an ADDENVVAR command before doing anything. The Java object must be in the an IFS directory and that directory must be on the classpath. That should save you some of the scars that I have accumulated getting this to work. Bill (copy of post to RPGIV@xxxxxxxxxxxxxxx) > I have coded a few servlets that use Toolbox for Java to process iSeries DB2 > files. I would now like to turn these servlets into beans and run them on > the iSeries. However, since Java is not a standard language in our shop, I > need to make the beans available through RPG programs. > > One strategy would be to make RPG programs that call (and pass parms to) the > Java programs. The Java programs would then instantiate and use the beans. > Another strategy would be to use Java-RPG interoperability and have the RPG > programs use the beans' methods directly. > > I'd appreciate any insights into why and under what circumstances one > strategy would be preferable to the other. I'd also like to hear about any > pitfalls of Java-RPG interoperability, and whether people think Java-RPG has > a bright or gloomy future. > > Thanks, > Kelly > > -- > ___________________________________________________________ > Sign-up for Ads Free at Mail.com > http://promo.mail.com/adsfreejump.htm > -- ___________________________________________________________ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.