![]() ![]() ![]() |
|
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In this Magercise, you will add a factory interface with a single create operation to the stock IDL file, implement it, generate JavaTM programming code from the IDL file and then compile and run the distributed stock application. This Magercise can be completed using either Sun's Java 2TM ORB or Inprise's VisiBroker 3.x for Java. Notes on these products are available:
PrerequisitesSkeleton Code
Tasks
[Modify IDL file] First edit the IDL file. The StockObjects module
in the IDL file defines the interface to a stock object. But there is
currently no way for a client to create stock objects. You need to add
another interface,
[Run IDL Compiler] At the command line, run the IDL compiler to generate Java code from the IDL file.
[Compile the generated Java code] Now compile the generated Java
code using the
standard Java compiler.
Compile it in the generated
[Examine the generated Java files] All the files will be generated
into the
Look carefully at the
file
[Implement the stock factory] The skeleton code file we have given you,
[Create Server Class] Now look at the file There is nothing for you to do except look at the file. Look carefully at each line.
[Create Client Class] In the file
[Compile the program] Now compile the program using the standard Java compiler.
[Run the Server program]
The server needs to run as a separate process. In DOS/Windows, you
will use the The Server outputs an IOR (or stringified reference) to a file and to the console for the Stock factory object it creates. The name of the file is passed as the first argument to the server.
To run the server, use the normal Putting it all together:
[Run the Client program] The client reads the stringified object reference of the stock factory object created by your server. An file containing the stringified object reference is passed as the first argument to the client. The second and third arguments passed to the client is the stock symbol and company description of the stock to be created. Note the following commands are each on a single line.
[Kill the Server] Don't forget to kill the server. Where help exists, the task numbers above are linked to the step-by-step help page. This Magercise has walked you through the steps of adding dynamic distributed object creation by means of a factory object. As you probably observed, a factory object is just like any other CORBA object. Solution SourceDemonstration
When you start the server it should output: Created stock factory IOR:000000000000002249444c3a53746f636b4f626a656374732f53746f63 6b466163746f72793a312e3000000000000001000000000000005400010000 0000000c3139322e3136382e302e3100073400000000003800504d43000000 010000002249444c3a53746f636b4f626a656374732f53746f636b46616374 6f72793a312e300000000000000153c5e784 The value of the IOR string will of course be different.
When you run the client with arguments
Created gii for Global Industries Inc. Next MagerciseMagercisesShort CourseCopyright © 1998-1999 MageLang Institute. All Rights Reserved. |