![]() ![]() ![]() |
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Help is available for each task.
Task 1First generate the IDL file. Use idl2java messageBox.idl , as in the previous Magercise.
Task 2
Examine the generated Java interface in Don't forget to add a constructor. It should take a string argument as a name, and call the superclass constructor to set the name of the object.
Notice how the sequence is generated. No The methods you will implement are: public MessageBoxImpl(String name, int max); public void reply(java.lang.String reply); public java.lang.String reply(); public java.lang.String leaveMessage( java.lang.String msg) throws ; public java.lang.String[] getMessages(); You will also need local variables to hold the value of the reply, and a vector for the messages. For example: protected String _reply; protected int _max; protected Vector _messages = new Vector(5); Task 3
Modify the You might want to enter the object instance name on the command-line, using code like the following: if (args.length > 0) name = args[0]; Task 4
Look at the vbj MBClient servername command param vbj MBClient servername leave message vbj MBClient servername reply reply-messsage vbj MBClient servername get Task 5
Finish the skeleton version of Here is an example of code you can add: // set the reply mb.reply(param); // leave a message try { System.out.println(mb.leaveMessage(param)); } catch ( MessageModule.MessageBoxPackage.boxFull e) { System.out.println( "Box full, message not left"); } // get messages String[] messages = mb.getMessages(); for(int i = 0; i < messages.length; i++) System.out.println(" " + messages[i]); Task 6
Now compile the program, using Use the command: vjbc *.java
Task 7
Run the server: Task 8
Run the client: See the expected behavior section for more detail on the correct output for your program. Task 9If you happen to have multiple machines, run the program on each and leave and retrieve messages on the other message boxes. Copyright © 1998-1999 MageLang Institute. All Rights Reserved. |