David Gibbs wrote:
Folks:
In an effort to educate myself, I'm wondering if someone could answer a few questions about EGL for me.  Unfortunately I don't really have time to do the research myself at the moment, and this is only idle curiosity at the moment.
1. Can anyone point me to a sample of simple EGL and the generated Java / native iSeries code that EGL emits?  I admit to having a prejudice against code generators (chalk it up to being scared by using AS/SET for 4 years).
  
I'll attach the code at the end of a simple program that invokes a web 
service and prints the result.  And while the Java is actually 
relatively readable, I raise the point that you don't look at the code 
unless the generator has a bug.  Other than that, you use the high-level 
EGL debugger which is very powerful.
2. I've been assuming that EGL has some runtime libraries that are required along with the compiled & generated code.  Is this correct?
  
Yes.
3. If #2 is correct, what are the licensing & redistribution rules regarding the runtime libraries, if any?
  
None.  If it's an EAR, export the EAR and run it.  The rich client 
JavaScript is even easier, just post the generated HTML on your favorite 
HTTP server.
4. Can someone point me to an basic example of EGL code that talks to a iSeries native program (perhaps via data queue) and does something for the client?
  
This code calls an RPG program, passing two structure (each with one 
field, but we're keeping it simple).
package services;
service HelloService
   function hello(toWhom string in) returns (string)
       SysLib.setRemoteUser("RUI00001", "RUI00001");
       hrq HelloRequest { Name = toWhom };
       hrs HelloResponse;
       call "HELLO" ( hrq, hrs );
       return (hrs.Salutation);
   end
end
Record HelloRequest type BasicRecord
 10 Name char(30);
end
Record HelloResponse type BasicRecord
 10 Salutation char(40);
end
The RPG code simply defines two parameters, one of 30 char, one of 40 
char.  Done.  If it were more complex data, you would use a data 
structure and EGL would convert between the various types.
Note that I've defined this as a service.  That means it can be invoked 
by another EGL program, or if I choose I can generate a web service 
complete with WSDL that can be invoked by anyone.
And here's the simple code to invoke that web service:
package clients;
import interfaces.HelloService;
program SayHello type BasicProgram {}
  
   // Variable Declarations
   name string = "Joe";
  
   function main()
       iHelloService HelloService { @BindService {} };
       SysLib.writeStdout(iHelloService.hello(name));
   end
  
end
It generates this:
// Generated at Thu Jul 31 12:40:53 CDT 2008 by EGL 7.1.0.RFB_20080124_1622
package clients;
public class SayHello extends com.ibm.javart.resources.Program
{
   private static final long serialVersionUID = 70L;
  
   public final SayHello ezeProgram;
   public com.ibm.javart.StringValue name;
  
   public SayHello( com.ibm.javart.resources.RunUnit ru ) throws Exception
   {
       super( "SayHello", "SayHello", ru, false, true );
       ezeProgram = this;
       name = new com.ibm.javart.StringItem( "name", 
com.ibm.javart.Value.SQL_NOT_NULLABLE, 
com.ibm.javart.Constants.SIGNATURE_STRING );
       $initSayHello( this );
   }
  
   public void _start() throws Exception
   {
       $func_main();
      
   }
   public static com.ibm.javart.resources.StartupInfo _startupInfo()
   {
       return new com.ibm.javart.resources.StartupInfo( "SayHello", 
"clients/SayHello.properties", false );
   }
   public static void main( String[] args ) throws Exception
   {
       com.ibm.javart.resources.StartupInfo info = _startupInfo();
       info.setArgs( args );
       com.ibm.javart.resources.RunUnit ru = new 
com.ibm.javart.resources.RunUnit( info );
       ru.start( new SayHello( ru ) );
       ru.exit();
   }
  
   public void $func_main() throws Exception
   {
       _funcPush( "main" );
      
       // iHelloService HelloService;
       com.ibm.javart.ref.ServiceReferenceRef iHelloService = new 
com.ibm.javart.ref.ServiceReferenceRef( "iHelloService", 
_runUnit().getServiceBinder().bindService( ezeProgram, "HelloService", 
"testservice" ), "Tinterfaces/HelloService;" );
       // SysLib.writeStdout(iHelloService.hello(name));
       System.out.println( 
com.ibm.javart.operations.ConvertToString.run( ezeProgram, 
iHelloService.checkedValue( ezeProgram ).ezeInvoke("hello", 
"$func_hello", new com.ibm.javart.calls.MethodParameter[] { new 
com.ibm.javart.calls.MethodParameter( 
com.ibm.javart.operations.Assign.run( ezeProgram, new 
com.ibm.javart.StringItem( "toWhom", 
com.ibm.javart.Value.SQL_NOT_NULLABLE, 
com.ibm.javart.Constants.SIGNATURE_STRING ), ezeProgram.name ), 1 ), new 
com.ibm.javart.calls.MethodParameter( new com.ibm.javart.StringItem( 
"STRING", com.ibm.javart.Value.SQL_NOT_NULLABLE, 
com.ibm.javart.Constants.SIGNATURE_STRING ), 0 )}) ) );
       // RETURN
       _funcPop();
       return;
   }
  
   public void $initSayHello( SayHello ezeProgram ) throws Exception
   {
       egl__vg__VGVar.handleOverflow.setValue(1);
       _dbms( com.ibm.javart.sql.Sql.DBMS_DB2 );
       // name = "Joe";
       com.ibm.javart.operations.Assign.run( ezeProgram, 
ezeProgram.name, "Joe" );
       // RETURN
   }
  
}
Not pretty, perhaps, but readable and again, you don't spend any time in 
this.
Joe
As an Amazon Associate we earn from qualifying purchases.