blob: 77d8946389b0910d2281399d11362815f5532321 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package example.corba;
import org.omg.CosNaming.*;
/*
* This class implements the server side of the example.
*
* $Id: StockServer.java,v 1.3 2001/11/19 22:43:13 momjian Exp $
*/
public class StockServer
{
public static void main(String[] args)
{
int numInstances = 3;
try
{
// Initialise the ORB
org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
// Create the StockDispenser object
StockDispenserImpl dispenser = new StockDispenserImpl(args, "Stock Dispenser", numInstances);
// Export the new object
orb.connect(dispenser);
// Get the naming service
org.omg.CORBA.Object nameServiceObj = orb.resolve_initial_references("NameService");
if (nameServiceObj == null)
{
System.err.println("nameServiceObj = null");
return ;
}
org.omg.CosNaming.NamingContext nameService = org.omg.CosNaming.NamingContextHelper.narrow(nameServiceObj);
if (nameService == null)
{
System.err.println("nameService = null");
return ;
}
// bind the dispenser into the naming service
NameComponent[] dispenserName = {
new NameComponent("StockDispenser", "Stock")
};
nameService.rebind(dispenserName, dispenser);
// Now wait forever for the current thread to die
Thread.currentThread().join();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
|