File: StockServer.java

package info (click to toggle)
libpgjava 8.1-405-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 3,484 kB
  • ctags: 4,266
  • sloc: java: 32,071; xml: 3,017; sql: 21; makefile: 18; sh: 10
file content (58 lines) | stat: -rw-r--r-- 1,745 bytes parent folder | download
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.
 *
 * $PostgreSQL: pgjdbc/example/corba/StockServer.java,v 1.7 2004/11/09 08:43:20 jurka 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();
        }
    }
}