Java Reference
In-Depth Information
/*
Use factory reference to create a StockItem
object on the server and return a reference to
this
StockItem
(using method
createStockItem
within the
StockItemFactory
interface)…
*/
StockItem stockRef2 =
stockFactoryRef.createStockItem("S0002",200);
//Now use this reference to call methods of the
//new
StockItem
object…
System.out.println("\nStock code: "
+ stockRef2.code());
System.out.println("Current level: "
+ stockRef2.currentLevel());
}
catch (Exception ex)
{
System.out.println("*** Client error! ***");
ex.printStackTrace();
}
}
}
7. Compile the client.
From the directory above directory
Sales
, execute the following command:
javac StockItemClient.java
8. Run the application.
As before, this requires three steps…
(i)
Start the CORBA naming service (unless it is already running)
.
Enter the following command:
tnameserv
Output should be as shown in Fig.
6.3
.
N.B. Attempting to start (another instance of) the naming service when it is
already running will generate an error message!
(ii)
Start the server in a new command window
.
The command for the current application will be:
java StockItemServer
Output should be as shown in Fig.
6.5
.
Search WWH ::
Custom Search