Java Reference
In-Depth Information
class StockItemFactoryServant
extends _StockItemFactoryImplBase
//Code as shown in step 3 above.
5. Compile the server and the idl-generated fi les.
From the directory above directory Sales , execute the following command within a
command window:
javac Sales\*.java
(Correct errors and recompile, as necessary.)
6. Create a client.
Our client program will be called and, like the server program,
will import package Sales . As with the client program in the previous example, it
should also import org.omg.CosNaming and org.omg.CORBA . In addition to the
steps executed by the client in the previous example, the steps listed below will be
carried out.
￿ Several method calls will be made on the (pre-existing) StockItem object, rather
than just the one made on the Hello object.
￿ A reference to the StockItemFactory object created and registered by the server
will be obtained.
￿ The above reference will be used to create a new StockItem object by invoking
method createStockItem (supplying the arguments required by the constructor).
Methods of the new StockItem object will be invoked, to demonstrate once again
that the object may be treated in just the same way as a local object.
The full code is shown below, with comments indicating the purpose of each
import Sales.*;
import org.omg.CosNaming.*;
import org.omg.CORBA.*;
public class StockItemClient
public static void main(String[] args)
//Create and initialise the ORB…
ORB orb = ORB.init(args,null);
//Get a reference to the root naming context…
org.omg.CORBA.Object objectRef =
Search WWH ::

Custom Search