These session snippets show how I installed and ran Voyager ORB on MPE/iX. also see http://www.Objectspace.com/products/ Notice that I am using MPE/iX 5.5 and Java/iX 1.1.7 as well as Java/iX 1.2.2 in this case. I am using the 1.1.7 JDK whenever possible, because it seems to launch faster on my small machine. However, it did not work with Voyager, so I used 1.2.2 for actually running the examples, while using 1.1.7 for tasks like compiling. As usual, this is "not HP supported" and "use at your own risk" ;-) MPE/iX:hello lars,manager.sys HP3000 Release: C.55.00 User Version: C.55.00 FRI, JUL 7, 2000, 8:36 PM MPE/iX HP31900 C.05.08 Copyright Hewlett-Packard 1987. All rights reserved. :newacct ix,mgr ;pass=acctpw :newacct ix,mgr ;onvs=user_set :altuser mgr.ix ;pass=mgrpw :altacct ix ;cap=+ph :# let's create a CORBA.IX user for Voyager, JacORB and EngineRoom experiments :newgroup corba.ix ;onvs=user_set :newgroup corba.ix ;homevs=user_set ;access=(r,x:ac; w,a,l,s:gl) :newuser corba.ix ;home=corba ;pass=userpw :altuser corba.ix ;cap=+ph,gl :hello lars,corba.ix HP3000 Release: C.55.00 User Version: C.55.00 FRI, JUL 7, 2000, 8:39 PM MPE/iX HP31900 C.05.08 Copyright Hewlett-Packard 1987. All rights reserved. :newdir temp Created directory "TEMP.CORBA.IX". :chdir temp CWD is "TEMP.CORBA.IX". :# at this point we upload the Voyager 3.3 ORB zip file to the 3000 :# this can be done with ftp or terminal emulator file transfer or by :# using samba to access the MPE/iX file system; you could even pull :# the file directly off the Internet, if you have GNU wget for MPE/iX :# installed and the 3000 can access the Internet either directly or :# through a web proxy. :listfile ./@ ,2 PATH= /IX/CORBA/TEMP/ CODE ------------LOGICAL RECORD----------- ----SPACE---- FILENAME SIZE TYP EOF LIMIT R/B SECTORS #X MX 1B BA 2886003 2147483647 1 11280 9 32 voyager3_3.zip :xeq /usr/local/bin/unzip voyager3_3.zip Archive: voyager3_3.zip inflating: install.txt inflating: voyager3_3.class : :listfile ./@ ,2 PATH= /IX/CORBA/TEMP/ CODE ------------LOGICAL RECORD----------- ----SPACE---- FILENAME SIZE TYP EOF LIMIT R/B SECTORS #X MX 1B BA 624 2147483647 1 16 1 * install.txt 1B BA 2927289 2147483647 1 11440 9 * voyager3_3.class 1B BA 2886003 2147483647 1 11280 9 32 voyager3_3.zip :# Oops. Unfortunately the Voyager folks are using InstallShield for Java, :# which requires a GUI capable machine for unpacking now. My workaround is :# to transfer the class file to a Windows or Linux PC, let InstallShield :# unpack to a subdirectory v33 there, zip that up and bring it back to the :# 3000, where I then can unzip it again... :listfile ./v33.zip ,2 PATH= /IX/CORBA/TEMP/ CODE ------------LOGICAL RECORD----------- ----SPACE---- FILENAME SIZE TYP EOF LIMIT R/B SECTORS #X MX 1B BA 3515081 16384000 1 13744 10 32 v33.zip :xeq /usr/local/bin/unzip v33.zip Archive: v33.zip creating: v33/ inflating: v33/COPYRIGHT.TXT inflating: v33/index.html inflating: v33/INSTALL.TXT inflating: v33/LICENSE.TXT inflating: v33/README.TXT creating: v33/bin/ inflating: v33/bin/cgen.exe inflating: v33/bin/igen.exe inflating: v33/bin/voyager.exe creating: v33/lib/ inflating: v33/lib/jgl3.1.0.jar inflating: v33/lib/jgl_pd.jar . . . inflating: v33/doc/Voyager-2.htm inflating: v33/doc/Voyager-22.htm error: can't create v33/doc/Voyager-23,01.htm error: can't create v33/doc/Voyager-23,02.htm error: can't create v33/doc/Voyager-23,03.htm error: can't create v33/doc/Voyager-23,04.htm error: can't create v33/doc/Voyager-23,05.htm error: can't create v33/doc/Voyager-23,06.htm error: can't create v33/doc/Voyager-23,07.htm error: can't create v33/doc/Voyager-23,08.htm error: can't create v33/doc/Voyager-23,09.htm error: can't create v33/doc/Voyager-23,10.htm error: can't create v33/doc/Voyager-23,11.htm error: can't create v33/doc/Voyager-23,12.htm error: can't create v33/doc/Voyager-23,13.htm error: can't create v33/doc/Voyager-23,14.htm error: can't create v33/doc/Voyager-23,15.htm error: can't create v33/doc/Voyager-23,16.htm error: can't create v33/doc/Voyager-23,17.htm error: can't create v33/doc/Voyager-23,18.htm error: can't create v33/doc/Voyager-23,19.htm error: can't create v33/doc/Voyager-23,20.htm error: can't create v33/doc/Voyager-23,21.htm inflating: v33/doc/Voyager-4.htm inflating: v33/doc/Voyager-4a.htm . . . inflating: v33/examples/timer/Timer2.java inflating: v33/examples/timer/Timer3.java inflating: v33/IsAdmin.exe inflating: v33/environment.txt inflating: v33/install.idb inflating: v33/uninstall.class : :# Notice that some of the files did not unzip successfully because they :# had comma characters in their filename. We could either rename them on :# the Windows or Linux PC before bringing the v33.zip here, or simply :# read this documentation files on the PC side. Being a lazy guy, I did :# the latter ;-) :xeq /bin/mv "v33 ../Voyager3_3" :chdir .. CWD is "/IX/CORBA". :purgedir temp ;tree Purge ALL files below and including "TEMP.CORBA.IX"? (ALL/NO)all :xeq /bin/chmod "-R go-w Voyager3_3" :listfile ./@ ,2 PATH= /IX/CORBA/ CODE ------------LOGICAL RECORD----------- ----SPACE---- FILENAME SIZE TYP EOF LIMIT R/B SECTORS #X MX 16W HBD 0 67107839 1 32 1 * Voyager3_3/ :# for convenience reasons, we create a command file to launch the :# Posix Shell with larger NMSTACK and or NMHEAP values, as this might :# be needed to prevent fork()ed Java children to run OutOfMemory :editor HP32201A.09.00 EDIT/3000 FRI, JUL 7, 2000, 9:42 PM (C) HEWLETT-PACKARD CO. 1993 /a 1 parm info="-L", nmstack=10240000, nmheap=10240000 2 run /bin/sh ;info="!info" ;nmstack=!nmstack ;nmheap=!nmheap 3 // ... /k shell,unn /e END OF SUBSYSTEM : :shell shell/iX> cd Voyager3_3 shell/iX> ls -l -rw-r--r-- 1 CORBA.IX IX 883 Jul 7 21:16 COPYRIGHT.TXT -rw-r--r-- 1 CORBA.IX IX 5543 Jul 7 21:16 INSTALL.TXT -rw-r--r-- 1 CORBA.IX IX 25600 Jul 7 21:16 IsAdmin.exe -rw-r--r-- 1 CORBA.IX IX 16844 Jul 7 21:16 LICENSE.TXT -rw-r--r-- 1 CORBA.IX IX 14444 Jul 7 21:16 README.TXT drwxr-x--x 2 CORBA.IX IX 512 Jul 7 21:16 bin drwxr-x--x 4 CORBA.IX IX 1856 Jul 7 21:16 doc -rw-r--r-- 1 CORBA.IX IX 174 Jul 7 21:16 environment.txt drwxr-x--x 19 CORBA.IX IX 1856 Jul 7 21:16 examples -rw-r--r-- 1 CORBA.IX IX 2254 Jul 7 21:16 index.html -rw-r--r-- 1 CORBA.IX IX 67731 Jul 7 21:16 install.idb drwxr-x--x 2 CORBA.IX IX 512 Jul 7 21:16 lib -rw-r--r-- 1 CORBA.IX IX 204942 Jul 7 21:16 uninstall.class shell/iX> ls bin cgen.exe igen.exe voyager.exe shell/iX> ls lib jgl3.1.0.jar jgl_pd.jar voyager.jar shell/iX> ls examples activation applets corba mobility security stockmarket agents basics db naming servlet timer aggregation calculator message rmi space shell/iX> # notice that we won't be able to use the .exe fiiles in the bin subdir shell/iX> # however, let's hope that there will be pure Java alternative approaches shell/iX> # we'll first create a couple of useful alias and env var settings shell/iX> # these could also be put into .profile but for the moment, we will shell/iX> # just put them into a local file that can be "sourced" with the shell/iX> # shell's "dot" command as needed (to run them inside the current shell/iX> # process instead of a child shell process). shell/iX> cat > useful alias java1="/usr/local/java/jdk1.1.7/bin/java -nojit" alias java1c="/usr/local/java/jdk1.1.7/bin/javac -J-nojit" alias java2="/usr/local/java/jdk1.2.2/bin/java -Xnojit" export CLASSPATH=:$PWD/lib/voyager.jar:$PWD/lib/jgl3.1.0.jar :eod shell/iX> . useful shell/iX> java1 -version java version "JDK 1.1.7B" shell/iX> java2 -version java version "JDK 1.2.2" Classic VM (build A.22.02 built on 05/30/00 @ 14:12, green threads, HP) shell/iX> # we'll now start with some of the Voyager examples... shell/iX> # the Basics1 example requires to launch the Voyager server by shell/iX> # using the bin/voyager.exe program; this does not help us here shell/iX> # as we are not on a PC; so we created a little helper program shell/iX> # that starts up Voyager, waits for a while and then exits... shell/iX> cat RunVgr.java class RunVgr { public static void main(String[] args) throws Exception { com.objectspace.voyager.Voyager.startup(args[0]); System.out.println("voyager ready"); try { Thread.sleep(Integer.parseInt(args[1])); } catch (Exception ign) {} System.out.println("voyager leave"); com.objectspace.voyager.Voyager.shutdown(); } } shell/iX> java1c RunVgr.java **Out of memory, exiting** shell/iX> # aha, my defaults for NMHEAP or NMSTACK were too small... shell/iX> exit END OF PROGRAM :shell ,20480000,20480000 shell/iX> cd Voyager3_3 shell/iX> . useful shell/iX> java1c RunVgr.java shell/iX> # okay, now let's try the Basics1 example shell/iX> # we will need to open a second session for running the client shell/iX> # program; I will merge the snippets from that session here and shell/iX> # indent them with a vertical bar to mark the "foreign" lines shell/iX> # notice that I won't preserve the exact time relationship by shell/iX> # interleaving "line by line" as this would be too confusing | MPE/iX:hello lars,corba.ix | | HP3000 Release: C.55.00 User Version: C.55.00 FRI, JUL 7, 2000, 10:18 PM | MPE/iX HP31900 C.05.08 Copyright Hewlett-Packard 1987. All rights reserved. | | :shell ,20480000,20480000 | | shell/iX> cd Voyager3_3 | shell/iX> . useful | | shell/iX> # let us try Basics1 example, but we will have to compile it first | | shell/iX> ls -l examples/basics | -rw-r--r-- 1 CORBA.IX IX 933 Jul 7 21:16 Basics1.java | -rw-r--r-- 1 CORBA.IX IX 579 Jul 7 21:16 Basics2A.java | -rw-r--r-- 1 CORBA.IX IX 610 Jul 7 21:16 Basics2B.java | | shell/iX> java1c examples/basics/Basics1.java | | shell/iX> java2 examples.basics.Basics1 | java.lang.ClassNotFoundException: examples.stockmarket.Stockmarket | | shell/iX> # oops! we should have paid more attention to the HTML docs as well | shell/iX> # as the source code (you do examine both, don't you?) -- the Basics1 | shell/iX> # example uses the Stockmarket class from another directory... | | shell/iX> ls -1 examples/stockmarket | IRmiStockmarket.java | IStockmarket.java | RmiStockmarket.java | Stockmarket.java | | shell/iX> java1c examples/stockmarket/Stockmarket.java | | shell/iX> ls -1 examples/stockmarket | IRmiStockmarket.java | IStockmarket.class | IStockmarket.java | RmiStockmarket.java | Stockmarket.class | Stockmarket.java | | shell/iX> # notice that javac did compile the Stockmarket class and the | shell/iX> # IStockmarket interface that it references (no MAKE needed :-) shell/iX> # now we run the Voyager server on port 8000 for 60 seconds... shell/iX> java2 RunVgr 8000 60000 Nonzero address passed to bind(); using localhost voyager ready | shell/iX> # and here is the client side, after the server was started... | | shell/iX> java2 examples.basics.Basics1 | sun share price = 81 | bought 10 shares of SUN for 760 | java.lang.IllegalArgumentException: share count < 0 | | shell/iX> # notice that the Exception above is not an error condition | shell/iX> # is it part of the example to show how a Java exception can | shell/iX> # be passed from the server side to the invoking client | | shell/iX> # also notice that Basics1 created an object remotely! construct stockmarket news: Sun releases Java voyager leave shell/iX> # the above messages were (in part) caused by our client run | shell/iX> # now let's visit example Basics2A and Basics2B... | | shell/iX> java1c examples/basics/Basics2A.java examples/basics/Basics2B.java | | shell/iX> # Basics2A provides the server part, Basics2B the client part | shell/iX> # however, there is not much of a visual effect; the client only | shell/iX> # invokes a server side object/method, there is no output on the | shell/iX> # client side and only a single line on the server side | | shell/iX> # also notice that both, Basics2A and Basics2B are not written | shell/iX> # to shutdown themselves, but have to be aborted explicitly; on | shell/iX> # a PC, you would use Ctrl-C; here on MPE, we use Break :ABORT shell/iX> # we run Basics2A in one session, trigger it twice from the other shell/iX> # session and then abort it to move on to the next Voyager example shell/iX> java2 examples.basics.Basics2A construct stockmarket Nonzero address passed to bind(); using localhost | shell/iX> # here are the two Basics2B invocations, each with Break :ABORT | | shell/iX> java2 examples.basics.Basics2B | Nonzero address passed to bind(); using localhost | :abort | | Program aborted per user request. (CIERR 989) | :shell ,20480000,20480000 | | shell/iX> cd V* | shell/iX> . useful | | shell/iX> java2 examples.basics.Basics2B | Nonzero address passed to bind(); using localhost | :abort | | Program aborted per user request. (CIERR 989) | :shell ,20480000,20480000 | | shell/iX> cd V* | shell/iX> . useful | | shell/iX> # each Basics2B run triggered a line out output in Basics2A... news: Sun releases Java news: Sun releases Java :abort Program aborted per user request. (CIERR 989) : :shell ,20480000,20480000 shell/iX> cd V* shell/iX> . useful shell/iX> # now we move on to the examples/corba/holder demo (don't ask me, shell/iX> # why I picked this; I simply made my way through the HTML docs shell/iX> # and stopped here and there, were it seemed simple enough for me, shell/iX> # a CORBA layman, to get something compiled and running)... shell/iX> # The corba/holder example includes some parts that are not coded shell/iX> # as Java interfaces (the convenient Voyager approach) but as IDL shell/iX> # files that have to be translated to (generated) Java code... shell/iX> # On a PC, we would use the bin/cgen.exe utility, however it seems shell/iX> # that this can also be invoked via Java; so we can add another shell/iX> # convenient alias to our "useful" file later... shell/iX> alias cgen="java1 com.objectspace.voyager.tools.cgen.Cgen" shell/iX> cgen cgen 3.3, copyright objectspace 1997-2000 usage: cgen cgen converts .idl files to/from .class/.java files valid arguments: file name of java file, without extension, to convert to idl file.idl name of idl file to be converted into java -a process lines in as arguments -d store packages relative to -f output flat idl structure -h disable holder generation -i use instead of java -I add to list of #include paths -m map idl typecode entity to/from java class -p process idl files as if they were prepended with -q quiet mode, do not display copyright notice -r use java.rmi.Remote instead of IRemote for pass-by-reference -t make IDL interface extend CosTransactions::TransactionalObject -v verbose mode, display status while processing -x pass remaining parameters to the java interpreter shell/iX> cgen -v -d . -I examples/corba/holder examples/corba/holder/*.idl cgen 3.3, copyright objectspace 1997-2000 reading files... read examples/corba/holder/ILottery.idl got ::examples::corba::holder::ILottery read examples/corba/holder/Person.idl got ::examples::corba::holder::Person read examples/corba/holder/Ticket.idl got ::examples::corba::holder::Ticket writing files... write ./examples/corba/holder/ILotteryHolder.java write ./examples/corba/holder/PersonHolder.java write ./examples/corba/holder/TicketHolder.java write ./examples/corba/holder/ILottery.java write ./examples/corba/holder/Person.java write ./examples/corba/holder/Ticket.java shell/iX> # now that we have added the missing .java files, we can compile shell/iX> # the generated classes as well as the one that we already had... shell/iX> java1c examples/corba/holder/*.java shell/iX> # the example does not use CORBA naming services (which is only shell/iX> # included in the Voyager Professional version; however here I did shell/iX> # not use their trial version, but the free Voyager ORB part) and shell/iX> # thus puts the IOR into a file so that server and client can share shell/iX> # it for object reference purpose. shell/iX> # we'll start the server and then run the client in the other session shell/iX> java2 examples.corba.holder.Server Nonzero address passed to bind(); using localhost lottery IOR = IOR:000000000000002749444c3a6578616d706c65732f636f7262612f686f6c64 65722f494c6f74746572793a312e3000000000000100000000000000280001000000000014687072 74647434302e6772632e68702e636f6d00edec00000000000400000001 CORBA server is ready | shell/iX> # We will run the client part twice, notice the messages that | shell/iX> # show up at server and client side, and finally use Break :ABORT | shell/iX> # to stop the server in the other window (see later)... | | shell/iX> ls -l *.IOR | -rw-rw---- 1 CORBA.IX IX 206 Jul 7 22:50 Lottery.IOR | | shell/iX> cat -v Lottery.IOR | ^@M-LIOR:000000000000002749444c3a6578616d706c65732f636f7262612f686f6c6465722f494 | c6f74746572793a312e3000000000000100000000000000280001000000000014687072746474343 | 02e6772632e68702e636f6d00edec00000000000400000001 | | shell/iX> java2 examples.corba.holder.Client | bank IOR = IOR:000000000000002749444c3a6578616d706c65732f636f7262612f686f6c64657 | 22f494c6f74746572793a312e3000000000000100000000000000280001000000000014687072746 | 47434302e6772632e68702e636f6d00edec00000000000400000001 | money before purchase = 30 | money after purchase = 20 | ticket = Ticket( 23, 42, 11 ) | | shell/iX> java2 examples.corba.holder.Client | bank IOR = IOR:000000000000002749444c3a6578616d706c65732f636f7262612f686f6c64657 | 22f494c6f74746572793a312e3000000000000100000000000000280001000000000014687072746 | 47434302e6772632e68702e636f6d00edec00000000000400000001 | money before purchase = 30 | money after purchase = 20 | ticket = Ticket( 23, 42, 11 ) | | shell/iX> # need to abort server now (not built for shutdown) money before purchase = 30 money after $10 purchase = 20 set ticket to Ticket( 23, 42, 11 ) money before purchase = 30 money after $10 purchase = 20 set ticket to Ticket( 23, 42, 11 ) :abort Program aborted per user request. (CIERR 989) :shell ,20480000,20480000 shell/iX> cd V* shell/iX> . useful shell/iX> # the next example is corba/bank, which shows how to generate IDL shell/iX> # files from Java interfaces (nice feature of Voyager), pass them shell/iX> # to a "client" developer (in corba/javatoidl) and use them for shell/iX> # generating the neccessary interface classes to access the Bank shell/iX> ls -1 examples/corba/bank Account.java Bank.java BatchException.java Client.java IAccount.java IBank.java OverdrawnException.java Server.java shell/iX> ls -1 examples/corba/javatoidl Client.java shell/iX> # first we compile the Bank parts (server and local client) shell/iX> cd examples/corba/bank shell/iX> java1c *.java shell/iX> # then we generate the IDL to export to the ../javatoidl developer shell/iX> alias cgen="java1 com.objectspace.voyager.tools.cgen.Cgen" shell/iX> cgen IBank IAccount OverdrawnException BatchException -v -d ../javatoidl cgen 3.3, copyright objectspace 1997-2000 reading files... read IBank from /IX/CORBA/Voyager3_3/examples/corba/bank/IBank.class read IAccount from /IX/CORBA/Voyager3_3/examples/corba/bank/IAccount.class read OverdrawnException from /IX/CORBA/Voyager3_3/examples/corba/bank/OverdrawnException.class read BatchException from /IX/CORBA/Voyager3_3/examples/corba/bank/BatchException.class writing files... write ../javatoidl/IBank.idl read com.objectspace.voyager.IRemote from zip file /IX/CORBA/Voyager3_3/lib/voyager.jar read java.lang.Object from zip file /usr/local/java/jdk1.1.7/lib/classes.zip read java.lang.Exception from zip file /usr/local/java/jdk1.1.7/lib/classes.zip read java.lang.Throwable from zip file /usr/local/java/jdk1.1.7/lib/classes.zip read java.io.Serializable from zip file /usr/local/java/jdk1.1.7/lib/classes.zip write ../javatoidl/IAccount.idl write ../javatoidl/OverdrawnException.idl write ../javatoidl/BatchException.idl shell/iX> ls -1 ../javatoidl BatchException.idl Client.java IAccount.idl IBank.idl OverdrawnException.idl shell/iX> # now the "client developer" can use the IDL to create his application | shell/iX> cd examples/corba/javatoidl | | shell/iX> alias cgen="java1 com.objectspace.voyager.tools.cgen.Cgen" | | shell/iX> cgen -v *.idl | cgen 3.3, copyright objectspace 1997-2000 | | reading files... | read BatchException.idl | got ::BatchException | read IAccount.idl | got ::IAccount | got ::IAccount::tmp1 | read IBank.idl | got ::IBank | read OverdrawnException.idl | got ::OverdrawnException | | writing files... | write IAccountHolder.java | write tmp1Holder.java | write IBankHolder.java | write BatchException.java | write IAccount.java | write IBank.java | write OverdrawnException.java | | shell/iX> java1c *.java | | shell/iX> ls | BatchException.class IAccount.java IBankHolder.java | BatchException.idl IAccountHolder.class OverdrawnException.class | BatchException.java IAccountHolder.java OverdrawnException.idl | Client.class IBank.class OverdrawnException.java | Client.java IBank.idl tmp1Holder.class | IAccount.class IBank.java tmp1Holder.java | IAccount.idl IBankHolder.class shell/iX> # here we start the Bank server now; it will write the IOR (we shell/iX> # are still not using CORBA naming services) into a file in ../common shell/iX> # so that the client (run from the ../javatoidl directory) can pick shell/iX> # it up; when Bank and Client run on different machines, the example shell/iX> # could be modified to share the IOR via http or LDAP (or Corba name shell/iX> # server ;-) shell/iX> # we trigger a couple of tests from the clients and then abort again shell/iX> pwd /IX/CORBA/Voyager3_3/examples/corba/bank shell/iX> java2 Server Nonzero address passed to bind(); using localhost bank IOR = IOR:000000000000000e49444c3a4942616e6b3a312e3000000000000001000000000 0000028000100000000001468707274647434302e6772632e68702e636f6d001f400000000000040 0000001 server is ready | shell/iX> ls ../common | Bank.IOR IBank.idl | IAccount.idl OverdrawnException.idl | | shell/iX> cat -v ../common/Bank.IOR | ^@M-^\IOR:000000000000000e49444c3a4942616e6b3a312e300000000000000100000000000000 | 28000100000000001468707274647434302e6772632e68702e636f6d001f40000000000004000000 | 01 | | shell/iX> # let's first try the ../bank client twice | | shell/iX> cd ../bank | shell/iX> pwd | /IX/CORBA/Voyager3_3/examples/corba/bank | | shell/iX> java2 Client | start REGULAR client | Nonzero address passed to bind(); using localhost | account balance = 1000 | account balance = 500 | OverdrawnException( only have $500, 1500 ) | | shell/iX> java2 Client | start REGULAR client | Nonzero address passed to bind(); using localhost | account balance = 1000 | account balance = 500 | OverdrawnException( only have $500, 1500 ) | | shell/iX> cd ../javatoidl | shell/iX> pwd | /IX/CORBA/Voyager3_3/examples/corba/javatoidl | | shell/iX> # let's now try the ../javatoidl client | | shell/iX> java2 Client | start CORBA client | bank IOR = IOR:000000000000000e49444c3a4942616e6b3a312e3000000000000001000000000 | 0000028000100000000001468707274647434302e6772632e68702e636f6d001f400000000000040 | 0000001 | account balance = 1000 | account balance = 500 | BatchException( 400, 2 ) | read on bad fd: -1 | | shell/iX> # oops something went wrong here?? let's try again | | shell/iX> java2 Client | start CORBA client | bank IOR = IOR:000000000000000e49444c3a4942616e6b3a312e3000000000000001000000000 | 0000028000100000000001468707274647434302e6772632e68702e636f6d001f400000000000040 | 0000001 | account balance = 1000 | account balance = 500 | BatchException( 400, 2 ) | read on bad fd: -1 | | shell/iX> # hmmm. looks like it needs some investigation. however, I dont | shell/iX> # feel inclined to do that now. it could also be easier if we had | shell/iX> # source code of Voyager to do that. the error *seems* to happen | shell/iX> # during Voyager.shutdown() as BatchException is still displayed. open account open account open account open account :abort Program aborted per user request. (CIERR 989) :shell ,20480000,20480000 shell/iX> cd V* shell/iX> . useful shell/iX> # let's move on to some home-grown example now shell/iX> # you won't find that in the Voyager HTML docs shell/iX> cd lars/basic shell/iX> # this one is a simple "remote adder" using Voyager basics shell/iX> # similar to the Basics2A and Basics2B. it will be modified shell/iX> # to use IDL and CORBA in a second step shell/iX> ls -1 AdderImp.java AdderInt.java Client.java Negative.java Server.java shell/iX> cat AdderInt.java public interface AdderInt { public int add( int a, int b ) throws Negative; public int getTotal(); } shell/iX> cat Negative.java public class Negative extends Exception { public java.lang.String msg; public Negative() { } public Negative( java.lang.String msg ) { super( msg ); this.msg = msg; } } shell/iX> cat AdderImp.java // example for use with Voyager Corba class AdderImp implements AdderInt { /** * total keeps track of add() results, even negative ones */ int total; /** * constructor sets total to zero */ AdderImp() { System.out.println( "Adder: init" ); total = 0; } /** * add() returns the sum or throws an exception, if negative */ public int add(int a, int b) throws Negative { System.out.println( "Adder: add, in=" + a + "," + b ); int sum = a + b; total += sum; if (sum < 0) { System.out.println( "Adder: add throws exception for sum " + sum ); throw new Negative("Adder.add result was " + sum); } else { System.out.println( "Adder: add returns sum " + sum ); return sum; } } /** * getTotal() returns the running total of all add() calls */ public int getTotal() { System.out.println( "Adder: getTotal returns " + total ); return total; } } shell/iX> cat Server.java // test server for Adder example import com.objectspace.voyager.*; class Server { public static void main(String[] args) throws Exception { String port = args[0]; String name = args[1]; Voyager.startup( port ); System.out.println("Server: exporting a new Adder..."); AdderInt a = (AdderInt) Proxy.export( new AdderImp() ); Namespace.bind( name, a ); System.out.println("Server: ready for requests"); } } // example: java Server 1234 /my.adder shell/iX> cat Client.java // test client for Adder example import com.objectspace.voyager.*; class Client { public static void main(String[] args) throws Exception { String objRef = args[0]; Voyager.startup(); System.out.println("Client: locating the Adder..."); AdderInt a = (AdderInt) Namespace.lookup( objRef ); for (int nextArg=1; nextArg + 1 < args.length; nextArg += 2) { int x = Integer.parseInt( args[nextArg+0] ); int y = Integer.parseInt( args[nextArg+1] ); try { System.out.println( "Client: Adder.add(" + x + "," + y + ") returned: " + a.add(x,y) ); } catch (Negative ex) { System.out.println( "Client: Adder.add(" + x + "," + y + ") threw exception\n" + " Exception was: " + ex + "\n Message was: " + ex.msg ); } } System.out.println( "Client: Adder.getTotal() returned: " + a.getTotal() ); Voyager.shutdown(); } } // example: java Client 1234/my.adder 3 4 3 -4 -3 4 shell/iX> # let's compile this example, start the server and then trigger it shell/iX> # by running the client program from another session or even my PC shell/iX> # notice that this is fairly easy by using the Voyager naming service shell/iX> java1c *.java shell/iX> java2 Server 4711 /my.adder Nonzero address passed to bind(); using localhost Server: exporting a new Adder... Adder: init Server: ready for requests | shell/iX> # we first run Client on the 3000 and then on my Windows PC !! | | shell/iX> cd lars/basic | | shell/iX> java2 Client 4711/my.adder 3 4 3 -4 3 -3 | Client: locating the Adder... | Nonzero address passed to bind(); using localhost | Client: Adder.add(3,4) returned: 7 | Client: Adder.add(3,-4) threw exception | Exception was: Negative: Adder.add result was -1 | Message was: Adder.add result was -1 | Client: Adder.add(3,-3) returned: 0 | Client: Adder.getTotal() returned: 6 | | shell/iX> java2 Client 4711/my.adder 3 4 3 -4 3 -3 | Client: locating the Adder... | Nonzero address passed to bind(); using localhost | Client: Adder.add(3,4) returned: 7 | Client: Adder.add(3,-4) threw exception | Exception was: Negative: Adder.add result was -1 | Message was: Adder.add result was -1 | Client: Adder.add(3,-3) returned: 0 | Client: Adder.getTotal() returned: 12 | | shell/iX> The next snippet is from a DOS Window on my PC !! >| D:\>java Client //my3000.grc.hp.com:4711/my.adder 1 1 2 -3 3 -3 >| >| Client: locating the Adder... >| Client: Adder.add(1,1) returned: 2 >| Client: Adder.add(2,-3) threw exception >| Exception was: Negative: Adder.add result was -1 >| Message was: Adder.add result was -1 >| Client: Adder.add(3,-3) returned: 0 >| Client: Adder.getTotal() returned: 13 >| >| D:\>rem We can also try the Server on the PC, invoke it from >| D:\>rem the Client run on MPE/iX and then abort the PC Server >| >| D:\>java Server //my.pc.ip.address:3456 /pc.adder >| >| Server: exporting a new Adder... >| Adder: init >| Server: ready for requests | shell/iX> # and here is the MPE Client run against PC Server... | | shell/iX> java2 Client //my.pc.ip.address:3456/pc.adder 1 1 2 -3 3 -3 | Client: locating the Adder... | Nonzero address passed to bind(); using localhost | Client: Adder.add(1,1) returned: 2 | Client: Adder.add(2,-3) threw exception | Exception was: Negative: Adder.add result was -1 | Message was: Adder.add result was -1 | Client: Adder.add(3,-3) returned: 0 | Client: Adder.getTotal() returned: 1 | | shell/iX> # so much about distributed computing :-) >| Adder: add, in=1,1 >| Adder: add returns sum 2 >| Adder: add, in=2,-3 >| Adder: add throws exception for sum -1 >| Adder: add, in=3,-3 >| Adder: add returns sum 0 >| Adder: getTotal returns 1 >| ^C >| D:\> Adder: add, in=3,4 Adder: add returns sum 7 Adder: add, in=3,-4 Adder: add throws exception for sum -1 Adder: add, in=3,-3 Adder: add returns sum 0 Adder: getTotal returns 6 Adder: add, in=3,4 Adder: add returns sum 7 Adder: add, in=3,-4 Adder: add throws exception for sum -1 Adder: add, in=3,-3 Adder: add returns sum 0 Adder: getTotal returns 12 Adder: add, in=1,1 Adder: add returns sum 2 Adder: add, in=2,-3 Adder: add throws exception for sum -1 Adder: add, in=3,-3 Adder: add returns sum 0 Adder: getTotal returns 13 :abort Program aborted per user request. (CIERR 989) :shell ,20480000,20480000 shell/iX> cd V* ; . useful shell/iX> # now let's look at a similar example, however using IDL and CORBA shell/iX> # it uses IDL for describing the Adder interface, generates classes shell/iX> # using the Voyager cgen utility, compiles all sources and runs the shell/iX> # Server and Client programs; the object reference is passed from shell/iX> # the Server to the Client by writing an IOR to a file (which could shell/iX> # also be shared via http) -- we are not using CORBA naming service shell/iX> # because the free Voyager version does not include it. shell/iX> cd ../corba shell/iX> ls -l -rwxr----- 1 CORBA.IX IX 1039 Jul 7 16:00 AdderImp.java -rwxr----- 1 CORBA.IX IX 1261 Jul 7 16:10 Client.java -rwxr----- 1 CORBA.IX IX 691 Jul 7 16:04 Server.java -rwxr----- 1 CORBA.IX IX 181 Jul 7 15:56 adder.idl shell/iX> cat adder.idl // example for use with Voyager Corba exception Negative { string msg; }; interface AdderInt { long add(in long a, in long b) raises( Negative ); long getTotal(); }; shell/iX> cat AdderImp.java // example for use with Voyager Corba class AdderImp implements AdderInt { /** * total keeps track of add() results, even negative ones */ int total; /** * constructor sets total to zero */ AdderImp() { System.out.println( "Adder: init" ); total = 0; } /** * add() returns the sum or throws an exception, if negative */ public int add(int a, int b) throws Negative { System.out.println( "Adder: add, in=" + a + "," + b ); int sum = a + b; total += sum; if (sum < 0) { System.out.println( "Adder: add throws exception for sum " + sum ); throw new Negative("Adder.add result was " + sum); } else { System.out.println( "Adder: add returns sum " + sum ); return sum; } } /** * getTotal() returns the running total of all add() calls */ public int getTotal() { System.out.println( "Adder: getTotal returns " + total ); return total; } } shell/iX> cat Server.java // test server for Adder example import com.objectspace.voyager.*; import com.objectspace.voyager.corba.*; import java.io.DataOutputStream; import java.io.FileOutputStream; class Server { public static void main(String[] args) throws Exception { String iorFile = args[0]; Voyager.startup("4711"); System.out.println("Server: creating new Adder..."); AdderInt a = new AdderImp(); System.out.println("Server: saving the IOR..."); String ior = Corba.asIOR( a ); DataOutputStream d = new DataOutputStream( new FileOutputStream(iorFile) ); d.writeUTF(ior); d.close(); System.out.println("Server: ready for requests"); } } shell/iX> cat Client.java // test client for Adder example import com.objectspace.voyager.*; import com.objectspace.voyager.corba.*; import java.io.DataInputStream; import java.io.FileInputStream; class Client { public static void main(String[] args) throws Exception { String iorFile = args[0]; Voyager.startup(); System.out.println("Client: loading the IOR..."); DataInputStream d = new DataInputStream( new FileInputStream(iorFile) ); String ior = d.readUTF(); d.close(); System.out.println("Client: locating the Adder..."); AdderInt a = (AdderInt) Namespace.lookup( ior ); for (int nextArg=1; nextArg + 1 < args.length; nextArg += 2) { int x = Integer.parseInt( args[nextArg+0] ); int y = Integer.parseInt( args[nextArg+1] ); try { System.out.println( "Client: Adder.add(" + x + "," + y + ") returned: " + a.add(x,y) ); } catch (Negative ex) { System.out.println( "Client: Adder.add(" + x + "," + y + ") threw exception\n" + " Exception was: " + ex + "\n Message was: " + ex.msg ); } } System.out.println( "Client: Adder.getTotal() returned: " + a.getTotal() ); Voyager.shutdown(); } } shell/iX> cgen -v adder.idl cgen 3.3, copyright objectspace 1997-2000 reading files... read adder.idl got ::Negative got ::AdderInt writing files... write AdderIntHolder.java write Negative.java write AdderInt.java shell/iX> java1c Client.java Server.java shell/iX> # now we can start the Server, trigger it from the Client side shell/iX> # and finally abort it with Break :ABORT (as we did not code it shell/iX> # to also provide a "graceful" shutdown)... shell/iX> java2 Server adder.IOR Nonzero address passed to bind(); using localhost Server: creating new Adder... Adder: init Server: saving the IOR... Server: ready for requests | shell/iX> # we first run the Client from MPE and then also from the PC | | shell/iX> cd ../corba | | shell/iX> ls -l adder.IOR | -rw-rw---- 1 CORBA.IX IX 166 Jul 7 23:38 adder.IOR | | shell/iX> cat -v adder.IOR | ^@M-$IOR:000000000000001149444c3a4164646572496e743a312e3000000000000000010000000 | 000000028000100000000001468707274647434302e6772632e68702e636f6d00126700000000000 | 400000001 | | shell/iX> java2 Client adder.IOR 3 4 3 -4 3 -3 | Client: loading the IOR... | Client: locating the Adder... | Client: Adder.add(3,4) returned: 7 | Client: Adder.add(3,-4) threw exception | Exception was: Negative( Adder.add result was -1 ) | Message was: Adder.add result was -1 | Client: Adder.add(3,-3) returned: 0 | Client: Adder.getTotal() returned: 6 | | shell/iX> # notice that I am sharing the IOR file with the PC by having | shell/iX> # it in a directory that the PC can access as "network drive" | shell/iX> # another option (besides CORBA naming services) would be to | shell/iX> # place the IOR file where it can be accessed by http (as the | shell/iX> # Java Client could easily retrieve it by URL) >| D:\>java Client F:\Voyager3_3\lars\corba\adder.IOR 3 4 3 -4 3 -3 >| >| Client: loading the IOR... >| Client: locating the Adder... >| Client: Adder.add(3,4) returned: 7 >| Client: Adder.add(3,-4) threw exception >| Exception was: Negative( Adder.add result was -1 ) >| Message was: Adder.add result was -1 >| Client: Adder.add(3,-3) returned: 0 >| Client: Adder.getTotal() returned: 12 Adder: add, in=3,4 Adder: add returns sum 7 Adder: add, in=3,-4 Adder: add throws exception for sum -1 Adder: add, in=3,-3 Adder: add returns sum 0 Adder: getTotal returns 6 Adder: add, in=3,4 Adder: add returns sum 7 Adder: add, in=3,-4 Adder: add throws exception for sum -1 Adder: add, in=3,-3 Adder: add returns sum 0 Adder: getTotal returns 12 :abort Program aborted per user request. (CIERR 989) :bye | shell/iX> # after this, I also tried to reverse the roles by running | shell/iX> # the Server on my PC and the Client on the 3000 (telling the | shell/iX> # Server program to place the IOR file on drive F: where the | shell/iX> # MPE program could easily access it; however, it did not work | shell/iX> # as expected, the Client timed out after a while; my current | shell/iX> # guess is that the IOR does contain a reference to the server | shell/iX> # machine that my client 3000 could not resolve (the PC name | shell/iX> # does not match its DNS name in my specific test scenario); | shell/iX> # however, I did not yet take the time to investigate this, as | shell/iX> # I am not quite an expert on CORBA and IOR contents. | shell/iX> exit | : bye